processing 0.5.13 → 0.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog.md +10 -0
- data/VERSION +1 -1
- data/lib/processing/context.rb +100 -8
- data/lib/processing/graphics_context.rb +32 -0
- data/lib/processing/window.rb +28 -4
- data/processing.gemspec +5 -8
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 311dd968164719386205299dcfeaf129213ab0837975e995f09568fb9180e0e3
|
4
|
+
data.tar.gz: 0b566cc36e09ba7e87624144ad5293f699f3662f1b114d24fd5738ed137a079b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4c627e0c5f44104b12dcb83b0e08257d416115797923af02ee156d8c6c72f309bc55fe19cce5db73de41582546550e31e42d0e543bd9a368107cfb7a3870ec4
|
7
|
+
data.tar.gz: 7c452bb4ad0144326991dddfd12f4e2ff60b5db8095b649630d27a9620b2070eb1b3a63424f03b13d26c45bc2c9a346670b3bd814604fce8f10d67a5612a9e54
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# processing ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.5.14] - 2023-05-29
|
5
|
+
|
6
|
+
- Add windowMove() and windowResize()
|
7
|
+
- Add windowMoved(), windowResized(), and windowResizable()
|
8
|
+
- Add windowX() and windowY()
|
9
|
+
- Add displayWidth(), displayHeight(), pixelWidth(), pixelHeight(), and pixelDensity()
|
10
|
+
- Add doc for width() and height()
|
11
|
+
- Fix crash on calling size()
|
12
|
+
|
13
|
+
|
4
14
|
## [v0.5.13] - 2023-05-27
|
5
15
|
|
6
16
|
- pushMatrix(), pushStyle(), and push() return the result of the expression at the end of the block when a block given
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.14
|
data/lib/processing/context.rb
CHANGED
@@ -144,6 +144,14 @@ module Processing
|
|
144
144
|
(@touchMovedBlock__ || @mouseDraggedBlock__)&.call
|
145
145
|
end
|
146
146
|
|
147
|
+
@window__.move = proc do |e|
|
148
|
+
@windowMovedBlock__&.call
|
149
|
+
end
|
150
|
+
|
151
|
+
@window__.resize = proc do |e|
|
152
|
+
@windowResizedBlock__&.call
|
153
|
+
end
|
154
|
+
|
147
155
|
@window__.motion = proc do |e|
|
148
156
|
@motionGravity__ = createVector(*e.gravity.to_a(3))
|
149
157
|
@motionBlock__&.call
|
@@ -173,6 +181,8 @@ module Processing
|
|
173
181
|
@touchStartedBlock__ ||
|
174
182
|
@touchEndedBlock__ ||
|
175
183
|
@touchMovedBlock__ ||
|
184
|
+
@windowMovedBlock__ ||
|
185
|
+
@windowResizedBlock__ ||
|
176
186
|
@motionBlock__
|
177
187
|
end
|
178
188
|
|
@@ -284,6 +294,24 @@ module Processing
|
|
284
294
|
nil
|
285
295
|
end
|
286
296
|
|
297
|
+
# Defines windowMoved block.
|
298
|
+
#
|
299
|
+
# @return [nil] nil
|
300
|
+
#
|
301
|
+
def windowMoved(&block)
|
302
|
+
@windowMovedBlock__ = block if block
|
303
|
+
nil
|
304
|
+
end
|
305
|
+
|
306
|
+
# Defines windowResized block.
|
307
|
+
#
|
308
|
+
# @return [nil] nil
|
309
|
+
#
|
310
|
+
def windowResized(&block)
|
311
|
+
@windowResizedBlock__ = block if block
|
312
|
+
nil
|
313
|
+
end
|
314
|
+
|
287
315
|
# Defines motion block.
|
288
316
|
#
|
289
317
|
# @return [nil] nil
|
@@ -345,14 +373,27 @@ module Processing
|
|
345
373
|
def resizeCanvas__(name, width, height, pixelDensity)
|
346
374
|
raise '#{name}() must be called on startup or setup block' if @started__
|
347
375
|
|
348
|
-
@painter__.__send__ :end_paint
|
349
376
|
@window__.resize_canvas width, height, pixelDensity
|
350
377
|
@window__.auto_resize = false
|
351
|
-
ensure
|
352
|
-
@painter__.__send__ :begin_paint
|
353
378
|
end
|
354
379
|
|
355
|
-
# Returns
|
380
|
+
# Returns the width of the display.
|
381
|
+
#
|
382
|
+
# @return [Numeric] width
|
383
|
+
#
|
384
|
+
def displayWidth()
|
385
|
+
@window__.screen.width
|
386
|
+
end
|
387
|
+
|
388
|
+
# Returns the height of the display.
|
389
|
+
#
|
390
|
+
# @return [Numeric] height
|
391
|
+
#
|
392
|
+
def displayHeight()
|
393
|
+
@window__.screen.height
|
394
|
+
end
|
395
|
+
|
396
|
+
# Returns the pixel density of the display.
|
356
397
|
#
|
357
398
|
# @return [Numeric] pixel density
|
358
399
|
#
|
@@ -360,7 +401,58 @@ module Processing
|
|
360
401
|
@window__.painter.pixel_density
|
361
402
|
end
|
362
403
|
|
363
|
-
#
|
404
|
+
# Move the position of the window.
|
405
|
+
#
|
406
|
+
# @param [Numeric] x x position of the window
|
407
|
+
# @param [Numeric] y y position of the window
|
408
|
+
#
|
409
|
+
# @return [nil] nil
|
410
|
+
#
|
411
|
+
def windowMove(x, y)
|
412
|
+
@window__.pos = [x, y]
|
413
|
+
nil
|
414
|
+
end
|
415
|
+
|
416
|
+
# Sets the size of the window.
|
417
|
+
#
|
418
|
+
# @param [Numeric] width width of the window
|
419
|
+
# @param [Numeric] height height of the window
|
420
|
+
#
|
421
|
+
# @return [nil] nil
|
422
|
+
#
|
423
|
+
def windowResize(width, height)
|
424
|
+
@window__.size = [width, height]
|
425
|
+
nil
|
426
|
+
end
|
427
|
+
|
428
|
+
# Makes the window resizable or not.
|
429
|
+
#
|
430
|
+
# @param [Boolean] resizable resizable or not
|
431
|
+
#
|
432
|
+
# @return [nil] nil
|
433
|
+
#
|
434
|
+
def windowResizable(resizable)
|
435
|
+
@window__.resizable = resizable
|
436
|
+
nil
|
437
|
+
end
|
438
|
+
|
439
|
+
# Returns the x position of the window.
|
440
|
+
#
|
441
|
+
# @return [Numeric] horizontal position of the window
|
442
|
+
#
|
443
|
+
def windowX()
|
444
|
+
@window__.x
|
445
|
+
end
|
446
|
+
|
447
|
+
# Returns the y position of the window.
|
448
|
+
#
|
449
|
+
# @return [Numeric] vertical position of the window
|
450
|
+
#
|
451
|
+
def windowY()
|
452
|
+
@window__.y
|
453
|
+
end
|
454
|
+
|
455
|
+
# Returns the width of the window.
|
364
456
|
#
|
365
457
|
# @return [Numeric] window width
|
366
458
|
#
|
@@ -368,7 +460,7 @@ module Processing
|
|
368
460
|
@window__.width
|
369
461
|
end
|
370
462
|
|
371
|
-
# Returns
|
463
|
+
# Returns the height of the window.
|
372
464
|
#
|
373
465
|
# @return [Numeric] window height
|
374
466
|
#
|
@@ -376,7 +468,7 @@ module Processing
|
|
376
468
|
@window__.height
|
377
469
|
end
|
378
470
|
|
379
|
-
# Returns number of frames since program started.
|
471
|
+
# Returns the number of frames since the program started.
|
380
472
|
#
|
381
473
|
# @return [Integer] total number of frames
|
382
474
|
#
|
@@ -384,7 +476,7 @@ module Processing
|
|
384
476
|
@frameCount__
|
385
477
|
end
|
386
478
|
|
387
|
-
# Returns number of frames per second.
|
479
|
+
# Returns the number of frames per second.
|
388
480
|
#
|
389
481
|
# @return [Float] frames per second
|
390
482
|
#
|
@@ -252,14 +252,46 @@ module Processing
|
|
252
252
|
@drawing__ = false
|
253
253
|
end
|
254
254
|
|
255
|
+
# Returns the width of the graphics object.
|
256
|
+
#
|
257
|
+
# @return [Numeric] width
|
258
|
+
#
|
255
259
|
def width()
|
256
260
|
@image__.width
|
257
261
|
end
|
258
262
|
|
263
|
+
# Returns the height of the graphics object.
|
264
|
+
#
|
265
|
+
# @return [Numeric] height
|
266
|
+
#
|
259
267
|
def height()
|
260
268
|
@image__.height
|
261
269
|
end
|
262
270
|
|
271
|
+
# Returns the width of the graphics object in pixels.
|
272
|
+
#
|
273
|
+
# @return [Numeric] width
|
274
|
+
#
|
275
|
+
def pixelWidth()
|
276
|
+
width * pixelDensity
|
277
|
+
end
|
278
|
+
|
279
|
+
# Returns the height of the graphics object in pixels.
|
280
|
+
#
|
281
|
+
# @return [Numeric] height
|
282
|
+
#
|
283
|
+
def pixelHeight()
|
284
|
+
height * pixelDensity
|
285
|
+
end
|
286
|
+
|
287
|
+
# Returns the pixel density of the graphics object.
|
288
|
+
#
|
289
|
+
# @return [Numeric] pixel density
|
290
|
+
#
|
291
|
+
def pixelDensity()
|
292
|
+
@painter__.pixel_density
|
293
|
+
end
|
294
|
+
|
263
295
|
# Sets color mode and max color values.
|
264
296
|
#
|
265
297
|
# @overload colorMode(mode)
|
data/lib/processing/window.rb
CHANGED
@@ -9,7 +9,7 @@ module Processing
|
|
9
9
|
attr_accessor :setup, :update, :draw, :resize,
|
10
10
|
:key_down, :key_up,
|
11
11
|
:pointer_down, :pointer_up, :pointer_move, :pointer_drag,
|
12
|
-
:motion,
|
12
|
+
:move, :resize, :motion,
|
13
13
|
:before_draw, :after_draw, :update_canvas
|
14
14
|
|
15
15
|
attr_accessor :auto_resize
|
@@ -82,6 +82,14 @@ module Processing
|
|
82
82
|
draw_canvas {call_block block, e} if block
|
83
83
|
end
|
84
84
|
|
85
|
+
def on_move(e)
|
86
|
+
draw_canvas {call_block @move, e} if @move
|
87
|
+
end
|
88
|
+
|
89
|
+
def on_resize(e)
|
90
|
+
draw_canvas {call_block @resize, e} if @resize
|
91
|
+
end
|
92
|
+
|
85
93
|
def on_motion(e)
|
86
94
|
draw_canvas {call_block @motion, e} if @motion
|
87
95
|
end
|
@@ -111,8 +119,19 @@ module Processing
|
|
111
119
|
end
|
112
120
|
|
113
121
|
def resize_canvas(width, height, pixel_density = nil, window_pixel_density: nil)
|
122
|
+
painting = canvas_painter.painting?
|
123
|
+
canvas_painter.__send__ :end_paint if painting
|
124
|
+
|
114
125
|
@pixel_density = pixel_density if pixel_density
|
115
|
-
|
126
|
+
|
127
|
+
resized =
|
128
|
+
begin
|
129
|
+
@canvas.resize width, height, @pixel_density || window_pixel_density
|
130
|
+
ensure
|
131
|
+
canvas_painter.__send__ :begin_paint if painting
|
132
|
+
end
|
133
|
+
|
134
|
+
if resized
|
116
135
|
@update_canvas.call canvas_image, canvas_painter if @update_canvas
|
117
136
|
size width, height
|
118
137
|
end
|
@@ -143,10 +162,11 @@ module Processing
|
|
143
162
|
end
|
144
163
|
|
145
164
|
def draw_canvas(&block)
|
146
|
-
|
165
|
+
drawing = self.drawing?
|
166
|
+
begin_draw unless drawing
|
147
167
|
block.call
|
148
168
|
ensure
|
149
|
-
end_draw
|
169
|
+
end_draw unless drawing
|
150
170
|
end
|
151
171
|
|
152
172
|
def begin_draw()
|
@@ -159,6 +179,10 @@ module Processing
|
|
159
179
|
canvas_painter.__send__ :end_paint
|
160
180
|
end
|
161
181
|
|
182
|
+
def drawing?()
|
183
|
+
canvas_painter.painting?
|
184
|
+
end
|
185
|
+
|
162
186
|
def draw_screen(painter)
|
163
187
|
window_painter.image canvas_image
|
164
188
|
end
|
data/processing.gemspec
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
# -*- mode: ruby -*-
|
2
2
|
|
3
3
|
|
4
|
-
|
5
|
-
.tap {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
|
6
|
-
|
7
|
-
require 'processing/extension'
|
4
|
+
require_relative 'lib/processing/extension'
|
8
5
|
|
9
6
|
|
10
7
|
Gem::Specification.new do |s|
|
@@ -28,10 +25,10 @@ Gem::Specification.new do |s|
|
|
28
25
|
s.platform = Gem::Platform::RUBY
|
29
26
|
s.required_ruby_version = '>= 3.0.0'
|
30
27
|
|
31
|
-
s.add_runtime_dependency 'xot', '~> 0.1.
|
32
|
-
s.add_runtime_dependency 'rucy', '~> 0.1.
|
33
|
-
s.add_runtime_dependency 'rays', '~> 0.1.
|
34
|
-
s.add_runtime_dependency 'reflexion', '~> 0.1.
|
28
|
+
s.add_runtime_dependency 'xot', '~> 0.1.38'
|
29
|
+
s.add_runtime_dependency 'rucy', '~> 0.1.38'
|
30
|
+
s.add_runtime_dependency 'rays', '~> 0.1.39'
|
31
|
+
s.add_runtime_dependency 'reflexion', '~> 0.1.41'
|
35
32
|
|
36
33
|
s.add_development_dependency 'rake'
|
37
34
|
s.add_development_dependency 'test-unit'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: processing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xot
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.
|
19
|
+
version: 0.1.38
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1.
|
26
|
+
version: 0.1.38
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rucy
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.
|
33
|
+
version: 0.1.38
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.
|
40
|
+
version: 0.1.38
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rays
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.
|
47
|
+
version: 0.1.39
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.1.
|
54
|
+
version: 0.1.39
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: reflexion
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.
|
61
|
+
version: 0.1.41
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.
|
68
|
+
version: 0.1.41
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|