processing 0.5.32 → 0.5.34
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 +49 -1
- data/VERSION +1 -1
- data/lib/processing/all.rb +3 -1
- data/lib/processing/context.rb +232 -16
- data/lib/processing/events.rb +22 -0
- data/lib/processing/font.rb +5 -0
- data/lib/processing/graphics.rb +11 -2
- data/lib/processing/graphics_context.rb +968 -74
- data/lib/processing/image.rb +92 -1
- data/lib/processing/shader.rb +29 -16
- data/lib/processing/shape.rb +268 -12
- data/lib/processing/vector.rb +126 -0
- data/lib/processing/window.rb +98 -58
- data/processing.gemspec +4 -4
- data/test/helper.rb +5 -2
- data/test/p5.rb +1 -1
- data/test/test_font.rb +1 -1
- data/test/test_graphics_context.rb +442 -8
- data/test/test_utility.rb +0 -19
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e54026be3e0523b71c57d18c46525a46dd0291fea20c916c9a77d06398735e15
|
4
|
+
data.tar.gz: 7c38db77660d2ddddaba759396e54ea6245b1bca132684292e25d306273e433e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d2f9f2a261da953754a3476140069d6493b17d1d476bdc7907e35662ce1f9e7633339995f2613871fa3a0f3053cc1397300d1827382270e0783dad80b5f8640
|
7
|
+
data.tar.gz: 97c6eeff19b69a6874db4f1672bd0d140081fda349ca64850f5c10b7ecf343517e3a87e60bb5b5c5a2b005d89103a8ca1308ce460d55736507c33cb206c9a50f
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,54 @@
|
|
1
1
|
# processing ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.5.34] - 2024-02-16
|
5
|
+
|
6
|
+
- Add '@see' links to documents
|
7
|
+
- Fix missing nil returning
|
8
|
+
|
9
|
+
|
10
|
+
## [v0.5.33] - 2024-02-07
|
11
|
+
|
12
|
+
- Add curveDetail() and bezierDetail()
|
13
|
+
- Add curvePoint(), curveTangent(), curveTightness(), bezierPoint(), and bezierTangent()
|
14
|
+
- Add textLeading()
|
15
|
+
- Add deltaTime
|
16
|
+
- Add hue(), saturation(), and brightness()
|
17
|
+
- Add noiseSeed() and noiseDetail()
|
18
|
+
- Add randomGaussian()
|
19
|
+
- Add randomSeed()
|
20
|
+
- Add rotateX(), rotateY(), and rotateZ()
|
21
|
+
- Add rotateX(), rotateY(), and rotateZ() to Shape class
|
22
|
+
- Add shearX() and shearY()
|
23
|
+
- Add applyMatrix()
|
24
|
+
- Add printMatrix()
|
25
|
+
- Add fullscreen() (fullScreen()) function
|
26
|
+
- Add smooth() and noSmooth()
|
27
|
+
- Add keyIsDown()
|
28
|
+
- Add keyIsPressed()
|
29
|
+
- Add mouseWheel()
|
30
|
+
- Add doubleClicked()
|
31
|
+
- Add renderMode()
|
32
|
+
|
33
|
+
- Setup view projection matrix by using perspective() instead of ortho()
|
34
|
+
- Display window in the center of the screen by default
|
35
|
+
- loadImage() uses Net::HTTP.get() instead of URI.open() to retrieve images via http(s)
|
36
|
+
- loadImage() writes a file in streaming mode
|
37
|
+
- loadImage() raises Net::HTTPClientException instead of OpenURI::HTTPError
|
38
|
+
- Reimplement the noise() for better compatibility
|
39
|
+
- push/popStyle() manage colorMode, angleMode, blendMode, and miter_limit states
|
40
|
+
- size() and createCanvas() resize the window by themselves
|
41
|
+
- texture_mode/wrap -> texcoord_mode/wrap
|
42
|
+
- updatePixels() can take block
|
43
|
+
|
44
|
+
- Fix that textFont() did not return current font
|
45
|
+
- Fix that updatePixels() did not update the texture
|
46
|
+
- Fix the performance of requestImage() by calling Thread.pass
|
47
|
+
- Fix an issue with unintended canvas resizing when the screen pixel density changes
|
48
|
+
- Fix some missing attribute copies on the canvas
|
49
|
+
- Fix Matrix::to_a order
|
50
|
+
|
51
|
+
|
4
52
|
## [v0.5.32] - 2024-01-08
|
5
53
|
|
6
54
|
- Add requestImage()
|
@@ -22,7 +70,7 @@
|
|
22
70
|
- Add createShape(), shape(), shapeMode()
|
23
71
|
- Add beginShape(), endShape(), and vertex(x, y)
|
24
72
|
- Test with p5.rb
|
25
|
-
- GraphicsContext#
|
73
|
+
- GraphicsContext#scale() can take z parameter
|
26
74
|
- Set default miter_limit to 10
|
27
75
|
- Trigger github actions on all pull_request
|
28
76
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.34
|
data/lib/processing/all.rb
CHANGED
@@ -2,7 +2,8 @@ require 'set'
|
|
2
2
|
require 'digest/sha1'
|
3
3
|
require 'pathname'
|
4
4
|
require 'tmpdir'
|
5
|
-
require '
|
5
|
+
require 'net/http'
|
6
|
+
require 'uri'
|
6
7
|
require 'xot/inspectable'
|
7
8
|
require 'reflex'
|
8
9
|
|
@@ -19,4 +20,5 @@ require 'processing/shader'
|
|
19
20
|
require 'processing/capture'
|
20
21
|
require 'processing/graphics_context'
|
21
22
|
require 'processing/graphics'
|
23
|
+
require 'processing/events'
|
22
24
|
require 'processing/context'
|
data/lib/processing/context.rb
CHANGED
@@ -41,9 +41,10 @@ module Processing
|
|
41
41
|
|
42
42
|
@window__ = window
|
43
43
|
init__(
|
44
|
-
@window__.
|
45
|
-
@window__.
|
44
|
+
@window__.canvas.image,
|
45
|
+
@window__.canvas.painter.paint {background 0.8})
|
46
46
|
|
47
|
+
@smooth__ = true
|
47
48
|
@loop__ = true
|
48
49
|
@redraw__ = false
|
49
50
|
@frameCount__ = 0
|
@@ -65,7 +66,7 @@ module Processing
|
|
65
66
|
|
66
67
|
# @private
|
67
68
|
def @window__.draw_screen(painter)
|
68
|
-
@context__.drawImage__ painter
|
69
|
+
@context__.drawImage__ painter, image__: canvas.render
|
69
70
|
end
|
70
71
|
|
71
72
|
drawFrame = -> {
|
@@ -89,8 +90,8 @@ module Processing
|
|
89
90
|
@key__ = event.chars
|
90
91
|
@keyCode__ = event.key
|
91
92
|
if pressed != nil
|
92
|
-
set
|
93
|
-
pressed ? set.add(
|
93
|
+
set = @keysPressed__
|
94
|
+
pressed ? set.add(@keyCode__) : set.delete(@keyCode__)
|
94
95
|
end
|
95
96
|
}
|
96
97
|
|
@@ -143,8 +144,8 @@ module Processing
|
|
143
144
|
updatePointersPressedAndReleased.call e, false
|
144
145
|
if e.any? {|p| p.id == @pointer__.id}
|
145
146
|
@mouseReleasedBlock__&.call
|
146
|
-
@mouseClickedBlock__&.call
|
147
|
-
|
147
|
+
@mouseClickedBlock__&.call if e.click_count > 0
|
148
|
+
@doubleClickedBlock__&.call if e.click_count == 2
|
148
149
|
end
|
149
150
|
@touchEndedBlock__&.call
|
150
151
|
@pointersReleased__.clear
|
@@ -157,6 +158,10 @@ module Processing
|
|
157
158
|
@touchMovedBlock__&.call
|
158
159
|
end
|
159
160
|
|
161
|
+
@window__.wheel = proc do |e|
|
162
|
+
@mouseWheelBlock__&.call WheelEvent.new(e)
|
163
|
+
end
|
164
|
+
|
160
165
|
@window__.move = proc do |e|
|
161
166
|
@windowMovedBlock__&.call
|
162
167
|
end
|
@@ -175,6 +180,9 @@ module Processing
|
|
175
180
|
#
|
176
181
|
# @return [nil] nil
|
177
182
|
#
|
183
|
+
# @see https://processing.org/reference/setup_.html
|
184
|
+
# @see https://p5js.org/reference/#/p5/setup
|
185
|
+
#
|
178
186
|
def setup(&block)
|
179
187
|
@window__.setup = block if block
|
180
188
|
nil
|
@@ -191,6 +199,8 @@ module Processing
|
|
191
199
|
@mouseMovedBlock__ ||
|
192
200
|
@mouseDraggedBlock__ ||
|
193
201
|
@mouseClickedBlock__ ||
|
202
|
+
@doubleClickedBlock__ ||
|
203
|
+
@mouseWheelBlock__ ||
|
194
204
|
@touchStartedBlock__ ||
|
195
205
|
@touchEndedBlock__ ||
|
196
206
|
@touchMovedBlock__ ||
|
@@ -203,6 +213,9 @@ module Processing
|
|
203
213
|
#
|
204
214
|
# @return [nil] nil
|
205
215
|
#
|
216
|
+
# @see https://processing.org/reference/draw_.html
|
217
|
+
# @see https://p5js.org/reference/#/p5/draw
|
218
|
+
#
|
206
219
|
def draw(&block)
|
207
220
|
@drawBlock__ = block if block
|
208
221
|
nil
|
@@ -212,15 +225,21 @@ module Processing
|
|
212
225
|
#
|
213
226
|
# @return [Boolean] is any key pressed or not
|
214
227
|
#
|
228
|
+
# @see https://processing.org/reference/keyPressed_.html
|
229
|
+
# @see https://p5js.org/reference/#/p5/keyPressed
|
230
|
+
#
|
215
231
|
def keyPressed(&block)
|
216
232
|
@keyPressedBlock__ = block if block
|
217
|
-
|
233
|
+
keyIsPressed
|
218
234
|
end
|
219
235
|
|
220
236
|
# Defines keyReleased block.
|
221
237
|
#
|
222
238
|
# @return [nil] nil
|
223
239
|
#
|
240
|
+
# @see https://processing.org/reference/keyReleased_.html
|
241
|
+
# @see https://p5js.org/reference/#/p5/keyReleased
|
242
|
+
#
|
224
243
|
def keyReleased(&block)
|
225
244
|
@keyReleasedBlock__ = block if block
|
226
245
|
nil
|
@@ -230,6 +249,9 @@ module Processing
|
|
230
249
|
#
|
231
250
|
# @return [nil] nil
|
232
251
|
#
|
252
|
+
# @see https://processing.org/reference/keyTyped_.html
|
253
|
+
# @see https://p5js.org/reference/#/p5/keyTyped
|
254
|
+
#
|
233
255
|
def keyTyped(&block)
|
234
256
|
@keyTypedBlock__ = block if block
|
235
257
|
nil
|
@@ -239,6 +261,10 @@ module Processing
|
|
239
261
|
#
|
240
262
|
# @return [Boolean] is any mouse button pressed or not
|
241
263
|
#
|
264
|
+
# @see https://processing.org/reference/mousePressed_.html
|
265
|
+
# @see https://processing.org/reference/mousePressed.html
|
266
|
+
# @see https://p5js.org/reference/#/p5/mousePressed
|
267
|
+
#
|
242
268
|
def mousePressed(&block)
|
243
269
|
@mousePressedBlock__ = block if block
|
244
270
|
not @pointersPressed__.empty?
|
@@ -248,6 +274,9 @@ module Processing
|
|
248
274
|
#
|
249
275
|
# @return [nil] nil
|
250
276
|
#
|
277
|
+
# @see https://processing.org/reference/mouseReleased_.html
|
278
|
+
# @see https://p5js.org/reference/#/p5/mouseReleased
|
279
|
+
#
|
251
280
|
def mouseReleased(&block)
|
252
281
|
@mouseReleasedBlock__ = block if block
|
253
282
|
nil
|
@@ -257,6 +286,9 @@ module Processing
|
|
257
286
|
#
|
258
287
|
# @return [nil] nil
|
259
288
|
#
|
289
|
+
# @see https://processing.org/reference/mouseMoved_.html
|
290
|
+
# @see https://p5js.org/reference/#/p5/mouseMoved
|
291
|
+
#
|
260
292
|
def mouseMoved(&block)
|
261
293
|
@mouseMovedBlock__ = block if block
|
262
294
|
nil
|
@@ -266,6 +298,9 @@ module Processing
|
|
266
298
|
#
|
267
299
|
# @return [nil] nil
|
268
300
|
#
|
301
|
+
# @see https://processing.org/reference/mouseDragged_.html
|
302
|
+
# @see https://p5js.org/reference/#/p5/mouseDragged
|
303
|
+
#
|
269
304
|
def mouseDragged(&block)
|
270
305
|
@mouseDraggedBlock__ = block if block
|
271
306
|
nil
|
@@ -275,15 +310,43 @@ module Processing
|
|
275
310
|
#
|
276
311
|
# @return [nil] nil
|
277
312
|
#
|
313
|
+
# @see https://processing.org/reference/mouseClicked_.html
|
314
|
+
# @see https://p5js.org/reference/#/p5/mouseClicked
|
315
|
+
#
|
278
316
|
def mouseClicked(&block)
|
279
317
|
@mouseClickedBlock__ = block if block
|
280
318
|
nil
|
281
319
|
end
|
282
320
|
|
321
|
+
# Defines doubleClicked block.
|
322
|
+
#
|
323
|
+
# @return [nil] nil
|
324
|
+
#
|
325
|
+
# @see https://p5js.org/reference/#/p5/doubleClicked
|
326
|
+
#
|
327
|
+
def doubleClicked(&block)
|
328
|
+
@doubleClickedBlock__ = block if block
|
329
|
+
nil
|
330
|
+
end
|
331
|
+
|
332
|
+
# Defines mouseWheel block.
|
333
|
+
#
|
334
|
+
# @return [nil] nil
|
335
|
+
#
|
336
|
+
# @see https://processing.org/reference/mouseWheel_.html
|
337
|
+
# @see https://p5js.org/reference/#/p5/mouseWheel
|
338
|
+
#
|
339
|
+
def mouseWheel(&block)
|
340
|
+
@mouseWheelBlock__ = block if block
|
341
|
+
nil
|
342
|
+
end
|
343
|
+
|
283
344
|
# Defines touchStarted block.
|
284
345
|
#
|
285
346
|
# @return [nil] nil
|
286
347
|
#
|
348
|
+
# @see https://p5js.org/reference/#/p5/touchStarted
|
349
|
+
#
|
287
350
|
def touchStarted(&block)
|
288
351
|
@touchStartedBlock__ = block if block
|
289
352
|
nil
|
@@ -293,6 +356,8 @@ module Processing
|
|
293
356
|
#
|
294
357
|
# @return [nil] nil
|
295
358
|
#
|
359
|
+
# @see https://p5js.org/reference/#/p5/touchEnded
|
360
|
+
#
|
296
361
|
def touchEnded(&block)
|
297
362
|
@touchEndedBlock__ = block if block
|
298
363
|
nil
|
@@ -302,6 +367,8 @@ module Processing
|
|
302
367
|
#
|
303
368
|
# @return [nil] nil
|
304
369
|
#
|
370
|
+
# @see https://p5js.org/reference/#/p5/touchMoved
|
371
|
+
#
|
305
372
|
def touchMoved(&block)
|
306
373
|
@touchMovedBlock__ = block if block
|
307
374
|
nil
|
@@ -311,6 +378,8 @@ module Processing
|
|
311
378
|
#
|
312
379
|
# @return [nil] nil
|
313
380
|
#
|
381
|
+
# @see https://processing.org/reference/windowMoved_.html
|
382
|
+
#
|
314
383
|
def windowMoved(&block)
|
315
384
|
@windowMovedBlock__ = block if block
|
316
385
|
nil
|
@@ -320,6 +389,9 @@ module Processing
|
|
320
389
|
#
|
321
390
|
# @return [nil] nil
|
322
391
|
#
|
392
|
+
# @see https://processing.org/reference/windowResized_.html
|
393
|
+
# @see https://p5js.org/reference/#/p5/windowResized
|
394
|
+
#
|
323
395
|
def windowResized(&block)
|
324
396
|
@windowResizedBlock__ = block if block
|
325
397
|
nil
|
@@ -342,8 +414,11 @@ module Processing
|
|
342
414
|
#
|
343
415
|
# @return [nil] nil
|
344
416
|
#
|
417
|
+
# @see https://processing.org/reference/size_.html
|
418
|
+
#
|
345
419
|
def size(width, height, pixelDensity: self.pixelDensity)
|
346
|
-
|
420
|
+
windowResize width, height
|
421
|
+
resizeCanvas__ width, height, pixelDensity
|
347
422
|
nil
|
348
423
|
end
|
349
424
|
|
@@ -355,8 +430,11 @@ module Processing
|
|
355
430
|
#
|
356
431
|
# @return [nil] nil
|
357
432
|
#
|
433
|
+
# @see https://p5js.org/reference/#/p5/createCanvas
|
434
|
+
#
|
358
435
|
def createCanvas(width, height, pixelDensity: self.pixelDensity)
|
359
|
-
|
436
|
+
windowResize width, height
|
437
|
+
resizeCanvas__ width, height, pixelDensity
|
360
438
|
nil
|
361
439
|
end
|
362
440
|
|
@@ -366,6 +444,8 @@ module Processing
|
|
366
444
|
#
|
367
445
|
# @return [nil] nil
|
368
446
|
#
|
447
|
+
# @see https://processing.org/reference/setTitle_.html
|
448
|
+
#
|
369
449
|
def setTitle(title)
|
370
450
|
@window__.title = title
|
371
451
|
nil
|
@@ -377,16 +457,59 @@ module Processing
|
|
377
457
|
#
|
378
458
|
# @return [Numeric] current pixel density
|
379
459
|
#
|
460
|
+
# @see https://processing.org/reference/pixelDensity_.html
|
461
|
+
# @see https://p5js.org/reference/#/p5/pixelDensity
|
462
|
+
#
|
380
463
|
def pixelDensity(density = nil)
|
381
|
-
resizeCanvas__
|
382
|
-
@
|
464
|
+
resizeCanvas__ width, height, density if density
|
465
|
+
@window__.canvas.pixel_density
|
383
466
|
end
|
384
467
|
|
385
|
-
#
|
386
|
-
|
387
|
-
|
468
|
+
# Toggles full-screen state or returns the current state.
|
469
|
+
#
|
470
|
+
# @param state [Boolean] Whether to display full-screen or not
|
471
|
+
#
|
472
|
+
# @return [Boolean] current state
|
473
|
+
#
|
474
|
+
# @see https://processing.org/reference/fullScreen_.html
|
475
|
+
# @see https://p5js.org/reference/#/p5/fullscreen
|
476
|
+
#
|
477
|
+
def fullscreen(state = nil)
|
478
|
+
@window__.fullscreen = state if state != nil
|
479
|
+
@window__.fullscreen?
|
480
|
+
end
|
481
|
+
|
482
|
+
alias fullScreen fullscreen
|
483
|
+
|
484
|
+
# Enables anti-aliasing.
|
485
|
+
# (Anti-aliasing is disabled on high DPI screen)
|
486
|
+
#
|
487
|
+
# @return [nil] nil
|
488
|
+
#
|
489
|
+
# @see https://processing.org/reference/smooth_.html
|
490
|
+
# @see https://p5js.org/reference/#/p5/smooth
|
491
|
+
#
|
492
|
+
def smooth()
|
493
|
+
@smooth__ = true
|
494
|
+
resizeCanvas__ width, height, pixelDensity
|
495
|
+
nil
|
496
|
+
end
|
497
|
+
|
498
|
+
# Disables anti-aliasing.
|
499
|
+
#
|
500
|
+
# @return [nil] nil
|
501
|
+
#
|
502
|
+
# @see https://processing.org/reference/noSmooth_.html
|
503
|
+
# @see https://p5js.org/reference/#/p5/noSmooth
|
504
|
+
#
|
505
|
+
def noSmooth()
|
506
|
+
@smooth__ = false
|
507
|
+
resizeCanvas__ width, height, pixelDensity
|
508
|
+
end
|
388
509
|
|
389
|
-
|
510
|
+
# @private
|
511
|
+
def resizeCanvas__(width, height, pixelDensity)
|
512
|
+
@window__.resize_canvas width, height, pixelDensity, antialiasing: @smooth__
|
390
513
|
@window__.auto_resize = false
|
391
514
|
end
|
392
515
|
|
@@ -394,6 +517,9 @@ module Processing
|
|
394
517
|
#
|
395
518
|
# @return [Numeric] width
|
396
519
|
#
|
520
|
+
# @see https://processing.org/reference/displayWidth.html
|
521
|
+
# @see https://p5js.org/reference/#/p5/displayWidth
|
522
|
+
#
|
397
523
|
def displayWidth()
|
398
524
|
@window__.screen.width
|
399
525
|
end
|
@@ -402,6 +528,9 @@ module Processing
|
|
402
528
|
#
|
403
529
|
# @return [Numeric] height
|
404
530
|
#
|
531
|
+
# @see https://processing.org/reference/displayHeight.html
|
532
|
+
# @see https://p5js.org/reference/#/p5/displayHeight
|
533
|
+
#
|
405
534
|
def displayHeight()
|
406
535
|
@window__.screen.height
|
407
536
|
end
|
@@ -410,6 +539,9 @@ module Processing
|
|
410
539
|
#
|
411
540
|
# @return [Numeric] pixel density
|
412
541
|
#
|
542
|
+
# @see https://processing.org/reference/displayDensity_.html
|
543
|
+
# @see https://p5js.org/reference/#/p5/displayDensity
|
544
|
+
#
|
413
545
|
def displayDensity()
|
414
546
|
@window__.painter.pixel_density
|
415
547
|
end
|
@@ -421,6 +553,8 @@ module Processing
|
|
421
553
|
#
|
422
554
|
# @return [nil] nil
|
423
555
|
#
|
556
|
+
# @see https://processing.org/reference/windowMove_.html
|
557
|
+
#
|
424
558
|
def windowMove(x, y)
|
425
559
|
@window__.pos = [x, y]
|
426
560
|
nil
|
@@ -433,6 +567,8 @@ module Processing
|
|
433
567
|
#
|
434
568
|
# @return [nil] nil
|
435
569
|
#
|
570
|
+
# @see https://processing.org/reference/windowResize_.html
|
571
|
+
#
|
436
572
|
def windowResize(width, height)
|
437
573
|
@window__.size = [width, height]
|
438
574
|
nil
|
@@ -444,6 +580,8 @@ module Processing
|
|
444
580
|
#
|
445
581
|
# @return [nil] nil
|
446
582
|
#
|
583
|
+
# @see https://processing.org/reference/windowResizable_.html
|
584
|
+
#
|
447
585
|
def windowResizable(resizable)
|
448
586
|
@window__.resizable = resizable
|
449
587
|
nil
|
@@ -455,6 +593,7 @@ module Processing
|
|
455
593
|
#
|
456
594
|
# @return [nil] nil
|
457
595
|
#
|
596
|
+
#
|
458
597
|
def windowOrientation(*orientations)
|
459
598
|
@window__.orientations = orientations.flatten.uniq
|
460
599
|
end
|
@@ -479,6 +618,8 @@ module Processing
|
|
479
618
|
#
|
480
619
|
# @return [Numeric] window width
|
481
620
|
#
|
621
|
+
# @see https://p5js.org/reference/#/p5/windowWidth
|
622
|
+
#
|
482
623
|
def windowWidth()
|
483
624
|
@window__.width
|
484
625
|
end
|
@@ -487,6 +628,8 @@ module Processing
|
|
487
628
|
#
|
488
629
|
# @return [Numeric] window height
|
489
630
|
#
|
631
|
+
# @see https://p5js.org/reference/#/p5/windowHeight
|
632
|
+
#
|
490
633
|
def windowHeight()
|
491
634
|
@window__.height
|
492
635
|
end
|
@@ -495,6 +638,9 @@ module Processing
|
|
495
638
|
#
|
496
639
|
# @return [Boolean] active or not
|
497
640
|
#
|
641
|
+
# @see https://processing.org/reference/focused.html
|
642
|
+
# @see https://p5js.org/reference/#/p5/focused
|
643
|
+
#
|
498
644
|
def focused()
|
499
645
|
@window__.active?
|
500
646
|
end
|
@@ -503,6 +649,9 @@ module Processing
|
|
503
649
|
#
|
504
650
|
# @return [Integer] total number of frames
|
505
651
|
#
|
652
|
+
# @see https://processing.org/reference/frameCount.html
|
653
|
+
# @see https://p5js.org/reference/#/p5/frameCount
|
654
|
+
#
|
506
655
|
def frameCount()
|
507
656
|
@frameCount__
|
508
657
|
end
|
@@ -511,14 +660,30 @@ module Processing
|
|
511
660
|
#
|
512
661
|
# @return [Float] frames per second
|
513
662
|
#
|
663
|
+
# @see https://processing.org/reference/frameRate.html
|
664
|
+
# @see https://p5js.org/reference/#/p5/frameRate
|
665
|
+
#
|
514
666
|
def frameRate()
|
515
667
|
@window__.event.fps
|
516
668
|
end
|
517
669
|
|
670
|
+
# Returns the elapsed time after previous drawing event
|
671
|
+
#
|
672
|
+
# @return [Float] elapsed time in milliseconds
|
673
|
+
#
|
674
|
+
# @see https://p5js.org/reference/#/p5/deltaTime
|
675
|
+
#
|
676
|
+
def deltaTime()
|
677
|
+
@window__.event.dt * 1000
|
678
|
+
end
|
679
|
+
|
518
680
|
# Returns the last key that was pressed or released.
|
519
681
|
#
|
520
682
|
# @return [String] last key
|
521
683
|
#
|
684
|
+
# @see https://processing.org/reference/key.html
|
685
|
+
# @see https://p5js.org/reference/#/p5/key
|
686
|
+
#
|
522
687
|
def key()
|
523
688
|
@key__
|
524
689
|
end
|
@@ -527,14 +692,42 @@ module Processing
|
|
527
692
|
#
|
528
693
|
# @return [Symbol] last key code
|
529
694
|
#
|
695
|
+
# @see https://processing.org/reference/keyCode.html
|
696
|
+
# @see https://p5js.org/reference/#/p5/keyCode
|
697
|
+
#
|
530
698
|
def keyCode()
|
531
699
|
@keyCode__
|
532
700
|
end
|
533
701
|
|
702
|
+
# Returns whether or not any key is pressed.
|
703
|
+
#
|
704
|
+
# @return [Boolean] is any key pressed or not
|
705
|
+
#
|
706
|
+
# @see https://p5js.org/reference/#/p5/keyIsPressed
|
707
|
+
#
|
708
|
+
def keyIsPressed()
|
709
|
+
not @keysPressed__.empty?
|
710
|
+
end
|
711
|
+
|
712
|
+
# Returns weather or not the key is currently pressed.
|
713
|
+
#
|
714
|
+
# @param keyCode [Numeric] code for the key
|
715
|
+
#
|
716
|
+
# @return [Boolean] is the key pressed or not
|
717
|
+
#
|
718
|
+
# @see https://p5js.org/reference/#/p5/keyIsDown
|
719
|
+
#
|
720
|
+
def keyIsDown(keyCode)
|
721
|
+
@keysPressed__.include? keyCode
|
722
|
+
end
|
723
|
+
|
534
724
|
# Returns mouse x position
|
535
725
|
#
|
536
726
|
# @return [Numeric] horizontal position of mouse
|
537
727
|
#
|
728
|
+
# @see https://processing.org/reference/mouseX.html
|
729
|
+
# @see https://p5js.org/reference/#/p5/mouseX
|
730
|
+
#
|
538
731
|
def mouseX()
|
539
732
|
@pointer__&.x || 0
|
540
733
|
end
|
@@ -543,6 +736,9 @@ module Processing
|
|
543
736
|
#
|
544
737
|
# @return [Numeric] vertical position of mouse
|
545
738
|
#
|
739
|
+
# @see https://processing.org/reference/mouseY.html
|
740
|
+
# @see https://p5js.org/reference/#/p5/mouseY
|
741
|
+
#
|
546
742
|
def mouseY()
|
547
743
|
@pointer__&.y || 0
|
548
744
|
end
|
@@ -551,6 +747,9 @@ module Processing
|
|
551
747
|
#
|
552
748
|
# @return [Numeric] horizontal position of mouse
|
553
749
|
#
|
750
|
+
# @see https://processing.org/reference/pmouseX.html
|
751
|
+
# @see https://p5js.org/reference/#/p5/pmouseX
|
752
|
+
#
|
554
753
|
def pmouseX()
|
555
754
|
@pointerPrev__&.x || 0
|
556
755
|
end
|
@@ -559,6 +758,9 @@ module Processing
|
|
559
758
|
#
|
560
759
|
# @return [Numeric] vertical position of mouse
|
561
760
|
#
|
761
|
+
# @see https://processing.org/reference/pmouseY.html
|
762
|
+
# @see https://p5js.org/reference/#/p5/pmouseY
|
763
|
+
#
|
562
764
|
def pmouseY()
|
563
765
|
@pointerPrev__&.y || 0
|
564
766
|
end
|
@@ -567,6 +769,9 @@ module Processing
|
|
567
769
|
#
|
568
770
|
# @return [Numeric] LEFT, RIGHT, CENTER or 0
|
569
771
|
#
|
772
|
+
# @see https://processing.org/reference/mouseButton.html
|
773
|
+
# @see https://p5js.org/reference/#/p5/mouseButton
|
774
|
+
#
|
570
775
|
def mouseButton()
|
571
776
|
((@pointersPressed__ + @pointersReleased__) & [LEFT, RIGHT, CENTER]).last
|
572
777
|
end
|
@@ -575,6 +780,8 @@ module Processing
|
|
575
780
|
#
|
576
781
|
# @return [Array] Touch objects
|
577
782
|
#
|
783
|
+
# @see https://p5js.org/reference/#/p5/touches
|
784
|
+
#
|
578
785
|
def touches()
|
579
786
|
@touches__
|
580
787
|
end
|
@@ -591,6 +798,9 @@ module Processing
|
|
591
798
|
#
|
592
799
|
# @return [nil] nil
|
593
800
|
#
|
801
|
+
# @see https://processing.org/reference/loop_.html
|
802
|
+
# @see https://p5js.org/reference/#/p5/loop
|
803
|
+
#
|
594
804
|
def loop()
|
595
805
|
@loop__ = true
|
596
806
|
end
|
@@ -599,6 +809,9 @@ module Processing
|
|
599
809
|
#
|
600
810
|
# @return [nil] nil
|
601
811
|
#
|
812
|
+
# @see https://processing.org/reference/noLoop_.html
|
813
|
+
# @see https://p5js.org/reference/#/p5/noLoop
|
814
|
+
#
|
602
815
|
def noLoop()
|
603
816
|
@loop__ = false
|
604
817
|
end
|
@@ -607,6 +820,9 @@ module Processing
|
|
607
820
|
#
|
608
821
|
# @return [nil] nil
|
609
822
|
#
|
823
|
+
# @see https://processing.org/reference/redraw_.html
|
824
|
+
# @see https://p5js.org/reference/#/p5/redraw
|
825
|
+
#
|
610
826
|
def redraw()
|
611
827
|
@redraw__ = true
|
612
828
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Processing
|
2
|
+
|
3
|
+
|
4
|
+
# Mouse wheel event object.
|
5
|
+
#
|
6
|
+
class WheelEvent
|
7
|
+
|
8
|
+
# @private
|
9
|
+
def initialize(event)
|
10
|
+
@event = event
|
11
|
+
end
|
12
|
+
|
13
|
+
def delta()
|
14
|
+
@event.dy
|
15
|
+
end
|
16
|
+
|
17
|
+
alias getCount delta
|
18
|
+
|
19
|
+
end# WheelEvent
|
20
|
+
|
21
|
+
|
22
|
+
end# Processing
|