soby 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/soby.rb +77 -78
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d65c06b2a1b4f7fb9baa781273823ee83a98dbf
|
4
|
+
data.tar.gz: 4be8a4d47977a8c4e635010bf8929b73118b2f8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7021ff045f8a62b4c998d65494578987bbdae8e9bda04a5f3d9f9f51f91864e6c93a4331d9b34610453d7206059695a23ee150a1675763c75574809ed353d919
|
7
|
+
data.tar.gz: e79848a3b0e5fea1a683c59d1688f98b1624a8701730fd8e57878eda451921c73a36a65ab86111f6e17137af48a9f159ed75616fed856e81d69c714eb00fb9db
|
data/lib/soby.rb
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
require 'nokogiri' # for XML.
|
4
|
-
require '
|
5
|
-
require '
|
4
|
+
require 'jruby_art'
|
5
|
+
require 'jruby_art/app'
|
6
6
|
|
7
|
-
Processing::Runner
|
8
|
-
Dir["#{Processing::RP_CONFIG['PROCESSING_ROOT']}/core/library/\*.jar"].each{ |jar| require jar }
|
9
7
|
|
10
|
-
|
8
|
+
require 'java'
|
9
|
+
|
10
|
+
# Processing::App::SKETCH_PATH = Dir.pwd
|
11
|
+
|
12
|
+
# For the other files, we need to load the libraries
|
11
13
|
Processing::App::load_library 'video', 'toxiclibscore'
|
12
14
|
|
13
15
|
require_relative 'soby/transforms'
|
14
16
|
require_relative 'soby/presentation'
|
15
17
|
require_relative 'soby/slide'
|
16
18
|
require_relative 'soby/cam'
|
17
|
-
require_relative 'soby/launcher'
|
19
|
+
require_relative 'soby/launcher'
|
18
20
|
|
19
21
|
class SobyPlayer < Processing::App
|
20
22
|
|
@@ -28,7 +30,7 @@ class SobyPlayer < Processing::App
|
|
28
30
|
|
29
31
|
# attr_accessor :background_max_color, :background_min_color, :background_constrain
|
30
32
|
attr_accessor :cam
|
31
|
-
|
33
|
+
|
32
34
|
def running? () @is_running end
|
33
35
|
|
34
36
|
TRANSITION_DURATION = 1000
|
@@ -38,38 +40,37 @@ class SobyPlayer < Processing::App
|
|
38
40
|
@h = h
|
39
41
|
super()
|
40
42
|
end
|
41
|
-
|
42
|
-
# no Border
|
43
|
-
def init
|
43
|
+
|
44
|
+
# no Border
|
45
|
+
def init
|
44
46
|
super
|
45
47
|
removeFrameBorder
|
46
48
|
end
|
47
|
-
|
49
|
+
|
48
50
|
def removeFrameBorder
|
49
51
|
frame.removeNotify
|
50
52
|
frame.setUndecorated true
|
51
53
|
frame.addNotify
|
52
|
-
end
|
54
|
+
end
|
53
55
|
|
56
|
+
def settings
|
57
|
+
size @w, @h, P3D
|
58
|
+
end
|
54
59
|
|
55
|
-
def setup
|
60
|
+
def setup
|
56
61
|
@ready = false
|
57
|
-
size @w, @h, OPENGL
|
58
|
-
|
59
|
-
## Some bugs with this.
|
60
|
-
frame.setResizable true if frame != nil
|
61
62
|
|
62
63
|
init_player
|
63
64
|
|
64
65
|
@custom_setup_done = true
|
65
66
|
@ready = true
|
66
|
-
end
|
67
|
+
end
|
67
68
|
|
68
69
|
def ready?
|
69
70
|
@ready
|
70
71
|
end
|
71
72
|
|
72
|
-
def init_player
|
73
|
+
def init_player
|
73
74
|
@prez = nil
|
74
75
|
@current_slide_no = 0
|
75
76
|
@is_running = false
|
@@ -77,10 +78,10 @@ class SobyPlayer < Processing::App
|
|
77
78
|
end
|
78
79
|
|
79
80
|
def init_cameras
|
80
|
-
# current camera matrix
|
81
|
+
# current camera matrix
|
81
82
|
@cam = PMatrix3D.new
|
82
83
|
|
83
|
-
# Cameras for movement.
|
84
|
+
# Cameras for movement.
|
84
85
|
@prev_cam = Cam.new
|
85
86
|
@next_cam = Cam.new
|
86
87
|
@is_moving = false
|
@@ -88,7 +89,7 @@ class SobyPlayer < Processing::App
|
|
88
89
|
end
|
89
90
|
|
90
91
|
|
91
|
-
## To be overriden by the Presentation Code.
|
92
|
+
## To be overriden by the Presentation Code.
|
92
93
|
def custom_setup
|
93
94
|
|
94
95
|
end
|
@@ -102,9 +103,9 @@ class SobyPlayer < Processing::App
|
|
102
103
|
end
|
103
104
|
|
104
105
|
|
105
|
-
def draw
|
106
|
+
def draw
|
106
107
|
|
107
|
-
if not @custom_setup_done
|
108
|
+
if not @custom_setup_done
|
108
109
|
custom_setup
|
109
110
|
@custom_setup_done = true
|
110
111
|
end
|
@@ -117,7 +118,7 @@ class SobyPlayer < Processing::App
|
|
117
118
|
imageMode(CORNER)
|
118
119
|
|
119
120
|
if(running?)
|
120
|
-
|
121
|
+
|
121
122
|
push_matrix
|
122
123
|
|
123
124
|
update_cam
|
@@ -126,26 +127,26 @@ class SobyPlayer < Processing::App
|
|
126
127
|
@prez.display_videos
|
127
128
|
pop_matrix
|
128
129
|
|
129
|
-
run_slide_code
|
130
|
-
display_slide_number
|
130
|
+
run_slide_code
|
131
|
+
display_slide_number
|
131
132
|
end
|
132
133
|
|
133
134
|
custom_post_draw
|
134
135
|
end
|
135
136
|
|
136
|
-
def run_slide_code
|
137
|
+
def run_slide_code
|
137
138
|
translate 0, 0, 1
|
138
139
|
if not @is_moving and @current_slide_no != 0
|
139
140
|
desc = @prez.slides[@current_slide_no].description
|
140
141
|
if(desc != nil)
|
141
|
-
# puts "EVAL #{desc}"
|
142
|
+
# puts "EVAL #{desc}"
|
142
143
|
eval desc
|
143
|
-
end
|
144
|
+
end
|
144
145
|
end
|
145
146
|
end
|
146
147
|
|
147
148
|
|
148
|
-
def display_slide_number
|
149
|
+
def display_slide_number
|
149
150
|
# Slide number
|
150
151
|
push_matrix
|
151
152
|
translate(@width - 40, @height - 45)
|
@@ -155,52 +156,52 @@ class SobyPlayer < Processing::App
|
|
155
156
|
ellipseMode(CENTER)
|
156
157
|
ellipse(18, 22, 35, 35)
|
157
158
|
fill(255)
|
158
|
-
noStroke
|
159
|
+
noStroke
|
159
160
|
textSize(20)
|
160
161
|
text(@current_slide_no.to_s, 10, 30)
|
161
162
|
pop_matrix
|
162
163
|
end
|
163
164
|
|
164
|
-
alias :default_display_slide_number :display_slide_number
|
165
|
+
alias :default_display_slide_number :display_slide_number
|
165
166
|
|
166
167
|
|
167
168
|
def key_pressed
|
168
169
|
|
169
|
-
if key == 'g'
|
170
|
+
if key == 'g'
|
170
171
|
puts "Garbage"
|
171
|
-
Java::JavaLang::System.gc
|
172
|
-
end
|
172
|
+
Java::JavaLang::System.gc
|
173
|
+
end
|
173
174
|
|
174
175
|
return if @prez == nil
|
175
176
|
|
176
|
-
if keyCode == LEFT
|
177
|
+
if keyCode == LEFT
|
177
178
|
prev_slide
|
178
179
|
end
|
179
180
|
|
180
181
|
if keyCode == RIGHT
|
181
182
|
next_slide
|
182
183
|
end
|
183
|
-
|
184
|
+
|
184
185
|
# puts "slide #{@current_slide_no} "
|
185
186
|
end
|
186
187
|
|
187
188
|
def mouse_dragged
|
188
|
-
if not @is_moving
|
189
|
-
tr = PMatrix3D.new
|
189
|
+
if not @is_moving
|
190
|
+
tr = PMatrix3D.new
|
190
191
|
tr.translate(mouse_x - pmouse_x, mouse_y - pmouse_y)
|
191
|
-
|
192
|
+
|
192
193
|
@cam.preApply(tr)
|
193
194
|
@next_cam.mat.preApply(tr)
|
194
195
|
end
|
195
196
|
end
|
196
197
|
|
197
|
-
def mouseWheel(event)
|
198
|
+
def mouseWheel(event)
|
198
199
|
e = event.getAmount()
|
199
|
-
if not @is_moving
|
200
|
-
tr = PMatrix3D.new
|
201
|
-
tr.translate(mouse_x, mouse_y)
|
200
|
+
if not @is_moving
|
201
|
+
tr = PMatrix3D.new
|
202
|
+
tr.translate(mouse_x, mouse_y)
|
202
203
|
tr.scale(e < 0 ? 1.05 : 1 / 1.05)
|
203
|
-
tr.translate(-mouse_x, -mouse_y)
|
204
|
+
tr.translate(-mouse_x, -mouse_y)
|
204
205
|
@cam.preApply(tr)
|
205
206
|
end
|
206
207
|
end
|
@@ -209,8 +210,8 @@ class SobyPlayer < Processing::App
|
|
209
210
|
def set_prez (prez)
|
210
211
|
|
211
212
|
current_slide = @current_slide_no
|
212
|
-
|
213
|
-
# PShape.loadedImages.clear
|
213
|
+
|
214
|
+
# PShape.loadedImages.clear
|
214
215
|
@prez = prez
|
215
216
|
@slides = prez.slides
|
216
217
|
|
@@ -219,7 +220,7 @@ class SobyPlayer < Processing::App
|
|
219
220
|
@is_running = true
|
220
221
|
@prez_middle = PVector.new(@prez.width / 2.0, @prez.height / 2.0)
|
221
222
|
|
222
|
-
puts "Presentation size "
|
223
|
+
puts "Presentation size "
|
223
224
|
puts @prez.width
|
224
225
|
puts @prez.height
|
225
226
|
|
@@ -237,23 +238,23 @@ class SobyPlayer < Processing::App
|
|
237
238
|
view.shape(@prez.pshape, 0, 0)
|
238
239
|
view.endDraw
|
239
240
|
|
240
|
-
view
|
241
|
+
view
|
241
242
|
end
|
242
243
|
|
243
244
|
|
244
245
|
def next_slide
|
245
|
-
is_last_slide = @current_slide_no >= @prez.nb_slides
|
246
|
+
is_last_slide = @current_slide_no >= @prez.nb_slides
|
246
247
|
is_slide_zero = current_slide_no == 0
|
247
248
|
|
248
249
|
# Gloal view
|
249
250
|
if is_slide_zero
|
250
251
|
goto_slide(@current_slide_no + 1)
|
251
|
-
return
|
252
|
+
return
|
252
253
|
end
|
253
254
|
|
254
255
|
# animation
|
255
256
|
if @slides[@current_slide_no].has_next_animation?
|
256
|
-
puts "Animation Next "
|
257
|
+
puts "Animation Next "
|
257
258
|
anim = @slides[@current_slide_no].next_animation
|
258
259
|
anim.pshape_elem.setVisible(true)
|
259
260
|
else
|
@@ -265,31 +266,31 @@ class SobyPlayer < Processing::App
|
|
265
266
|
def prev_slide
|
266
267
|
return if @current_slide_no <= 0
|
267
268
|
|
268
|
-
if current_slide_no == 0
|
269
|
-
goto_slide(@current_slide_no - 1)
|
270
|
-
return
|
269
|
+
if current_slide_no == 0
|
270
|
+
goto_slide(@current_slide_no - 1)
|
271
|
+
return
|
271
272
|
end
|
272
273
|
|
273
274
|
if @slides[@current_slide_no].has_previous_animation?
|
274
|
-
puts "Animation Previous "
|
275
|
+
puts "Animation Previous "
|
275
276
|
anim = @slides[@current_slide_no].previous_animation
|
276
277
|
anim.pshape_elem.setVisible(false)
|
277
278
|
else
|
278
|
-
goto_slide(@current_slide_no - 1)
|
279
|
+
goto_slide(@current_slide_no - 1)
|
279
280
|
end
|
280
281
|
|
281
282
|
end
|
282
283
|
|
283
284
|
def goto_slide (next_slide)
|
284
285
|
|
285
|
-
current_slide = @current_slide_no
|
286
|
+
current_slide = @current_slide_no
|
286
287
|
|
287
|
-
use_global_view = next_slide == 0 || next_slide > @prez.slides.size
|
288
|
+
use_global_view = next_slide == 0 || next_slide > @prez.slides.size
|
288
289
|
|
289
290
|
cam = global_view if use_global_view
|
290
|
-
cam = slide_view(next_slide) if next_slide > 0
|
291
|
+
cam = slide_view(next_slide) if next_slide > 0
|
291
292
|
|
292
|
-
# previous next is now old.
|
293
|
+
# previous next is now old.
|
293
294
|
@prev_cam = @next_cam
|
294
295
|
@prev_cam.mat.set(@cam)
|
295
296
|
@next_cam = cam
|
@@ -303,7 +304,7 @@ class SobyPlayer < Processing::App
|
|
303
304
|
end
|
304
305
|
|
305
306
|
@transition_start_time = millis
|
306
|
-
@is_moving = true
|
307
|
+
@is_moving = true
|
307
308
|
@current_ratio = 0
|
308
309
|
|
309
310
|
## trigger the slide_change function (user defined)
|
@@ -315,7 +316,7 @@ class SobyPlayer < Processing::App
|
|
315
316
|
end
|
316
317
|
|
317
318
|
|
318
|
-
def update_cam
|
319
|
+
def update_cam
|
319
320
|
|
320
321
|
return unless @is_moving
|
321
322
|
return if @slides.size == 0
|
@@ -329,7 +330,7 @@ class SobyPlayer < Processing::App
|
|
329
330
|
@is_moving = false
|
330
331
|
@cam = @prev_cam.lerp(@next_cam, 1)
|
331
332
|
|
332
|
-
# save a copy
|
333
|
+
# save a copy
|
333
334
|
@prev_cam.mat = @cam.get
|
334
335
|
return
|
335
336
|
end
|
@@ -337,16 +338,16 @@ class SobyPlayer < Processing::App
|
|
337
338
|
# puts @current_ratio
|
338
339
|
@cam = @prev_cam.lerp(@next_cam, @current_ratio)
|
339
340
|
|
340
|
-
end
|
341
|
+
end
|
341
342
|
|
342
343
|
def slide_view (slide_no)
|
343
344
|
|
344
|
-
if slide_no > @prez.slides.size
|
345
|
-
puts "No more slides"
|
345
|
+
if slide_no > @prez.slides.size
|
346
|
+
puts "No more slides"
|
346
347
|
return
|
347
348
|
end
|
348
349
|
|
349
|
-
return if @prez.slides[slide_no] == nil
|
350
|
+
return if @prez.slides[slide_no] == nil
|
350
351
|
|
351
352
|
puts "slide view..." << slide_no.to_s
|
352
353
|
|
@@ -359,22 +360,22 @@ class SobyPlayer < Processing::App
|
|
359
360
|
sc1 = @width.to_f / w.to_f
|
360
361
|
sc2 = @height.to_f / h.to_f
|
361
362
|
|
362
|
-
# scale
|
363
|
+
# scale
|
363
364
|
sc = [sc1, sc2].min
|
364
365
|
|
365
366
|
|
366
|
-
# translate
|
367
|
+
# translate
|
367
368
|
dx = ((@width / sc) - w) * 0.5
|
368
369
|
dy = ((@height / sc) - h) * 0.5
|
369
370
|
|
370
371
|
cam = Cam.new
|
371
372
|
|
372
|
-
m = PMatrix3D.new
|
373
|
+
m = PMatrix3D.new
|
373
374
|
m.apply @prez.slides[slide_no].matrix
|
374
375
|
m.invert
|
375
376
|
|
376
377
|
# Scale
|
377
|
-
tr = PMatrix3D.new
|
378
|
+
tr = PMatrix3D.new
|
378
379
|
tr.scale(sc)
|
379
380
|
m.preApply(tr)
|
380
381
|
m.translate(dx, dy)
|
@@ -386,17 +387,17 @@ class SobyPlayer < Processing::App
|
|
386
387
|
end
|
387
388
|
|
388
389
|
|
389
|
-
def global_view
|
390
|
+
def global_view
|
390
391
|
# ortho(left, right, bottom, top)
|
391
392
|
# frustum(left, right, bottom, top, near, far)
|
392
|
-
|
393
|
+
|
393
394
|
my_scale = find_scale
|
394
395
|
|
395
396
|
# centering
|
396
397
|
dx = ((@width / my_scale) - @prez.width) * 0.5
|
397
398
|
dy = ((@height / my_scale) - @prez.height) * 0.5
|
398
399
|
|
399
|
-
cam = Cam.new
|
400
|
+
cam = Cam.new
|
400
401
|
cam.scale = my_scale
|
401
402
|
# Not necessary : display from the center...
|
402
403
|
cam.post_translation.set(dx, dy)
|
@@ -413,5 +414,3 @@ class SobyPlayer < Processing::App
|
|
413
414
|
|
414
415
|
|
415
416
|
end
|
416
|
-
|
417
|
-
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Laviole
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
|
-
- -
|
16
|
+
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
18
|
version: 1.6.3
|
19
19
|
name: nokogiri
|
@@ -21,24 +21,24 @@ dependencies:
|
|
21
21
|
type: :runtime
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.6.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
|
-
- -
|
30
|
+
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
33
|
-
name:
|
32
|
+
version: 0.8.0
|
33
|
+
name: jruby_art
|
34
34
|
prerelease: false
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
description: Based on Sozi, it
|
40
|
+
version: 0.8.0
|
41
|
+
description: Based on Sozi, it plays presentation using JRubyArt.
|
42
42
|
email: poqudrof@gmail.com
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
@@ -60,17 +60,17 @@ require_paths:
|
|
60
60
|
- lib
|
61
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
62
62
|
requirements:
|
63
|
-
- -
|
63
|
+
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: '0'
|
66
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 2.4.
|
73
|
+
rubygems_version: 2.4.8
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: Sozi player !
|