processing 0.5.33 → 1.0.1
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 +25 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/Rakefile +5 -5
- data/VERSION +1 -1
- data/lib/processing/all.rb +4 -1
- data/lib/processing/context.rb +128 -0
- data/lib/processing/font.rb +5 -0
- data/lib/processing/graphics.rb +9 -0
- data/lib/processing/graphics_context.rb +640 -42
- data/lib/processing/image.rb +86 -0
- data/lib/processing/shader.rb +29 -16
- data/lib/processing/shape.rb +369 -28
- data/lib/processing/svg.rb +248 -0
- data/lib/processing/vector.rb +126 -0
- data/lib/processing/window.rb +2 -0
- data/processing.gemspec +4 -4
- data/test/{p5.rb → browser.rb} +37 -3
- data/test/helper.rb +40 -7
- data/test/test_color.rb +94 -0
- data/test/test_graphics_context.rb +26 -59
- data/test/test_shape.rb +129 -6
- data/test/test_svg.rb +257 -0
- metadata +17 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7ebe70f2fc384d5892bfc8bf33773451585c82aecc01e36f594803cbd3cbe4c
|
4
|
+
data.tar.gz: fccd650cf7fa9e38f499c7d279624c5a30aa5eb40bde70d9a3c6c5c4ce8805f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 875bdd9a5bdce3f8aa0b9490e7dd8fa526859999dbef0ac6fe7dcb4984f6c1f76435b550dfbf249ff817fb7e5b07dabea543e9d70c99887baebb0a7c0ecc5c23
|
7
|
+
data.tar.gz: 1f7348aaa12c5fc0893e9a6ca6c177daa2efc1c98934ebb5d50fb714638da2a7fd09c563c51c4fdd00ea2f9e634e460d3e5a6ad5ba3e68e9ca09f02c004d28b0
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,30 @@
|
|
1
1
|
# processing ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v1.0.1] - 2024-03-14
|
5
|
+
|
6
|
+
- Add 'rexml' to Gemfile
|
7
|
+
|
8
|
+
|
9
|
+
## [v1.0] - 2024-03-14
|
10
|
+
|
11
|
+
- Add stroke(), setStroke(), and setStrokeWeight() to Shape class
|
12
|
+
- Add setStrokeCap() and setStrokeJoin() to Shape class
|
13
|
+
- Add join type 'miter-clip' and 'arcs'
|
14
|
+
- Add color codes
|
15
|
+
- Add loadShape()
|
16
|
+
|
17
|
+
- Rename the join type 'SQUARE' to 'BEVEL'
|
18
|
+
|
19
|
+
- Fix that <circle> and <ellipse> had half diameters
|
20
|
+
|
21
|
+
|
22
|
+
## [v0.5.34] - 2024-02-16
|
23
|
+
|
24
|
+
- Add '@see' links to documents
|
25
|
+
- Fix missing nil returning
|
26
|
+
|
27
|
+
|
4
28
|
## [v0.5.33] - 2024-02-07
|
5
29
|
|
6
30
|
- Add curveDetail() and bezierDetail()
|
@@ -64,7 +88,7 @@
|
|
64
88
|
- Add createShape(), shape(), shapeMode()
|
65
89
|
- Add beginShape(), endShape(), and vertex(x, y)
|
66
90
|
- Test with p5.rb
|
67
|
-
- GraphicsContext#
|
91
|
+
- GraphicsContext#scale() can take z parameter
|
68
92
|
- Set default miter_limit to 10
|
69
93
|
- Trigger github actions on all pull_request
|
70
94
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -14,15 +14,15 @@ require 'reflex/extension'
|
|
14
14
|
require 'processing/extension'
|
15
15
|
|
16
16
|
|
17
|
-
def
|
18
|
-
ENV['
|
17
|
+
def test_with_browser()
|
18
|
+
ENV['TEST_WITH_BROWSER'] = '1'
|
19
19
|
end
|
20
20
|
|
21
21
|
EXTENSIONS = [Xot, Rucy, Rays, Reflex, Processing]
|
22
22
|
|
23
23
|
ENV['RDOC'] = 'yardoc --no-private'
|
24
24
|
|
25
|
-
#
|
25
|
+
#test_with_browser if ci?
|
26
26
|
|
27
27
|
default_tasks
|
28
28
|
use_bundler
|
@@ -37,8 +37,8 @@ namespace :test do
|
|
37
37
|
sh %( rm -rf test/.png/*.png )
|
38
38
|
end
|
39
39
|
|
40
|
-
task :
|
41
|
-
|
40
|
+
task :with_browser do
|
41
|
+
test_with_browser
|
42
42
|
end
|
43
43
|
|
44
44
|
::Rake::TestTask.new :draw do |t|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.1
|
data/lib/processing/all.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'set'
|
2
|
+
require 'strscan'
|
2
3
|
require 'digest/sha1'
|
3
4
|
require 'pathname'
|
4
5
|
require 'tmpdir'
|
5
|
-
require 'net/http'
|
6
6
|
require 'uri'
|
7
|
+
require 'rexml'
|
8
|
+
require 'net/http'
|
7
9
|
require 'xot/inspectable'
|
8
10
|
require 'reflex'
|
9
11
|
|
@@ -16,6 +18,7 @@ require 'processing/image'
|
|
16
18
|
require 'processing/font'
|
17
19
|
require 'processing/touch'
|
18
20
|
require 'processing/shape'
|
21
|
+
require 'processing/svg'
|
19
22
|
require 'processing/shader'
|
20
23
|
require 'processing/capture'
|
21
24
|
require 'processing/graphics_context'
|
data/lib/processing/context.rb
CHANGED
@@ -180,6 +180,9 @@ module Processing
|
|
180
180
|
#
|
181
181
|
# @return [nil] nil
|
182
182
|
#
|
183
|
+
# @see https://processing.org/reference/setup_.html
|
184
|
+
# @see https://p5js.org/reference/#/p5/setup
|
185
|
+
#
|
183
186
|
def setup(&block)
|
184
187
|
@window__.setup = block if block
|
185
188
|
nil
|
@@ -210,6 +213,9 @@ module Processing
|
|
210
213
|
#
|
211
214
|
# @return [nil] nil
|
212
215
|
#
|
216
|
+
# @see https://processing.org/reference/draw_.html
|
217
|
+
# @see https://p5js.org/reference/#/p5/draw
|
218
|
+
#
|
213
219
|
def draw(&block)
|
214
220
|
@drawBlock__ = block if block
|
215
221
|
nil
|
@@ -219,6 +225,9 @@ module Processing
|
|
219
225
|
#
|
220
226
|
# @return [Boolean] is any key pressed or not
|
221
227
|
#
|
228
|
+
# @see https://processing.org/reference/keyPressed_.html
|
229
|
+
# @see https://p5js.org/reference/#/p5/keyPressed
|
230
|
+
#
|
222
231
|
def keyPressed(&block)
|
223
232
|
@keyPressedBlock__ = block if block
|
224
233
|
keyIsPressed
|
@@ -228,6 +237,9 @@ module Processing
|
|
228
237
|
#
|
229
238
|
# @return [nil] nil
|
230
239
|
#
|
240
|
+
# @see https://processing.org/reference/keyReleased_.html
|
241
|
+
# @see https://p5js.org/reference/#/p5/keyReleased
|
242
|
+
#
|
231
243
|
def keyReleased(&block)
|
232
244
|
@keyReleasedBlock__ = block if block
|
233
245
|
nil
|
@@ -237,6 +249,9 @@ module Processing
|
|
237
249
|
#
|
238
250
|
# @return [nil] nil
|
239
251
|
#
|
252
|
+
# @see https://processing.org/reference/keyTyped_.html
|
253
|
+
# @see https://p5js.org/reference/#/p5/keyTyped
|
254
|
+
#
|
240
255
|
def keyTyped(&block)
|
241
256
|
@keyTypedBlock__ = block if block
|
242
257
|
nil
|
@@ -246,6 +261,10 @@ module Processing
|
|
246
261
|
#
|
247
262
|
# @return [Boolean] is any mouse button pressed or not
|
248
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
|
+
#
|
249
268
|
def mousePressed(&block)
|
250
269
|
@mousePressedBlock__ = block if block
|
251
270
|
not @pointersPressed__.empty?
|
@@ -255,6 +274,9 @@ module Processing
|
|
255
274
|
#
|
256
275
|
# @return [nil] nil
|
257
276
|
#
|
277
|
+
# @see https://processing.org/reference/mouseReleased_.html
|
278
|
+
# @see https://p5js.org/reference/#/p5/mouseReleased
|
279
|
+
#
|
258
280
|
def mouseReleased(&block)
|
259
281
|
@mouseReleasedBlock__ = block if block
|
260
282
|
nil
|
@@ -264,6 +286,9 @@ module Processing
|
|
264
286
|
#
|
265
287
|
# @return [nil] nil
|
266
288
|
#
|
289
|
+
# @see https://processing.org/reference/mouseMoved_.html
|
290
|
+
# @see https://p5js.org/reference/#/p5/mouseMoved
|
291
|
+
#
|
267
292
|
def mouseMoved(&block)
|
268
293
|
@mouseMovedBlock__ = block if block
|
269
294
|
nil
|
@@ -273,6 +298,9 @@ module Processing
|
|
273
298
|
#
|
274
299
|
# @return [nil] nil
|
275
300
|
#
|
301
|
+
# @see https://processing.org/reference/mouseDragged_.html
|
302
|
+
# @see https://p5js.org/reference/#/p5/mouseDragged
|
303
|
+
#
|
276
304
|
def mouseDragged(&block)
|
277
305
|
@mouseDraggedBlock__ = block if block
|
278
306
|
nil
|
@@ -282,6 +310,9 @@ module Processing
|
|
282
310
|
#
|
283
311
|
# @return [nil] nil
|
284
312
|
#
|
313
|
+
# @see https://processing.org/reference/mouseClicked_.html
|
314
|
+
# @see https://p5js.org/reference/#/p5/mouseClicked
|
315
|
+
#
|
285
316
|
def mouseClicked(&block)
|
286
317
|
@mouseClickedBlock__ = block if block
|
287
318
|
nil
|
@@ -291,6 +322,8 @@ module Processing
|
|
291
322
|
#
|
292
323
|
# @return [nil] nil
|
293
324
|
#
|
325
|
+
# @see https://p5js.org/reference/#/p5/doubleClicked
|
326
|
+
#
|
294
327
|
def doubleClicked(&block)
|
295
328
|
@doubleClickedBlock__ = block if block
|
296
329
|
nil
|
@@ -300,6 +333,9 @@ module Processing
|
|
300
333
|
#
|
301
334
|
# @return [nil] nil
|
302
335
|
#
|
336
|
+
# @see https://processing.org/reference/mouseWheel_.html
|
337
|
+
# @see https://p5js.org/reference/#/p5/mouseWheel
|
338
|
+
#
|
303
339
|
def mouseWheel(&block)
|
304
340
|
@mouseWheelBlock__ = block if block
|
305
341
|
nil
|
@@ -309,6 +345,8 @@ module Processing
|
|
309
345
|
#
|
310
346
|
# @return [nil] nil
|
311
347
|
#
|
348
|
+
# @see https://p5js.org/reference/#/p5/touchStarted
|
349
|
+
#
|
312
350
|
def touchStarted(&block)
|
313
351
|
@touchStartedBlock__ = block if block
|
314
352
|
nil
|
@@ -318,6 +356,8 @@ module Processing
|
|
318
356
|
#
|
319
357
|
# @return [nil] nil
|
320
358
|
#
|
359
|
+
# @see https://p5js.org/reference/#/p5/touchEnded
|
360
|
+
#
|
321
361
|
def touchEnded(&block)
|
322
362
|
@touchEndedBlock__ = block if block
|
323
363
|
nil
|
@@ -327,6 +367,8 @@ module Processing
|
|
327
367
|
#
|
328
368
|
# @return [nil] nil
|
329
369
|
#
|
370
|
+
# @see https://p5js.org/reference/#/p5/touchMoved
|
371
|
+
#
|
330
372
|
def touchMoved(&block)
|
331
373
|
@touchMovedBlock__ = block if block
|
332
374
|
nil
|
@@ -336,6 +378,8 @@ module Processing
|
|
336
378
|
#
|
337
379
|
# @return [nil] nil
|
338
380
|
#
|
381
|
+
# @see https://processing.org/reference/windowMoved_.html
|
382
|
+
#
|
339
383
|
def windowMoved(&block)
|
340
384
|
@windowMovedBlock__ = block if block
|
341
385
|
nil
|
@@ -345,6 +389,9 @@ module Processing
|
|
345
389
|
#
|
346
390
|
# @return [nil] nil
|
347
391
|
#
|
392
|
+
# @see https://processing.org/reference/windowResized_.html
|
393
|
+
# @see https://p5js.org/reference/#/p5/windowResized
|
394
|
+
#
|
348
395
|
def windowResized(&block)
|
349
396
|
@windowResizedBlock__ = block if block
|
350
397
|
nil
|
@@ -367,6 +414,8 @@ module Processing
|
|
367
414
|
#
|
368
415
|
# @return [nil] nil
|
369
416
|
#
|
417
|
+
# @see https://processing.org/reference/size_.html
|
418
|
+
#
|
370
419
|
def size(width, height, pixelDensity: self.pixelDensity)
|
371
420
|
windowResize width, height
|
372
421
|
resizeCanvas__ width, height, pixelDensity
|
@@ -381,6 +430,8 @@ module Processing
|
|
381
430
|
#
|
382
431
|
# @return [nil] nil
|
383
432
|
#
|
433
|
+
# @see https://p5js.org/reference/#/p5/createCanvas
|
434
|
+
#
|
384
435
|
def createCanvas(width, height, pixelDensity: self.pixelDensity)
|
385
436
|
windowResize width, height
|
386
437
|
resizeCanvas__ width, height, pixelDensity
|
@@ -393,6 +444,8 @@ module Processing
|
|
393
444
|
#
|
394
445
|
# @return [nil] nil
|
395
446
|
#
|
447
|
+
# @see https://processing.org/reference/setTitle_.html
|
448
|
+
#
|
396
449
|
def setTitle(title)
|
397
450
|
@window__.title = title
|
398
451
|
nil
|
@@ -404,6 +457,9 @@ module Processing
|
|
404
457
|
#
|
405
458
|
# @return [Numeric] current pixel density
|
406
459
|
#
|
460
|
+
# @see https://processing.org/reference/pixelDensity_.html
|
461
|
+
# @see https://p5js.org/reference/#/p5/pixelDensity
|
462
|
+
#
|
407
463
|
def pixelDensity(density = nil)
|
408
464
|
resizeCanvas__ width, height, density if density
|
409
465
|
@window__.canvas.pixel_density
|
@@ -430,6 +486,9 @@ module Processing
|
|
430
486
|
#
|
431
487
|
# @return [nil] nil
|
432
488
|
#
|
489
|
+
# @see https://processing.org/reference/smooth_.html
|
490
|
+
# @see https://p5js.org/reference/#/p5/smooth
|
491
|
+
#
|
433
492
|
def smooth()
|
434
493
|
@smooth__ = true
|
435
494
|
resizeCanvas__ width, height, pixelDensity
|
@@ -440,6 +499,9 @@ module Processing
|
|
440
499
|
#
|
441
500
|
# @return [nil] nil
|
442
501
|
#
|
502
|
+
# @see https://processing.org/reference/noSmooth_.html
|
503
|
+
# @see https://p5js.org/reference/#/p5/noSmooth
|
504
|
+
#
|
443
505
|
def noSmooth()
|
444
506
|
@smooth__ = false
|
445
507
|
resizeCanvas__ width, height, pixelDensity
|
@@ -455,6 +517,9 @@ module Processing
|
|
455
517
|
#
|
456
518
|
# @return [Numeric] width
|
457
519
|
#
|
520
|
+
# @see https://processing.org/reference/displayWidth.html
|
521
|
+
# @see https://p5js.org/reference/#/p5/displayWidth
|
522
|
+
#
|
458
523
|
def displayWidth()
|
459
524
|
@window__.screen.width
|
460
525
|
end
|
@@ -463,6 +528,9 @@ module Processing
|
|
463
528
|
#
|
464
529
|
# @return [Numeric] height
|
465
530
|
#
|
531
|
+
# @see https://processing.org/reference/displayHeight.html
|
532
|
+
# @see https://p5js.org/reference/#/p5/displayHeight
|
533
|
+
#
|
466
534
|
def displayHeight()
|
467
535
|
@window__.screen.height
|
468
536
|
end
|
@@ -471,6 +539,9 @@ module Processing
|
|
471
539
|
#
|
472
540
|
# @return [Numeric] pixel density
|
473
541
|
#
|
542
|
+
# @see https://processing.org/reference/displayDensity_.html
|
543
|
+
# @see https://p5js.org/reference/#/p5/displayDensity
|
544
|
+
#
|
474
545
|
def displayDensity()
|
475
546
|
@window__.painter.pixel_density
|
476
547
|
end
|
@@ -482,6 +553,8 @@ module Processing
|
|
482
553
|
#
|
483
554
|
# @return [nil] nil
|
484
555
|
#
|
556
|
+
# @see https://processing.org/reference/windowMove_.html
|
557
|
+
#
|
485
558
|
def windowMove(x, y)
|
486
559
|
@window__.pos = [x, y]
|
487
560
|
nil
|
@@ -494,6 +567,8 @@ module Processing
|
|
494
567
|
#
|
495
568
|
# @return [nil] nil
|
496
569
|
#
|
570
|
+
# @see https://processing.org/reference/windowResize_.html
|
571
|
+
#
|
497
572
|
def windowResize(width, height)
|
498
573
|
@window__.size = [width, height]
|
499
574
|
nil
|
@@ -505,6 +580,8 @@ module Processing
|
|
505
580
|
#
|
506
581
|
# @return [nil] nil
|
507
582
|
#
|
583
|
+
# @see https://processing.org/reference/windowResizable_.html
|
584
|
+
#
|
508
585
|
def windowResizable(resizable)
|
509
586
|
@window__.resizable = resizable
|
510
587
|
nil
|
@@ -540,6 +617,8 @@ module Processing
|
|
540
617
|
#
|
541
618
|
# @return [Numeric] window width
|
542
619
|
#
|
620
|
+
# @see https://p5js.org/reference/#/p5/windowWidth
|
621
|
+
#
|
543
622
|
def windowWidth()
|
544
623
|
@window__.width
|
545
624
|
end
|
@@ -548,6 +627,8 @@ module Processing
|
|
548
627
|
#
|
549
628
|
# @return [Numeric] window height
|
550
629
|
#
|
630
|
+
# @see https://p5js.org/reference/#/p5/windowHeight
|
631
|
+
#
|
551
632
|
def windowHeight()
|
552
633
|
@window__.height
|
553
634
|
end
|
@@ -556,6 +637,9 @@ module Processing
|
|
556
637
|
#
|
557
638
|
# @return [Boolean] active or not
|
558
639
|
#
|
640
|
+
# @see https://processing.org/reference/focused.html
|
641
|
+
# @see https://p5js.org/reference/#/p5/focused
|
642
|
+
#
|
559
643
|
def focused()
|
560
644
|
@window__.active?
|
561
645
|
end
|
@@ -564,6 +648,9 @@ module Processing
|
|
564
648
|
#
|
565
649
|
# @return [Integer] total number of frames
|
566
650
|
#
|
651
|
+
# @see https://processing.org/reference/frameCount.html
|
652
|
+
# @see https://p5js.org/reference/#/p5/frameCount
|
653
|
+
#
|
567
654
|
def frameCount()
|
568
655
|
@frameCount__
|
569
656
|
end
|
@@ -572,6 +659,9 @@ module Processing
|
|
572
659
|
#
|
573
660
|
# @return [Float] frames per second
|
574
661
|
#
|
662
|
+
# @see https://processing.org/reference/frameRate.html
|
663
|
+
# @see https://p5js.org/reference/#/p5/frameRate
|
664
|
+
#
|
575
665
|
def frameRate()
|
576
666
|
@window__.event.fps
|
577
667
|
end
|
@@ -580,6 +670,8 @@ module Processing
|
|
580
670
|
#
|
581
671
|
# @return [Float] elapsed time in milliseconds
|
582
672
|
#
|
673
|
+
# @see https://p5js.org/reference/#/p5/deltaTime
|
674
|
+
#
|
583
675
|
def deltaTime()
|
584
676
|
@window__.event.dt * 1000
|
585
677
|
end
|
@@ -588,6 +680,9 @@ module Processing
|
|
588
680
|
#
|
589
681
|
# @return [String] last key
|
590
682
|
#
|
683
|
+
# @see https://processing.org/reference/key.html
|
684
|
+
# @see https://p5js.org/reference/#/p5/key
|
685
|
+
#
|
591
686
|
def key()
|
592
687
|
@key__
|
593
688
|
end
|
@@ -596,6 +691,9 @@ module Processing
|
|
596
691
|
#
|
597
692
|
# @return [Symbol] last key code
|
598
693
|
#
|
694
|
+
# @see https://processing.org/reference/keyCode.html
|
695
|
+
# @see https://p5js.org/reference/#/p5/keyCode
|
696
|
+
#
|
599
697
|
def keyCode()
|
600
698
|
@keyCode__
|
601
699
|
end
|
@@ -604,6 +702,8 @@ module Processing
|
|
604
702
|
#
|
605
703
|
# @return [Boolean] is any key pressed or not
|
606
704
|
#
|
705
|
+
# @see https://p5js.org/reference/#/p5/keyIsPressed
|
706
|
+
#
|
607
707
|
def keyIsPressed()
|
608
708
|
not @keysPressed__.empty?
|
609
709
|
end
|
@@ -614,6 +714,8 @@ module Processing
|
|
614
714
|
#
|
615
715
|
# @return [Boolean] is the key pressed or not
|
616
716
|
#
|
717
|
+
# @see https://p5js.org/reference/#/p5/keyIsDown
|
718
|
+
#
|
617
719
|
def keyIsDown(keyCode)
|
618
720
|
@keysPressed__.include? keyCode
|
619
721
|
end
|
@@ -622,6 +724,9 @@ module Processing
|
|
622
724
|
#
|
623
725
|
# @return [Numeric] horizontal position of mouse
|
624
726
|
#
|
727
|
+
# @see https://processing.org/reference/mouseX.html
|
728
|
+
# @see https://p5js.org/reference/#/p5/mouseX
|
729
|
+
#
|
625
730
|
def mouseX()
|
626
731
|
@pointer__&.x || 0
|
627
732
|
end
|
@@ -630,6 +735,9 @@ module Processing
|
|
630
735
|
#
|
631
736
|
# @return [Numeric] vertical position of mouse
|
632
737
|
#
|
738
|
+
# @see https://processing.org/reference/mouseY.html
|
739
|
+
# @see https://p5js.org/reference/#/p5/mouseY
|
740
|
+
#
|
633
741
|
def mouseY()
|
634
742
|
@pointer__&.y || 0
|
635
743
|
end
|
@@ -638,6 +746,9 @@ module Processing
|
|
638
746
|
#
|
639
747
|
# @return [Numeric] horizontal position of mouse
|
640
748
|
#
|
749
|
+
# @see https://processing.org/reference/pmouseX.html
|
750
|
+
# @see https://p5js.org/reference/#/p5/pmouseX
|
751
|
+
#
|
641
752
|
def pmouseX()
|
642
753
|
@pointerPrev__&.x || 0
|
643
754
|
end
|
@@ -646,6 +757,9 @@ module Processing
|
|
646
757
|
#
|
647
758
|
# @return [Numeric] vertical position of mouse
|
648
759
|
#
|
760
|
+
# @see https://processing.org/reference/pmouseY.html
|
761
|
+
# @see https://p5js.org/reference/#/p5/pmouseY
|
762
|
+
#
|
649
763
|
def pmouseY()
|
650
764
|
@pointerPrev__&.y || 0
|
651
765
|
end
|
@@ -654,6 +768,9 @@ module Processing
|
|
654
768
|
#
|
655
769
|
# @return [Numeric] LEFT, RIGHT, CENTER or 0
|
656
770
|
#
|
771
|
+
# @see https://processing.org/reference/mouseButton.html
|
772
|
+
# @see https://p5js.org/reference/#/p5/mouseButton
|
773
|
+
#
|
657
774
|
def mouseButton()
|
658
775
|
((@pointersPressed__ + @pointersReleased__) & [LEFT, RIGHT, CENTER]).last
|
659
776
|
end
|
@@ -662,6 +779,8 @@ module Processing
|
|
662
779
|
#
|
663
780
|
# @return [Array] Touch objects
|
664
781
|
#
|
782
|
+
# @see https://p5js.org/reference/#/p5/touches
|
783
|
+
#
|
665
784
|
def touches()
|
666
785
|
@touches__
|
667
786
|
end
|
@@ -678,6 +797,9 @@ module Processing
|
|
678
797
|
#
|
679
798
|
# @return [nil] nil
|
680
799
|
#
|
800
|
+
# @see https://processing.org/reference/loop_.html
|
801
|
+
# @see https://p5js.org/reference/#/p5/loop
|
802
|
+
#
|
681
803
|
def loop()
|
682
804
|
@loop__ = true
|
683
805
|
end
|
@@ -686,6 +808,9 @@ module Processing
|
|
686
808
|
#
|
687
809
|
# @return [nil] nil
|
688
810
|
#
|
811
|
+
# @see https://processing.org/reference/noLoop_.html
|
812
|
+
# @see https://p5js.org/reference/#/p5/noLoop
|
813
|
+
#
|
689
814
|
def noLoop()
|
690
815
|
@loop__ = false
|
691
816
|
end
|
@@ -694,6 +819,9 @@ module Processing
|
|
694
819
|
#
|
695
820
|
# @return [nil] nil
|
696
821
|
#
|
822
|
+
# @see https://processing.org/reference/redraw_.html
|
823
|
+
# @see https://p5js.org/reference/#/p5/redraw
|
824
|
+
#
|
697
825
|
def redraw()
|
698
826
|
@redraw__ = true
|
699
827
|
end
|
data/lib/processing/font.rb
CHANGED
@@ -3,6 +3,9 @@ module Processing
|
|
3
3
|
|
4
4
|
# Font object.
|
5
5
|
#
|
6
|
+
# @see https://processing.org/reference/PFont.html
|
7
|
+
# @see https://p5js.org/reference/#/p5.Font
|
8
|
+
#
|
6
9
|
class Font
|
7
10
|
|
8
11
|
# @private
|
@@ -24,6 +27,8 @@ module Processing
|
|
24
27
|
#
|
25
28
|
# @return [TextBounds] bounding box for text
|
26
29
|
#
|
30
|
+
# @see https://p5js.org/reference/#/p5.Font/textBounds
|
31
|
+
#
|
27
32
|
def textBounds(str, x = 0, y = 0, fontSize = nil)
|
28
33
|
font = getInternal__ fontSize
|
29
34
|
TextBounds.new x, y, x + font.width(str), y + font.height
|
data/lib/processing/graphics.rb
CHANGED
@@ -3,6 +3,9 @@ module Processing
|
|
3
3
|
|
4
4
|
# Draws graphics into an offscreen buffer
|
5
5
|
#
|
6
|
+
# @see https://processing.org/reference/PGraphics.html
|
7
|
+
# @see https://p5js.org/reference/#/p5.Graphics
|
8
|
+
#
|
6
9
|
class Graphics
|
7
10
|
|
8
11
|
include Xot::Inspectable
|
@@ -10,6 +13,8 @@ module Processing
|
|
10
13
|
|
11
14
|
# Initialize graphics object.
|
12
15
|
#
|
16
|
+
# @see https://p5js.org/reference/#/p5.Graphics
|
17
|
+
#
|
13
18
|
def initialize(width, height, pixelDensity = 1)
|
14
19
|
image = Rays::Image.new width, height, Rays::RGBA, pixelDensity
|
15
20
|
init__ image, image.painter
|
@@ -17,6 +22,8 @@ module Processing
|
|
17
22
|
|
18
23
|
# Start drawing.
|
19
24
|
#
|
25
|
+
# @see https://processing.org/reference/PGraphics_beginDraw_.html
|
26
|
+
#
|
20
27
|
def beginDraw(&block)
|
21
28
|
@painter__.__send__ :begin_paint
|
22
29
|
beginDraw__
|
@@ -32,6 +39,8 @@ module Processing
|
|
32
39
|
|
33
40
|
# End drawing.
|
34
41
|
#
|
42
|
+
# @see https://processing.org/reference/PGraphics_endDraw_.html
|
43
|
+
#
|
35
44
|
def endDraw()
|
36
45
|
pop
|
37
46
|
endDraw__
|