processing 0.5.33 → 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 +7 -1
- data/VERSION +1 -1
- data/lib/processing/context.rb +129 -0
- data/lib/processing/font.rb +5 -0
- data/lib/processing/graphics.rb +9 -0
- data/lib/processing/graphics_context.rb +431 -1
- data/lib/processing/image.rb +91 -0
- data/lib/processing/shader.rb +29 -16
- data/lib/processing/shape.rb +258 -10
- data/lib/processing/vector.rb +126 -0
- data/lib/processing/window.rb +2 -0
- metadata +2 -2
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,12 @@
|
|
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
|
+
|
4
10
|
## [v0.5.33] - 2024-02-07
|
5
11
|
|
6
12
|
- Add curveDetail() and bezierDetail()
|
@@ -64,7 +70,7 @@
|
|
64
70
|
- Add createShape(), shape(), shapeMode()
|
65
71
|
- Add beginShape(), endShape(), and vertex(x, y)
|
66
72
|
- Test with p5.rb
|
67
|
-
- GraphicsContext#
|
73
|
+
- GraphicsContext#scale() can take z parameter
|
68
74
|
- Set default miter_limit to 10
|
69
75
|
- Trigger github actions on all pull_request
|
70
76
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.34
|
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
|
@@ -516,6 +593,7 @@ module Processing
|
|
516
593
|
#
|
517
594
|
# @return [nil] nil
|
518
595
|
#
|
596
|
+
#
|
519
597
|
def windowOrientation(*orientations)
|
520
598
|
@window__.orientations = orientations.flatten.uniq
|
521
599
|
end
|
@@ -540,6 +618,8 @@ module Processing
|
|
540
618
|
#
|
541
619
|
# @return [Numeric] window width
|
542
620
|
#
|
621
|
+
# @see https://p5js.org/reference/#/p5/windowWidth
|
622
|
+
#
|
543
623
|
def windowWidth()
|
544
624
|
@window__.width
|
545
625
|
end
|
@@ -548,6 +628,8 @@ module Processing
|
|
548
628
|
#
|
549
629
|
# @return [Numeric] window height
|
550
630
|
#
|
631
|
+
# @see https://p5js.org/reference/#/p5/windowHeight
|
632
|
+
#
|
551
633
|
def windowHeight()
|
552
634
|
@window__.height
|
553
635
|
end
|
@@ -556,6 +638,9 @@ module Processing
|
|
556
638
|
#
|
557
639
|
# @return [Boolean] active or not
|
558
640
|
#
|
641
|
+
# @see https://processing.org/reference/focused.html
|
642
|
+
# @see https://p5js.org/reference/#/p5/focused
|
643
|
+
#
|
559
644
|
def focused()
|
560
645
|
@window__.active?
|
561
646
|
end
|
@@ -564,6 +649,9 @@ module Processing
|
|
564
649
|
#
|
565
650
|
# @return [Integer] total number of frames
|
566
651
|
#
|
652
|
+
# @see https://processing.org/reference/frameCount.html
|
653
|
+
# @see https://p5js.org/reference/#/p5/frameCount
|
654
|
+
#
|
567
655
|
def frameCount()
|
568
656
|
@frameCount__
|
569
657
|
end
|
@@ -572,6 +660,9 @@ module Processing
|
|
572
660
|
#
|
573
661
|
# @return [Float] frames per second
|
574
662
|
#
|
663
|
+
# @see https://processing.org/reference/frameRate.html
|
664
|
+
# @see https://p5js.org/reference/#/p5/frameRate
|
665
|
+
#
|
575
666
|
def frameRate()
|
576
667
|
@window__.event.fps
|
577
668
|
end
|
@@ -580,6 +671,8 @@ module Processing
|
|
580
671
|
#
|
581
672
|
# @return [Float] elapsed time in milliseconds
|
582
673
|
#
|
674
|
+
# @see https://p5js.org/reference/#/p5/deltaTime
|
675
|
+
#
|
583
676
|
def deltaTime()
|
584
677
|
@window__.event.dt * 1000
|
585
678
|
end
|
@@ -588,6 +681,9 @@ module Processing
|
|
588
681
|
#
|
589
682
|
# @return [String] last key
|
590
683
|
#
|
684
|
+
# @see https://processing.org/reference/key.html
|
685
|
+
# @see https://p5js.org/reference/#/p5/key
|
686
|
+
#
|
591
687
|
def key()
|
592
688
|
@key__
|
593
689
|
end
|
@@ -596,6 +692,9 @@ module Processing
|
|
596
692
|
#
|
597
693
|
# @return [Symbol] last key code
|
598
694
|
#
|
695
|
+
# @see https://processing.org/reference/keyCode.html
|
696
|
+
# @see https://p5js.org/reference/#/p5/keyCode
|
697
|
+
#
|
599
698
|
def keyCode()
|
600
699
|
@keyCode__
|
601
700
|
end
|
@@ -604,6 +703,8 @@ module Processing
|
|
604
703
|
#
|
605
704
|
# @return [Boolean] is any key pressed or not
|
606
705
|
#
|
706
|
+
# @see https://p5js.org/reference/#/p5/keyIsPressed
|
707
|
+
#
|
607
708
|
def keyIsPressed()
|
608
709
|
not @keysPressed__.empty?
|
609
710
|
end
|
@@ -614,6 +715,8 @@ module Processing
|
|
614
715
|
#
|
615
716
|
# @return [Boolean] is the key pressed or not
|
616
717
|
#
|
718
|
+
# @see https://p5js.org/reference/#/p5/keyIsDown
|
719
|
+
#
|
617
720
|
def keyIsDown(keyCode)
|
618
721
|
@keysPressed__.include? keyCode
|
619
722
|
end
|
@@ -622,6 +725,9 @@ module Processing
|
|
622
725
|
#
|
623
726
|
# @return [Numeric] horizontal position of mouse
|
624
727
|
#
|
728
|
+
# @see https://processing.org/reference/mouseX.html
|
729
|
+
# @see https://p5js.org/reference/#/p5/mouseX
|
730
|
+
#
|
625
731
|
def mouseX()
|
626
732
|
@pointer__&.x || 0
|
627
733
|
end
|
@@ -630,6 +736,9 @@ module Processing
|
|
630
736
|
#
|
631
737
|
# @return [Numeric] vertical position of mouse
|
632
738
|
#
|
739
|
+
# @see https://processing.org/reference/mouseY.html
|
740
|
+
# @see https://p5js.org/reference/#/p5/mouseY
|
741
|
+
#
|
633
742
|
def mouseY()
|
634
743
|
@pointer__&.y || 0
|
635
744
|
end
|
@@ -638,6 +747,9 @@ module Processing
|
|
638
747
|
#
|
639
748
|
# @return [Numeric] horizontal position of mouse
|
640
749
|
#
|
750
|
+
# @see https://processing.org/reference/pmouseX.html
|
751
|
+
# @see https://p5js.org/reference/#/p5/pmouseX
|
752
|
+
#
|
641
753
|
def pmouseX()
|
642
754
|
@pointerPrev__&.x || 0
|
643
755
|
end
|
@@ -646,6 +758,9 @@ module Processing
|
|
646
758
|
#
|
647
759
|
# @return [Numeric] vertical position of mouse
|
648
760
|
#
|
761
|
+
# @see https://processing.org/reference/pmouseY.html
|
762
|
+
# @see https://p5js.org/reference/#/p5/pmouseY
|
763
|
+
#
|
649
764
|
def pmouseY()
|
650
765
|
@pointerPrev__&.y || 0
|
651
766
|
end
|
@@ -654,6 +769,9 @@ module Processing
|
|
654
769
|
#
|
655
770
|
# @return [Numeric] LEFT, RIGHT, CENTER or 0
|
656
771
|
#
|
772
|
+
# @see https://processing.org/reference/mouseButton.html
|
773
|
+
# @see https://p5js.org/reference/#/p5/mouseButton
|
774
|
+
#
|
657
775
|
def mouseButton()
|
658
776
|
((@pointersPressed__ + @pointersReleased__) & [LEFT, RIGHT, CENTER]).last
|
659
777
|
end
|
@@ -662,6 +780,8 @@ module Processing
|
|
662
780
|
#
|
663
781
|
# @return [Array] Touch objects
|
664
782
|
#
|
783
|
+
# @see https://p5js.org/reference/#/p5/touches
|
784
|
+
#
|
665
785
|
def touches()
|
666
786
|
@touches__
|
667
787
|
end
|
@@ -678,6 +798,9 @@ module Processing
|
|
678
798
|
#
|
679
799
|
# @return [nil] nil
|
680
800
|
#
|
801
|
+
# @see https://processing.org/reference/loop_.html
|
802
|
+
# @see https://p5js.org/reference/#/p5/loop
|
803
|
+
#
|
681
804
|
def loop()
|
682
805
|
@loop__ = true
|
683
806
|
end
|
@@ -686,6 +809,9 @@ module Processing
|
|
686
809
|
#
|
687
810
|
# @return [nil] nil
|
688
811
|
#
|
812
|
+
# @see https://processing.org/reference/noLoop_.html
|
813
|
+
# @see https://p5js.org/reference/#/p5/noLoop
|
814
|
+
#
|
689
815
|
def noLoop()
|
690
816
|
@loop__ = false
|
691
817
|
end
|
@@ -694,6 +820,9 @@ module Processing
|
|
694
820
|
#
|
695
821
|
# @return [nil] nil
|
696
822
|
#
|
823
|
+
# @see https://processing.org/reference/redraw_.html
|
824
|
+
# @see https://p5js.org/reference/#/p5/redraw
|
825
|
+
#
|
697
826
|
def redraw()
|
698
827
|
@redraw__ = true
|
699
828
|
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__
|