processing 0.5.33 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -70,6 +70,14 @@ module Processing
70
70
  #
71
71
  RADIUS = :radius
72
72
 
73
+ # Mode for strokeCap() and strokeJoin().
74
+ #
75
+ ROUND = :round
76
+
77
+ # Mode for strokeCap().
78
+ #
79
+ SQUARE = :butt
80
+
73
81
  # Mode for strokeCap().
74
82
  #
75
83
  PROJECT = :square
@@ -80,11 +88,7 @@ module Processing
80
88
 
81
89
  # Mode for strokeCap() and strokeJoin().
82
90
  #
83
- ROUND = :round
84
-
85
- # Mode for strokeCap() and strokeJoin().
86
- #
87
- SQUARE = :butt
91
+ BEVEL = :square
88
92
 
89
93
  # Mode for blendMode().
90
94
  #
@@ -123,96 +127,127 @@ module Processing
123
127
  REPLACE = :replace
124
128
 
125
129
  # Key code or Mode for textAlign().
130
+ #
126
131
  LEFT = :left
127
132
 
128
133
  # Key code or Mode for textAlign().
134
+ #
129
135
  RIGHT = :right
130
136
 
131
137
  # Mode for textAlign().
138
+ #
132
139
  TOP = :top
133
140
 
134
141
  # Mode for textAlign().
142
+ #
135
143
  BOTTOM = :bottom
136
144
 
137
145
  # Mode for textAlign().
146
+ #
138
147
  BASELINE = :baseline
139
148
 
140
149
  # Mode for textureMode().
150
+ #
141
151
  IMAGE = :image
142
152
 
143
153
  # Mode for textureMode().
154
+ #
144
155
  NORMAL = :normal
145
156
 
146
157
  # Mode for textureWrap().
158
+ #
147
159
  CLAMP = :clamp
148
160
 
149
161
  # Mode for textureWrap().
162
+ #
150
163
  REPEAT = :repeat
151
164
 
152
165
  # Filter type for filter()
166
+ #
153
167
  THRESHOLD = :threshold
154
168
 
155
169
  # Filter type for filter()
170
+ #
156
171
  GRAY = :gray
157
172
 
158
173
  # Filter type for filter()
174
+ #
159
175
  INVERT = :invert
160
176
 
161
177
  # Filter type for filter()
178
+ #
162
179
  BLUR = :blur
163
180
 
164
181
  # Shape mode for createShape()
182
+ #
165
183
  LINE = :line
166
184
 
167
185
  # Shape mode for createShape()
186
+ #
168
187
  RECT = :rect
169
188
 
170
189
  # Shape mode for createShape()
190
+ #
171
191
  ELLIPSE = :ellipse
172
192
 
173
193
  # Shape mode for createShape()
194
+ #
174
195
  ARC = :arc
175
196
 
176
197
  # Shape mode for createShape()
198
+ #
177
199
  TRIANGLE = :triangle
178
200
 
179
201
  # Shape mode for createShape()
202
+ #
180
203
  QUAD = :quad
181
204
 
182
205
  # Shape mode for createShape()
206
+ #
183
207
  GROUP = :group
184
208
 
185
209
  # Shape mode for beginShape()
210
+ #
186
211
  POINTS = :points
187
212
 
188
213
  # Shape mode for beginShape()
214
+ #
189
215
  LINES = :lines
190
216
 
191
217
  # Shape mode for beginShape()
218
+ #
192
219
  TRIANGLES = :triangles
193
220
 
194
221
  # Shape mode for beginShape()
222
+ #
195
223
  TRIANGLE_FAN = :triangle_fan
196
224
 
197
225
  # Shape mode for beginShape()
226
+ #
198
227
  TRIANGLE_STRIP = :triangle_strip
199
228
 
200
229
  # Shape mode for beginShape()
230
+ #
201
231
  QUADS = :quads
202
232
 
203
233
  # Shape mode for beginShape()
234
+ #
204
235
  QUAD_STRIP = :quad_strip
205
236
 
206
237
  # Shape mode for beginShape()
238
+ #
207
239
  TESS = :tess
208
240
 
209
241
  # OPEN flag for endShape()
242
+ #
210
243
  OPEN = :open
211
244
 
212
245
  # CLOSE flag for endShape()
246
+ #
213
247
  CLOSE = :close
214
248
 
215
249
  # Key codes.
250
+ #
216
251
  ENTER = :enter
217
252
  SPACE = :space
218
253
  TAB = :tab
@@ -261,6 +296,158 @@ module Processing
261
296
  UP = :up
262
297
  DOWN = :down
263
298
 
299
+ COLOR_CODES = {
300
+ aliceblue: '#f0f8ff',
301
+ antiquewhite: '#faebd7',
302
+ aqua: '#00ffff',
303
+ aquamarine: '#7fffd4',
304
+ azure: '#f0ffff',
305
+ beige: '#f5f5dc',
306
+ bisque: '#ffe4c4',
307
+ black: '#000000',
308
+ blanchedalmond: '#ffebcd',
309
+ blue: '#0000ff',
310
+ blueviolet: '#8a2be2',
311
+ brown: '#a52a2a',
312
+ burlywood: '#deb887',
313
+ cadetblue: '#5f9ea0',
314
+ chartreuse: '#7fff00',
315
+ chocolate: '#d2691e',
316
+ coral: '#ff7f50',
317
+ cornflowerblue: '#6495ed',
318
+ cornsilk: '#fff8dc',
319
+ crimson: '#dc143c',
320
+ cyan: '#00ffff',
321
+ darkblue: '#00008b',
322
+ darkcyan: '#008b8b',
323
+ darkgoldenrod: '#b8860b',
324
+ darkgray: '#a9a9a9',
325
+ darkgreen: '#006400',
326
+ darkgrey: '#a9a9a9',
327
+ darkkhaki: '#bdb76b',
328
+ darkmagenta: '#8b008b',
329
+ darkolivegreen: '#556b2f',
330
+ darkorange: '#ff8c00',
331
+ darkorchid: '#9932cc',
332
+ darkred: '#8b0000',
333
+ darksalmon: '#e9967a',
334
+ darkseagreen: '#8fbc8f',
335
+ darkslateblue: '#483d8b',
336
+ darkslategray: '#2f4f4f',
337
+ darkslategrey: '#2f4f4f',
338
+ darkturquoise: '#00ced1',
339
+ darkviolet: '#9400d3',
340
+ deeppink: '#ff1493',
341
+ deepskyblue: '#00bfff',
342
+ dimgray: '#696969',
343
+ dimgrey: '#696969',
344
+ dodgerblue: '#1e90ff',
345
+ firebrick: '#b22222',
346
+ floralwhite: '#fffaf0',
347
+ forestgreen: '#228b22',
348
+ fuchsia: '#ff00ff',
349
+ gainsboro: '#dcdcdc',
350
+ ghostwhite: '#f8f8ff',
351
+ goldenrod: '#daa520',
352
+ gold: '#ffd700',
353
+ gray: '#808080',
354
+ green: '#008000',
355
+ greenyellow: '#adff2f',
356
+ grey: '#808080',
357
+ honeydew: '#f0fff0',
358
+ hotpink: '#ff69b4',
359
+ indianred: '#cd5c5c',
360
+ indigo: '#4b0082',
361
+ ivory: '#fffff0',
362
+ khaki: '#f0e68c',
363
+ lavenderblush: '#fff0f5',
364
+ lavender: '#e6e6fa',
365
+ lawngreen: '#7cfc00',
366
+ lemonchiffon: '#fffacd',
367
+ lightblue: '#add8e6',
368
+ lightcoral: '#f08080',
369
+ lightcyan: '#e0ffff',
370
+ lightgoldenrodyellow: '#fafad2',
371
+ lightgray: '#d3d3d3',
372
+ lightgreen: '#90ee90',
373
+ lightgrey: '#d3d3d3',
374
+ lightpink: '#ffb6c1',
375
+ lightsalmon: '#ffa07a',
376
+ lightseagreen: '#20b2aa',
377
+ lightskyblue: '#87cefa',
378
+ lightslategray: '#778899',
379
+ lightslategrey: '#778899',
380
+ lightsteelblue: '#b0c4de',
381
+ lightyellow: '#ffffe0',
382
+ lime: '#00ff00',
383
+ limegreen: '#32cd32',
384
+ linen: '#faf0e6',
385
+ magenta: '#ff00ff',
386
+ maroon: '#800000',
387
+ mediumaquamarine: '#66cdaa',
388
+ mediumblue: '#0000cd',
389
+ mediumorchid: '#ba55d3',
390
+ mediumpurple: '#9370db',
391
+ mediumseagreen: '#3cb371',
392
+ mediumslateblue: '#7b68ee',
393
+ mediumspringgreen: '#00fa9a',
394
+ mediumturquoise: '#48d1cc',
395
+ mediumvioletred: '#c71585',
396
+ midnightblue: '#191970',
397
+ mintcream: '#f5fffa',
398
+ mistyrose: '#ffe4e1',
399
+ moccasin: '#ffe4b5',
400
+ navajowhite: '#ffdead',
401
+ navy: '#000080',
402
+ oldlace: '#fdf5e6',
403
+ olive: '#808000',
404
+ olivedrab: '#6b8e23',
405
+ orange: '#ffa500',
406
+ orangered: '#ff4500',
407
+ orchid: '#da70d6',
408
+ palegoldenrod: '#eee8aa',
409
+ palegreen: '#98fb98',
410
+ paleturquoise: '#afeeee',
411
+ palevioletred: '#db7093',
412
+ papayawhip: '#ffefd5',
413
+ peachpuff: '#ffdab9',
414
+ peru: '#cd853f',
415
+ pink: '#ffc0cb',
416
+ plum: '#dda0dd',
417
+ powderblue: '#b0e0e6',
418
+ purple: '#800080',
419
+ rebeccapurple: '#663399',
420
+ red: '#ff0000',
421
+ rosybrown: '#bc8f8f',
422
+ royalblue: '#4169e1',
423
+ saddlebrown: '#8b4513',
424
+ salmon: '#fa8072',
425
+ sandybrown: '#f4a460',
426
+ seagreen: '#2e8b57',
427
+ seashell: '#fff5ee',
428
+ sienna: '#a0522d',
429
+ silver: '#c0c0c0',
430
+ skyblue: '#87ceeb',
431
+ slateblue: '#6a5acd',
432
+ slategray: '#708090',
433
+ slategrey: '#708090',
434
+ snow: '#fffafa',
435
+ springgreen: '#00ff7f',
436
+ steelblue: '#4682b4',
437
+ tan: '#d2b48c',
438
+ teal: '#008080',
439
+ thistle: '#d8bfd8',
440
+ tomato: '#ff6347',
441
+ turquoise: '#40e0d0',
442
+ violet: '#ee82ee',
443
+ wheat: '#f5deb3',
444
+ white: '#ffffff',
445
+ whitesmoke: '#f5f5f5',
446
+ yellow: '#ffff00',
447
+ yellowgreen: '#9acd32',
448
+ none: '#00000000',
449
+ }
450
+
264
451
  # @private
265
452
  DEG2RAD__ = Math::PI / 180.0
266
453
 
@@ -382,6 +569,9 @@ module Processing
382
569
  #
383
570
  # @return [Numeric] width
384
571
  #
572
+ # @see https://processing.org/reference/width.html
573
+ # @see https://p5js.org/reference/#/p5/width
574
+ #
385
575
  def width()
386
576
  getInternal__.width
387
577
  end
@@ -390,6 +580,9 @@ module Processing
390
580
  #
391
581
  # @return [Numeric] height
392
582
  #
583
+ # @see https://processing.org/reference/height.html
584
+ # @see https://p5js.org/reference/#/p5/height
585
+ #
393
586
  def height()
394
587
  getInternal__.height
395
588
  end
@@ -398,6 +591,8 @@ module Processing
398
591
  #
399
592
  # @return [Numeric] width
400
593
  #
594
+ # @see https://processing.org/reference/pixelWidth.html
595
+ #
401
596
  def pixelWidth()
402
597
  width * pixelDensity
403
598
  end
@@ -406,6 +601,8 @@ module Processing
406
601
  #
407
602
  # @return [Numeric] height
408
603
  #
604
+ # @see https://processing.org/reference/pixelHeight.html
605
+ #
409
606
  def pixelHeight()
410
607
  height * pixelDensity
411
608
  end
@@ -414,6 +611,9 @@ module Processing
414
611
  #
415
612
  # @return [Numeric] pixel density
416
613
  #
614
+ # @see https://processing.org/reference/pixelDensity_.html
615
+ # @see https://p5js.org/reference/#/p5/pixelDensity
616
+ #
417
617
  def pixelDensity()
418
618
  @painter__.pixel_density
419
619
  end
@@ -448,6 +648,9 @@ module Processing
448
648
  #
449
649
  # @return [RGB, HSB] current mode
450
650
  #
651
+ # @see https://processing.org/reference/colorMode_.html
652
+ # @see https://p5js.org/reference/#/p5/colorMode
653
+ #
451
654
  def colorMode(mode = nil, *maxes)
452
655
  if mode != nil
453
656
  mode = mode.downcase.to_sym
@@ -479,18 +682,33 @@ module Processing
479
682
  #
480
683
  # @return [Integer] the rgba color value
481
684
  #
685
+ # @see https://processing.org/reference/color_.html
686
+ # @see https://p5js.org/reference/#/p5/color
687
+ #
482
688
  def color(*args)
483
689
  toRGBA__(*args)
484
690
  .map {|n| (n * 255).to_i.clamp 0, 255}
485
691
  .then {|r, g, b, a| Image.toColor__ r, g, b, a}
486
692
  end
487
693
 
694
+ # @private
695
+ private def color2raw__(color)
696
+ Rays::Color.new(
697
+ ((color >> 16) & 0xff) / 255.0,
698
+ ((color >> 8) & 0xff) / 255.0,
699
+ ( color & 0xff) / 255.0,
700
+ ((color >> 24) & 0xff) / 255.0)
701
+ end
702
+
488
703
  # Returns the red value of the color.
489
704
  #
490
705
  # @param color [Numeric] color value
491
706
  #
492
707
  # @return [Numeric] the red value
493
708
  #
709
+ # @see https://processing.org/reference/red_.html
710
+ # @see https://p5js.org/reference/#/p5/red
711
+ #
494
712
  def red(color)
495
713
  ((color >> 16) & 0xff) / 255.0 * @colorMaxes__[0]
496
714
  end
@@ -501,6 +719,9 @@ module Processing
501
719
  #
502
720
  # @return [Numeric] the green value
503
721
  #
722
+ # @see https://processing.org/reference/green_.html
723
+ # @see https://p5js.org/reference/#/p5/green
724
+ #
504
725
  def green(color)
505
726
  ((color >> 8) & 0xff) / 255.0 * @colorMaxes__[1]
506
727
  end
@@ -511,6 +732,9 @@ module Processing
511
732
  #
512
733
  # @return [Numeric] the blue value
513
734
  #
735
+ # @see https://processing.org/reference/blue_.html
736
+ # @see https://p5js.org/reference/#/p5/blue
737
+ #
514
738
  def blue(color)
515
739
  (color & 0xff) / 255.0 * @colorMaxes__[2]
516
740
  end
@@ -521,6 +745,9 @@ module Processing
521
745
  #
522
746
  # @return [Numeric] the red value
523
747
  #
748
+ # @see https://processing.org/reference/alpha_.html
749
+ # @see https://p5js.org/reference/#/p5/alpha
750
+ #
524
751
  def alpha(color)
525
752
  ((color >> 24) & 0xff) / 255.0 * @colorMaxes__[3]
526
753
  end
@@ -531,8 +758,11 @@ module Processing
531
758
  #
532
759
  # @return [Numeric] the hue value
533
760
  #
761
+ # @see https://processing.org/reference/hue_.html
762
+ # @see https://p5js.org/reference/#/p5/hue
763
+ #
534
764
  def hue(color)
535
- h, = toRawColor__(color).to_hsv
765
+ h, = color2raw__(color).to_hsv
536
766
  h * (@hsbColor__ ? @colorMaxes__[0] : 1)
537
767
  end
538
768
 
@@ -542,8 +772,11 @@ module Processing
542
772
  #
543
773
  # @return [Numeric] the saturation value
544
774
  #
775
+ # @see https://processing.org/reference/saturation_.html
776
+ # @see https://p5js.org/reference/#/p5/saturation
777
+ #
545
778
  def saturation(color)
546
- _, s, = toRawColor__(color).to_hsv
779
+ _, s, = color2raw__(color).to_hsv
547
780
  s * (@hsbColor__ ? @colorMaxes__[1] : 1)
548
781
  end
549
782
 
@@ -553,37 +786,46 @@ module Processing
553
786
  #
554
787
  # @return [Numeric] the brightness value
555
788
  #
789
+ # @see https://processing.org/reference/brightness_.html
790
+ # @see https://p5js.org/reference/#/p5/brightness
791
+ #
556
792
  def brightness(color)
557
- _, _, b = toRawColor__(color).to_hsv
793
+ _, _, b = color2raw__(color).to_hsv
558
794
  b * (@hsbColor__ ? @colorMaxes__[2] : 1)
559
795
  end
560
796
 
561
797
  # @private
562
798
  private def toRGBA__(*args)
563
- a, b = args
564
- return parseColor__(a, b || alphaMax__) if a.kind_of?(String)
565
- rawColor__(*args).to_a
799
+ toRawColor__(*args).to_a
566
800
  end
567
801
 
568
802
  # @private
569
- def rawColor__(*args)
803
+ def toRawColor__(*args)
570
804
  a, b, c, d = args
571
- rgba = case args.size
805
+ return parseColor__(a, b || alphaMax__) if a.is_a?(String) || a.is_a?(Symbol)
806
+ rgba =
807
+ case args.size
572
808
  when 1, 2 then [a, a, a, b || alphaMax__]
573
809
  when 3, 4 then [a, b, c, d || alphaMax__]
574
810
  else raise ArgumentError
575
811
  end
576
- rgba = rgba.map.with_index {|value, i| value / @colorMaxes__[i]}
812
+ rgba = rgba.map.with_index {|n, i| n / @colorMaxes__[i]}
577
813
  @hsbColor__ ? Rays::Color.hsv(*rgba) : Rays::Color.new(*rgba)
578
814
  end
579
815
 
580
816
  # @private
581
817
  private def parseColor__(str, alpha)
582
- result = str.match(/^\s*##{'([0-9a-f]{2})' * 3}\s*$/i)
583
- raise ArgumentError, "invalid color code: '#{str}'" unless result
584
-
585
- rgb = result[1..3].map.with_index {|hex, i| hex.to_i(16) / 255.0}
586
- return *rgb, (alpha / alphaMax__)
818
+ str = COLOR_CODES[str.downcase.to_sym] || str if str !~ /^\s*#\d+/
819
+ r, g, b, a =
820
+ case str
821
+ when /^\s*##{'([0-9a-f]{2})' * 3}([0-9a-f]{2})?\s*$/i
822
+ $~[1..4].map {|n| n.to_i(16) / 255.0 if n}
823
+ when /^\s*##{'([0-9a-f]{1})' * 3}([0-9a-f]{1})?\s*$/i
824
+ $~[1..4].map {|n| n.to_i(16) / 15.0 if n}
825
+ else
826
+ raise ArgumentError, "invalid color code: '#{str}'"
827
+ end
828
+ Rays::Color.new(r, g, b, a || (alpha / alphaMax__))
587
829
  end
588
830
 
589
831
  # @private
@@ -591,21 +833,14 @@ module Processing
591
833
  @colorMaxes__[3]
592
834
  end
593
835
 
594
- # @private
595
- private def toRawColor__(color)
596
- Rays::Color.new(
597
- ((color >> 16) & 0xff) / 255.0,
598
- ((color >> 8) & 0xff) / 255.0,
599
- ( color & 0xff) / 255.0,
600
- ((color >> 24) & 0xff) / 255.0)
601
- end
602
-
603
836
  # Sets angle mode.
604
837
  #
605
838
  # @param mode [RADIANS, DEGREES] RADIANS or DEGREES
606
839
  #
607
840
  # @return [RADIANS, DEGREES] current mode
608
841
  #
842
+ # @see https://p5js.org/reference/#/p5/angleMode
843
+ #
609
844
  def angleMode(mode = nil)
610
845
  if mode != nil
611
846
  @angleMode__ = mode
@@ -650,6 +885,9 @@ module Processing
650
885
  #
651
886
  # @return [nil] nil
652
887
  #
888
+ # @see https://processing.org/reference/rectMode_.html
889
+ # @see https://p5js.org/reference/#/p5/rectMode
890
+ #
653
891
  def rectMode(mode)
654
892
  @rectMode__ = mode
655
893
  end
@@ -665,6 +903,9 @@ module Processing
665
903
  #
666
904
  # @return [nil] nil
667
905
  #
906
+ # @see https://processing.org/reference/ellipseMode_.html
907
+ # @see https://p5js.org/reference/#/p5/ellipseMode
908
+ #
668
909
  def ellipseMode(mode)
669
910
  @ellipseMode__ = mode
670
911
  end
@@ -679,6 +920,9 @@ module Processing
679
920
  #
680
921
  # @return [nil] nil
681
922
  #
923
+ # @see https://processing.org/reference/imageMode_.html
924
+ # @see https://p5js.org/reference/#/p5/imageMode
925
+ #
682
926
  def imageMode(mode)
683
927
  @imageMode__ = mode
684
928
  end
@@ -693,6 +937,8 @@ module Processing
693
937
  #
694
938
  # @return [nil] nil
695
939
  #
940
+ # @see https://processing.org/reference/shapeMode_.html
941
+ #
696
942
  def shapeMode(mode)
697
943
  @shapeMode__ = mode
698
944
  end
@@ -714,6 +960,9 @@ module Processing
714
960
  #
715
961
  # @return [nil] nil
716
962
  #
963
+ # @see https://processing.org/reference/blendMode_.html
964
+ # @see https://p5js.org/reference/#/p5/blendMode
965
+ #
717
966
  def blendMode(mode = nil)
718
967
  if mode != nil
719
968
  @blendMode__ = mode
@@ -740,20 +989,21 @@ module Processing
740
989
  #
741
990
  # @return [nil] nil
742
991
  #
992
+ # @see https://processing.org/reference/fill_.html
993
+ # @see https://p5js.org/reference/#/p5/fill
994
+ #
743
995
  def fill(*args)
744
996
  @painter__.fill(*toRGBA__(*args))
745
997
  nil
746
998
  end
747
999
 
748
- # @private
749
- def getFill__()
750
- @painter__.fill
751
- end
752
-
753
1000
  # Disables filling.
754
1001
  #
755
1002
  # @return [nil] nil
756
1003
  #
1004
+ # @see https://processing.org/reference/noFill_.html
1005
+ # @see https://p5js.org/reference/#/p5/noFill
1006
+ #
757
1007
  def noFill()
758
1008
  @painter__.fill nil
759
1009
  nil
@@ -777,6 +1027,9 @@ module Processing
777
1027
  #
778
1028
  # @return [nil] nil
779
1029
  #
1030
+ # @see https://processing.org/reference/stroke_.html
1031
+ # @see https://p5js.org/reference/#/p5/stroke
1032
+ #
780
1033
  def stroke(*args)
781
1034
  @painter__.stroke(*toRGBA__(*args))
782
1035
  nil
@@ -786,6 +1039,9 @@ module Processing
786
1039
  #
787
1040
  # @return [nil] nil
788
1041
  #
1042
+ # @see https://processing.org/reference/noStroke_.html
1043
+ # @see https://p5js.org/reference/#/p5/noStroke
1044
+ #
789
1045
  def noStroke()
790
1046
  @painter__.stroke nil
791
1047
  nil
@@ -797,28 +1053,39 @@ module Processing
797
1053
  #
798
1054
  # @return [nil] nil
799
1055
  #
1056
+ # @see https://processing.org/reference/strokeWeight_.html
1057
+ # @see https://p5js.org/reference/#/p5/strokeWeight
1058
+ #
800
1059
  def strokeWeight(weight)
801
1060
  @painter__.stroke_width weight
802
1061
  nil
803
1062
  end
804
1063
 
805
1064
  # Sets stroke cap mode.
1065
+ # The default cap if ROUND.
806
1066
  #
807
- # @param cap [BUTT, ROUND, SQUARE]
1067
+ # @param cap [ROUND, SQUARE, PROJECT]
808
1068
  #
809
1069
  # @return [nil] nil
810
1070
  #
1071
+ # @see https://processing.org/reference/strokeCap_.html
1072
+ # @see https://p5js.org/reference/#/p5/strokeCap
1073
+ #
811
1074
  def strokeCap(cap)
812
1075
  @painter__.stroke_cap cap
813
1076
  nil
814
1077
  end
815
1078
 
816
1079
  # Sets stroke join mode.
1080
+ # The default join is MITER.
817
1081
  #
818
- # @param join [MITER, ROUND, SQUARE]
1082
+ # @param join [MITER, BEVEL, ROUND]
819
1083
  #
820
1084
  # @return [nil] nil
821
1085
  #
1086
+ # @see https://processing.org/reference/strokeJoin_.html
1087
+ # @see https://p5js.org/reference/#/p5/strokeJoin
1088
+ #
822
1089
  def strokeJoin(join)
823
1090
  @painter__.stroke_join join
824
1091
  nil
@@ -888,6 +1155,9 @@ module Processing
888
1155
  #
889
1156
  # @return [nil] nil
890
1157
  #
1158
+ # @see https://processing.org/reference/tint_.html
1159
+ # @see https://p5js.org/reference/#/p5/tint
1160
+ #
891
1161
  def tint(*args)
892
1162
  @tint__ = args
893
1163
  nil
@@ -897,6 +1167,9 @@ module Processing
897
1167
  #
898
1168
  # @return [nil] nil
899
1169
  #
1170
+ # @see https://processing.org/reference/noTint_.html
1171
+ # @see https://p5js.org/reference/#/p5/noTint
1172
+ #
900
1173
  def noTint()
901
1174
  @tint__ = nil
902
1175
  end
@@ -917,6 +1190,9 @@ module Processing
917
1190
  #
918
1191
  # @return [nil] nil
919
1192
  #
1193
+ # @see https://processing.org/reference/clip_.html
1194
+ # @see https://p5js.org/reference/#/p5/clip
1195
+ #
920
1196
  def clip(a, b, c, d)
921
1197
  x, y, w, h = toXYWH__ @imageMode__, a, b, c, d
922
1198
  @painter__.clip x, y, w, h
@@ -927,6 +1203,8 @@ module Processing
927
1203
  #
928
1204
  # @return [nil] nil
929
1205
  #
1206
+ # @see https://processing.org/reference/noClip_.html
1207
+ #
930
1208
  def noClip()
931
1209
  @painter__.no_clip
932
1210
  nil
@@ -947,6 +1225,9 @@ module Processing
947
1225
  #
948
1226
  # @return [Font] current font
949
1227
  #
1228
+ # @see https://processing.org/reference/textFont_.html
1229
+ # @see https://p5js.org/reference/#/p5/textFont
1230
+ #
950
1231
  def textFont(font = nil, size = nil)
951
1232
  if font != nil || size != nil
952
1233
  size = FONT_SIZE_MAX__ if size && size > FONT_SIZE_MAX__
@@ -967,25 +1248,63 @@ module Processing
967
1248
  #
968
1249
  # @return [nil] nil
969
1250
  #
1251
+ # @see https://processing.org/reference/textSize_.html
1252
+ # @see https://p5js.org/reference/#/p5/textSize
1253
+ #
970
1254
  def textSize(size)
971
1255
  textFont @textFont__, size
1256
+ nil
972
1257
  end
973
1258
 
1259
+ # Returns the width of the text.
1260
+ #
1261
+ # @param str [String] text string
1262
+ #
1263
+ # @return [Numeric] width of the text
1264
+ #
1265
+ # @see https://processing.org/reference/textWidth_.html
1266
+ # @see https://p5js.org/reference/#/p5/textWidth
1267
+ #
974
1268
  def textWidth(str)
975
1269
  @painter__.font.width str
976
1270
  end
977
1271
 
1272
+ # Returns ascent of the current font at its current size.
1273
+ #
1274
+ # @return [Numeric] ascent
1275
+ #
1276
+ # @see https://processing.org/reference/textAscent_.html
1277
+ # @see https://p5js.org/reference/#/p5/textAscent
1278
+ #
978
1279
  def textAscent()
979
1280
  @painter__.font.ascent
980
1281
  end
981
1282
 
1283
+ # Returns descent of the current font at its current size.
1284
+ #
1285
+ # @return [Numeric] descent
1286
+ #
1287
+ # @see https://processing.org/reference/textDescent_.html
1288
+ # @see https://p5js.org/reference/#/p5/textDescent
1289
+ #
982
1290
  def textDescent()
983
1291
  @painter__.font.descent
984
1292
  end
985
1293
 
1294
+ # Sets the alignment for drawing text.
1295
+ #
1296
+ # @param horizontal [LEFT, CENTER, RIGHT] horizontal alignment
1297
+ # @param vertical [TOP, BOTTOM, CENTER, BASELINE] vertical alignment
1298
+ #
1299
+ # @return [nil] nil
1300
+ #
1301
+ # @see https://processing.org/reference/textAlign_.html
1302
+ # @see https://p5js.org/reference/#/p5/textAlign
1303
+ #
986
1304
  def textAlign(horizontal, vertical = BASELINE)
987
1305
  @textAlignH__ = horizontal
988
1306
  @textAlignV__ = vertical
1307
+ nil
989
1308
  end
990
1309
 
991
1310
  # Sets the spacing between lines of text in units of pixels.
@@ -997,11 +1316,23 @@ module Processing
997
1316
  #
998
1317
  # @return [Numeric] current spacing
999
1318
  #
1319
+ # @see https://processing.org/reference/textLeading_.html
1320
+ # @see https://p5js.org/reference/#/p5/textLeading
1321
+ #
1000
1322
  def textLeading(leading = nil)
1001
1323
  @painter__.line_height = leading if leading
1002
1324
  @painter__.line_height
1003
1325
  end
1004
1326
 
1327
+ # Sets texture.
1328
+ #
1329
+ # @param image [Image] texture image
1330
+ #
1331
+ # @return [nil] nil
1332
+ #
1333
+ # @see https://processing.org/reference/texture_.html
1334
+ # @see https://p5js.org/reference/#/p5/texture
1335
+ #
1005
1336
  def texture(image)
1006
1337
  @painter__.texture image&.getInternal__
1007
1338
  nil
@@ -1050,6 +1381,9 @@ module Processing
1050
1381
  #
1051
1382
  # @return [nil] nil
1052
1383
  #
1384
+ # @see https://processing.org/reference/shader_.html
1385
+ # @see https://p5js.org/reference/#/p5/shader
1386
+ #
1053
1387
  def shader(shader)
1054
1388
  @painter__.shader shader&.getInternal__
1055
1389
  nil
@@ -1059,6 +1393,9 @@ module Processing
1059
1393
  #
1060
1394
  # @return [nil] nil
1061
1395
  #
1396
+ # @see https://processing.org/reference/resetShader_.html
1397
+ # @see https://p5js.org/reference/#/p5/resetShader
1398
+ #
1062
1399
  def resetShader()
1063
1400
  @painter__.no_shader
1064
1401
  nil
@@ -1074,8 +1411,14 @@ module Processing
1074
1411
  # @param type [THRESHOLD, GRAY, INVERT, BLUR] filter type
1075
1412
  # @param param [Numeric] a parameter for each filter
1076
1413
  #
1414
+ # @return [nil] nil
1415
+ #
1416
+ # @see https://processing.org/reference/filter_.html
1417
+ # @see https://p5js.org/reference/#/p5/filter
1418
+ #
1077
1419
  def filter(*args)
1078
1420
  @filter__ = Shader.createFilter__(*args)
1421
+ nil
1079
1422
  end
1080
1423
 
1081
1424
  # Clears screen.
@@ -1096,6 +1439,9 @@ module Processing
1096
1439
  #
1097
1440
  # @return [nil] nil
1098
1441
  #
1442
+ # @see https://processing.org/reference/background_.html
1443
+ # @see https://p5js.org/reference/#/p5/background
1444
+ #
1099
1445
  def background(*args)
1100
1446
  assertDrawing__
1101
1447
  rgba = toRGBA__(*args)
@@ -1122,6 +1468,9 @@ module Processing
1122
1468
  #
1123
1469
  # @return [nil] nil
1124
1470
  #
1471
+ # @see https://processing.org/reference/point_.html
1472
+ # @see https://p5js.org/reference/#/p5/point
1473
+ #
1125
1474
  def point(x, y)
1126
1475
  assertDrawing__
1127
1476
  @painter__.point x, y
@@ -1139,6 +1488,9 @@ module Processing
1139
1488
  #
1140
1489
  # @return [nil] nil
1141
1490
  #
1491
+ # @see https://processing.org/reference/line_.html
1492
+ # @see https://p5js.org/reference/#/p5/line
1493
+ #
1142
1494
  def line(x1, y1, x2, y2)
1143
1495
  assertDrawing__
1144
1496
  @painter__.line x1, y1, x2, y2
@@ -1167,6 +1519,9 @@ module Processing
1167
1519
  #
1168
1520
  # @return [nil] nil
1169
1521
  #
1522
+ # @see https://processing.org/reference/rect_.html
1523
+ # @see https://p5js.org/reference/#/p5/rect
1524
+ #
1170
1525
  def rect(a, b, c, d, *args)
1171
1526
  assertDrawing__
1172
1527
  x, y, w, h = toXYWH__ @rectMode__, a, b, c, d
@@ -1192,6 +1547,9 @@ module Processing
1192
1547
  #
1193
1548
  # @return [nil] nil
1194
1549
  #
1550
+ # @see https://processing.org/reference/ellipse_.html
1551
+ # @see https://p5js.org/reference/#/p5/ellipse
1552
+ #
1195
1553
  def ellipse(a, b, c, d)
1196
1554
  assertDrawing__
1197
1555
  x, y, w, h = toXYWH__ @ellipseMode__, a, b, c, d
@@ -1209,6 +1567,9 @@ module Processing
1209
1567
  #
1210
1568
  # @return [nil] nil
1211
1569
  #
1570
+ # @see https://processing.org/reference/circle_.html
1571
+ # @see https://p5js.org/reference/#/p5/circle
1572
+ #
1212
1573
  def circle(x, y, extent)
1213
1574
  ellipse x, y, extent, extent
1214
1575
  end
@@ -1228,6 +1589,9 @@ module Processing
1228
1589
  #
1229
1590
  # @return [nil] nil
1230
1591
  #
1592
+ # @see https://processing.org/reference/arc_.html
1593
+ # @see https://p5js.org/reference/#/p5/arc
1594
+ #
1231
1595
  def arc(a, b, c, d, start, stop)
1232
1596
  assertDrawing__
1233
1597
  x, y, w, h = toXYWH__ @ellipseMode__, a, b, c, d
@@ -1246,6 +1610,9 @@ module Processing
1246
1610
  #
1247
1611
  # @return [nil] nil
1248
1612
  #
1613
+ # @see https://processing.org/reference/square_.html
1614
+ # @see https://p5js.org/reference/#/p5/square
1615
+ #
1249
1616
  def square(x, y, extent)
1250
1617
  rect x, y, extent, extent
1251
1618
  end
@@ -1263,6 +1630,9 @@ module Processing
1263
1630
  #
1264
1631
  # @return [nil] nil
1265
1632
  #
1633
+ # @see https://processing.org/reference/triangle_.html
1634
+ # @see https://p5js.org/reference/#/p5/triangle
1635
+ #
1266
1636
  def triangle(x1, y1, x2, y2, x3, y3)
1267
1637
  assertDrawing__
1268
1638
  @painter__.line x1, y1, x2, y2, x3, y3, loop: true
@@ -1284,6 +1654,9 @@ module Processing
1284
1654
  #
1285
1655
  # @return [nil] nil
1286
1656
  #
1657
+ # @see https://processing.org/reference/quad_.html
1658
+ # @see https://p5js.org/reference/#/p5/quad
1659
+ #
1287
1660
  def quad(x1, y1, x2, y2, x3, y3, x4, y4)
1288
1661
  assertDrawing__
1289
1662
  @painter__.line x1, y1, x2, y2, x3, y3, x4, y4, loop: true
@@ -1305,6 +1678,9 @@ module Processing
1305
1678
  #
1306
1679
  # @return [nil] nil
1307
1680
  #
1681
+ # @see https://processing.org/reference/curve_.html
1682
+ # @see https://p5js.org/reference/#/p5/curve
1683
+ #
1308
1684
  def curve(cx1, cy1, x1, y1, x2, y2, cx2, cy2)
1309
1685
  assertDrawing__
1310
1686
  @painter__.nsegment = @curveDetail__
@@ -1328,6 +1704,9 @@ module Processing
1328
1704
  #
1329
1705
  # @return [nil] nil
1330
1706
  #
1707
+ # @see https://processing.org/reference/bezier_.html
1708
+ # @see https://p5js.org/reference/#/p5/bezier
1709
+ #
1331
1710
  def bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2)
1332
1711
  assertDrawing__
1333
1712
  @painter__.nsegment = @bezierDetail__
@@ -1356,6 +1735,9 @@ module Processing
1356
1735
  #
1357
1736
  # @return [nil] nil
1358
1737
  #
1738
+ # @see https://processing.org/reference/text_.html
1739
+ # @see https://p5js.org/reference/#/p5/text
1740
+ #
1359
1741
  def text(str, x, y, x2 = nil, y2 = nil)
1360
1742
  assertDrawing__
1361
1743
  if x2
@@ -1394,6 +1776,9 @@ module Processing
1394
1776
  #
1395
1777
  # @return [nil] nil
1396
1778
  #
1779
+ # @see https://processing.org/reference/image_.html
1780
+ # @see https://p5js.org/reference/#/p5/image
1781
+ #
1397
1782
  def image(img, a, b, c = nil, d = nil)
1398
1783
  assertDrawing__
1399
1784
  x, y, w, h = toXYWH__ @imageMode__, a, b, c || img.width, d || img.height
@@ -1418,6 +1803,8 @@ module Processing
1418
1803
  #
1419
1804
  # @return [nil] nil
1420
1805
  #
1806
+ # @see https://processing.org/reference/shape_.html
1807
+ #
1421
1808
  def shape(shp, a = 0, b = 0, c = nil, d = nil)
1422
1809
  assertDrawing__
1423
1810
  return nil unless shp.isVisible
@@ -1604,6 +1991,9 @@ module Processing
1604
1991
  #
1605
1992
  # @return [nil] nil
1606
1993
  #
1994
+ # @see https://processing.org/reference/copy_.html
1995
+ # @see https://p5js.org/reference/#/p5/copy
1996
+ #
1607
1997
  def copy(img = nil, sx, sy, sw, sh, dx, dy, dw, dh)
1608
1998
  blend img, sx, sy, sw, sh, dx, dy, dw, dh, BLEND
1609
1999
  end
@@ -1626,6 +2016,9 @@ module Processing
1626
2016
  #
1627
2017
  # @return [nil] nil
1628
2018
  #
2019
+ # @see https://processing.org/reference/blend_.html
2020
+ # @see https://p5js.org/reference/#/p5/blend
2021
+ #
1629
2022
  def blend(img = nil, sx, sy, sw, sh, dx, dy, dw, dh, mode)
1630
2023
  assertDrawing__
1631
2024
  (img || self).drawImage__(
@@ -1637,6 +2030,9 @@ module Processing
1637
2030
  #
1638
2031
  # @return [nil] nil
1639
2032
  #
2033
+ # @see https://processing.org/reference/loadPixels_.html
2034
+ # @see https://p5js.org/reference/#/p5/loadPixels
2035
+ #
1640
2036
  def loadPixels()
1641
2037
  @pixels__ = getInternal__.pixels
1642
2038
  end
@@ -1645,6 +2041,9 @@ module Processing
1645
2041
  #
1646
2042
  # @return [nil] nil
1647
2043
  #
2044
+ # @see https://processing.org/reference/updatePixels_.html
2045
+ # @see https://p5js.org/reference/#/p5/updatePixels
2046
+ #
1648
2047
  def updatePixels(&block)
1649
2048
  return if !block && !@pixels__
1650
2049
  if block
@@ -1661,6 +2060,11 @@ module Processing
1661
2060
  # An array of all pixels.
1662
2061
  # Call loadPixels() before accessing the array.
1663
2062
  #
2063
+ # @return [Array] color array
2064
+ #
2065
+ # @see https://processing.org/reference/pixels.html
2066
+ # @see https://p5js.org/reference/#/p5/pixels
2067
+ #
1664
2068
  def pixels()
1665
2069
  @pixels__
1666
2070
  end
@@ -1671,6 +2075,9 @@ module Processing
1671
2075
  #
1672
2076
  # @return [nil] nil
1673
2077
  #
2078
+ # @see https://processing.org/reference/save_.html
2079
+ # @see https://p5js.org/reference/#/p5/save
2080
+ #
1674
2081
  def save(filename)
1675
2082
  getInternal__.save filename
1676
2083
  nil
@@ -1683,10 +2090,13 @@ module Processing
1683
2090
  #
1684
2091
  # @param x [Numeric] left/right translation
1685
2092
  # @param y [Numeric] up/down translation
1686
- # @param y [Numeric] forward/backward translation
2093
+ # @param z [Numeric] forward/backward translation
1687
2094
  #
1688
2095
  # @return [nil] nil
1689
2096
  #
2097
+ # @see https://processing.org/reference/translate_.html
2098
+ # @see https://p5js.org/reference/#/p5/translate
2099
+ #
1690
2100
  def translate(x, y, z = 0)
1691
2101
  assertDrawing__
1692
2102
  @painter__.translate x, y, z
@@ -1697,13 +2107,18 @@ module Processing
1697
2107
  #
1698
2108
  # @overload scale(s)
1699
2109
  # @overload scale(x, y)
2110
+ # @overload scale(x, y, z)
1700
2111
  #
1701
2112
  # @param s [Numeric] horizontal and vertical scale
1702
2113
  # @param x [Numeric] horizontal scale
1703
2114
  # @param y [Numeric] vertical scale
2115
+ # @param z [Numeric] depth scale
1704
2116
  #
1705
2117
  # @return [nil] nil
1706
2118
  #
2119
+ # @see https://processing.org/reference/scale_.html
2120
+ # @see https://p5js.org/reference/#/p5/scale
2121
+ #
1707
2122
  def scale(x, y = nil, z = 1)
1708
2123
  assertDrawing__
1709
2124
  @painter__.scale x, (y || x), z
@@ -1716,30 +2131,69 @@ module Processing
1716
2131
  #
1717
2132
  # @return [nil] nil
1718
2133
  #
2134
+ # @see https://processing.org/reference/rotate_.html
2135
+ # @see https://p5js.org/reference/#/p5/rotate
2136
+ #
1719
2137
  def rotate(angle)
1720
2138
  assertDrawing__
1721
2139
  @painter__.rotate toDegrees__ angle
1722
2140
  nil
1723
2141
  end
1724
2142
 
2143
+ # Applies rotation around the x-axis.
2144
+ #
2145
+ # @param angle [Numeric] angle for rotation
2146
+ #
2147
+ # @return [nil] nil
2148
+ #
2149
+ # @see https://processing.org/reference/rotateX_.html
2150
+ # @see https://p5js.org/reference/#/p5/rotateX
2151
+ #
1725
2152
  def rotateX(angle)
1726
2153
  assertDrawing__
1727
2154
  @painter__.rotate toDegrees__(angle), 1, 0, 0
1728
2155
  nil
1729
2156
  end
1730
2157
 
2158
+ # Applies rotation around the y-axis.
2159
+ #
2160
+ # @param angle [Numeric] angle for rotation
2161
+ #
2162
+ # @return [nil] nil
2163
+ #
2164
+ # @see https://processing.org/reference/rotateY_.html
2165
+ # @see https://p5js.org/reference/#/p5/rotateY
2166
+ #
1731
2167
  def rotateY(angle)
1732
2168
  assertDrawing__
1733
2169
  @painter__.rotate toDegrees__(angle), 0, 1, 0
1734
2170
  nil
1735
2171
  end
1736
2172
 
2173
+ # Applies rotation around the z-axis.
2174
+ #
2175
+ # @param angle [Numeric] angle for rotation
2176
+ #
2177
+ # @return [nil] nil
2178
+ #
2179
+ # @see https://processing.org/reference/rotateZ_.html
2180
+ # @see https://p5js.org/reference/#/p5/rotateZ
2181
+ #
1737
2182
  def rotateZ(angle)
1738
2183
  assertDrawing__
1739
2184
  @painter__.rotate toDegrees__(angle), 0, 0, 1
1740
2185
  nil
1741
2186
  end
1742
2187
 
2188
+ # Applies shear around the x-axis.
2189
+ #
2190
+ # @param angle [Numeric] angle for shearing
2191
+ #
2192
+ # @return [nil] nil
2193
+ #
2194
+ # @see https://processing.org/reference/shearX_.html
2195
+ # @see https://p5js.org/reference/#/p5/shearX
2196
+ #
1743
2197
  def shearX(angle)
1744
2198
  t = Math.tan toRadians__(angle)
1745
2199
  @painter__.matrix *= Rays::Matrix.new(
@@ -1747,8 +2201,18 @@ module Processing
1747
2201
  0, 1, 0, 0,
1748
2202
  0, 0, 1, 0,
1749
2203
  0, 0, 0, 1)
2204
+ nil
1750
2205
  end
1751
2206
 
2207
+ # Applies shear around the y-axis.
2208
+ #
2209
+ # @param angle [Numeric] angle for shearing
2210
+ #
2211
+ # @return [nil] nil
2212
+ #
2213
+ # @see https://processing.org/reference/shearY_.html
2214
+ # @see https://p5js.org/reference/#/p5/shearY
2215
+ #
1752
2216
  def shearY(angle)
1753
2217
  t = Math.tan toRadians__(angle)
1754
2218
  @painter__.matrix *= Rays::Matrix.new(
@@ -1756,12 +2220,15 @@ module Processing
1756
2220
  t, 1, 0, 0,
1757
2221
  0, 0, 1, 0,
1758
2222
  0, 0, 0, 1)
2223
+ nil
1759
2224
  end
1760
2225
 
1761
2226
  # Pushes the current transformation matrix to stack.
1762
2227
  #
1763
2228
  # @return [Object] result of the expression at the end of the block
1764
2229
  #
2230
+ # @see https://processing.org/reference/pushMatrix_.html
2231
+ #
1765
2232
  def pushMatrix(&block)
1766
2233
  assertDrawing__
1767
2234
  @matrixStack__.push @painter__.matrix
@@ -1774,6 +2241,8 @@ module Processing
1774
2241
  #
1775
2242
  # @return [nil] nil
1776
2243
  #
2244
+ # @see https://processing.org/reference/popMatrix_.html
2245
+ #
1777
2246
  def popMatrix()
1778
2247
  assertDrawing__
1779
2248
  raise "matrix stack underflow" if @matrixStack__.empty?
@@ -1807,6 +2276,9 @@ module Processing
1807
2276
  #
1808
2277
  # @return [nil] nil
1809
2278
  #
2279
+ # @see https://processing.org/reference/applyMatrix_.html
2280
+ # @see https://p5js.org/reference/#/p5/applyMatrix
2281
+ #
1810
2282
  def applyMatrix(*args)
1811
2283
  assertDrawing__
1812
2284
  args = args.first if args.first.kind_of?(Array)
@@ -1830,6 +2302,9 @@ module Processing
1830
2302
  #
1831
2303
  # @return [nil] nil
1832
2304
  #
2305
+ # @see https://processing.org/reference/resetMatrix_.html
2306
+ # @see https://p5js.org/reference/#/p5/resetMatrix
2307
+ #
1833
2308
  def resetMatrix()
1834
2309
  assertDrawing__
1835
2310
  @painter__.matrix = 1
@@ -1840,6 +2315,8 @@ module Processing
1840
2315
  #
1841
2316
  # @return [nil] nil
1842
2317
  #
2318
+ # @see https://processing.org/reference/printMatrix_.html
2319
+ #
1843
2320
  def printMatrix()
1844
2321
  m = @painter__.matrix
1845
2322
  m.transpose! if @p5jsMode__
@@ -1851,6 +2328,8 @@ module Processing
1851
2328
  #
1852
2329
  # @return [Object] result of the expression at the end of the block
1853
2330
  #
2331
+ # @see https://processing.org/reference/pushStyle_.html
2332
+ #
1854
2333
  def pushStyle(&block)
1855
2334
  assertDrawing__
1856
2335
  @styleStack__.push [
@@ -1898,6 +2377,8 @@ module Processing
1898
2377
  #
1899
2378
  # @return [nil] nil
1900
2379
  #
2380
+ # @see https://processing.org/reference/popStyle_.html
2381
+ #
1901
2382
  def popStyle()
1902
2383
  assertDrawing__
1903
2384
  raise "style stack underflow" if @styleStack__.empty?
@@ -1943,6 +2424,9 @@ module Processing
1943
2424
  #
1944
2425
  # @return [Object] result of the expression at the end of the block
1945
2426
  #
2427
+ # @see https://processing.org/reference/push_.html
2428
+ # @see https://p5js.org/reference/#/p5/push
2429
+ #
1946
2430
  def push(&block)
1947
2431
  pushMatrix
1948
2432
  pushStyle
@@ -1955,11 +2439,19 @@ module Processing
1955
2439
  #
1956
2440
  # @return [nil] nil
1957
2441
  #
2442
+ # @see https://processing.org/reference/pop_.html
2443
+ # @see https://p5js.org/reference/#/p5/pop
2444
+ #
1958
2445
  def pop()
1959
2446
  popMatrix
1960
2447
  popStyle
1961
2448
  end
1962
2449
 
2450
+ # @private
2451
+ def getPainter__()
2452
+ @painter__
2453
+ end
2454
+
1963
2455
  # @private
1964
2456
  def getInternal__()
1965
2457
  @image__
@@ -1988,6 +2480,9 @@ module Processing
1988
2480
  #
1989
2481
  # @return [Numeric] absolute number
1990
2482
  #
2483
+ # @see https://processing.org/reference/abs_.html
2484
+ # @see https://p5js.org/reference/#/p5/abs
2485
+ #
1991
2486
  def abs(value)
1992
2487
  value.abs
1993
2488
  end
@@ -1998,6 +2493,9 @@ module Processing
1998
2493
  #
1999
2494
  # @return [Numeric] rounded up number
2000
2495
  #
2496
+ # @see https://processing.org/reference/ceil_.html
2497
+ # @see https://p5js.org/reference/#/p5/ceil
2498
+ #
2001
2499
  def ceil(value)
2002
2500
  value.ceil
2003
2501
  end
@@ -2008,6 +2506,9 @@ module Processing
2008
2506
  #
2009
2507
  # @return [Numeric] rounded down number
2010
2508
  #
2509
+ # @see https://processing.org/reference/floor_.html
2510
+ # @see https://p5js.org/reference/#/p5/floor
2511
+ #
2011
2512
  def floor(value)
2012
2513
  value.floor
2013
2514
  end
@@ -2018,6 +2519,9 @@ module Processing
2018
2519
  #
2019
2520
  # @return [Numeric] rounded number
2020
2521
  #
2522
+ # @see https://processing.org/reference/round_.html
2523
+ # @see https://p5js.org/reference/#/p5/round
2524
+ #
2021
2525
  def round(value)
2022
2526
  value.round
2023
2527
  end
@@ -2028,6 +2532,9 @@ module Processing
2028
2532
  #
2029
2533
  # @return [Numeric] result number
2030
2534
  #
2535
+ # @see https://processing.org/reference/log_.html
2536
+ # @see https://p5js.org/reference/#/p5/log
2537
+ #
2031
2538
  def log(n)
2032
2539
  Math.log n
2033
2540
  end
@@ -2038,6 +2545,9 @@ module Processing
2038
2545
  #
2039
2546
  # @return [Numeric] result number
2040
2547
  #
2548
+ # @see https://processing.org/reference/exp_.html
2549
+ # @see https://p5js.org/reference/#/p5/exp
2550
+ #
2041
2551
  def exp(n)
2042
2552
  Math.exp n
2043
2553
  end
@@ -2049,6 +2559,9 @@ module Processing
2049
2559
  #
2050
2560
  # @return [Numeric] value ** exponent
2051
2561
  #
2562
+ # @see https://processing.org/reference/pow_.html
2563
+ # @see https://p5js.org/reference/#/p5/pow
2564
+ #
2052
2565
  def pow(value, exponent)
2053
2566
  value ** exponent
2054
2567
  end
@@ -2059,6 +2572,9 @@ module Processing
2059
2572
  #
2060
2573
  # @return [Numeric] squared value
2061
2574
  #
2575
+ # @see https://processing.org/reference/sq_.html
2576
+ # @see https://p5js.org/reference/#/p5/sq
2577
+ #
2062
2578
  def sq(value)
2063
2579
  value * value
2064
2580
  end
@@ -2069,6 +2585,9 @@ module Processing
2069
2585
  #
2070
2586
  # @return [Numeric] squared value
2071
2587
  #
2588
+ # @see https://processing.org/reference/sqrt_.html
2589
+ # @see https://p5js.org/reference/#/p5/sqrt
2590
+ #
2072
2591
  def sqrt(value)
2073
2592
  Math.sqrt value
2074
2593
  end
@@ -2084,6 +2603,9 @@ module Processing
2084
2603
  #
2085
2604
  # @return [Numeric] magnitude
2086
2605
  #
2606
+ # @see https://processing.org/reference/mag_.html
2607
+ # @see https://p5js.org/reference/#/p5/mag
2608
+ #
2087
2609
  def mag(*args)
2088
2610
  x, y, z = *args
2089
2611
  case args.size
@@ -2107,6 +2629,9 @@ module Processing
2107
2629
  #
2108
2630
  # @return [Numeric] distance between 2 points
2109
2631
  #
2632
+ # @see https://processing.org/reference/dist_.html
2633
+ # @see https://p5js.org/reference/#/p5/dist
2634
+ #
2110
2635
  def dist(*args)
2111
2636
  case args.size
2112
2637
  when 4
@@ -2129,6 +2654,9 @@ module Processing
2129
2654
  #
2130
2655
  # @return [Numeric] normalized value between 0..1
2131
2656
  #
2657
+ # @see https://processing.org/reference/norm_.html
2658
+ # @see https://p5js.org/reference/#/p5/norm
2659
+ #
2132
2660
  def norm(value, start, stop)
2133
2661
  (value.to_f - start.to_f) / (stop.to_f - start.to_f)
2134
2662
  end
@@ -2141,6 +2669,9 @@ module Processing
2141
2669
  #
2142
2670
  # @return [Numeric] interporated number
2143
2671
  #
2672
+ # @see https://processing.org/reference/lerp_.html
2673
+ # @see https://p5js.org/reference/#/p5/lerp
2674
+ #
2144
2675
  def lerp(start, stop, amount)
2145
2676
  start + (stop - start) * amount
2146
2677
  end
@@ -2153,6 +2684,9 @@ module Processing
2153
2684
  #
2154
2685
  # @return [Integer] interporated color
2155
2686
  #
2687
+ # @see https://processing.org/reference/lerpColor_.html
2688
+ # @see https://p5js.org/reference/#/p5/lerpColor
2689
+ #
2156
2690
  def lerpColor(color1, color2, amount)
2157
2691
  color(
2158
2692
  lerp(red( color1), red( color2), amount),
@@ -2171,6 +2705,9 @@ module Processing
2171
2705
  #
2172
2706
  # @return [Numeric] mapped number
2173
2707
  #
2708
+ # @see https://processing.org/reference/map_.html
2709
+ # @see https://p5js.org/reference/#/p5/map
2710
+ #
2174
2711
  def map(value, start1, stop1, start2, stop2)
2175
2712
  lerp start2, stop2, norm(value, start1, stop1)
2176
2713
  end
@@ -2188,6 +2725,9 @@ module Processing
2188
2725
  #
2189
2726
  # @return [Numeric] minimum value
2190
2727
  #
2728
+ # @see https://processing.org/reference/min_.html
2729
+ # @see https://p5js.org/reference/#/p5/min
2730
+ #
2191
2731
  def min(*args)
2192
2732
  args.flatten.min
2193
2733
  end
@@ -2205,6 +2745,9 @@ module Processing
2205
2745
  #
2206
2746
  # @return [Numeric] maximum value
2207
2747
  #
2748
+ # @see https://processing.org/reference/max_.html
2749
+ # @see https://p5js.org/reference/#/p5/max
2750
+ #
2208
2751
  def max(*args)
2209
2752
  args.flatten.max
2210
2753
  end
@@ -2217,6 +2760,9 @@ module Processing
2217
2760
  #
2218
2761
  # @return [Numeric] constrained number
2219
2762
  #
2763
+ # @see https://processing.org/reference/constrain_.html
2764
+ # @see https://p5js.org/reference/#/p5/constrain
2765
+ #
2220
2766
  def constrain(value, min, max)
2221
2767
  value < min ? min : (value > max ? max : value)
2222
2768
  end
@@ -2227,6 +2773,9 @@ module Processing
2227
2773
  #
2228
2774
  # @return [Numeric] radian
2229
2775
  #
2776
+ # @see https://processing.org/reference/radians_.html
2777
+ # @see https://p5js.org/reference/#/p5/radians
2778
+ #
2230
2779
  def radians(degree)
2231
2780
  degree * DEG2RAD__
2232
2781
  end
@@ -2237,6 +2786,9 @@ module Processing
2237
2786
  #
2238
2787
  # @return [Numeric] degree
2239
2788
  #
2789
+ # @see https://processing.org/reference/degrees_.html
2790
+ # @see https://p5js.org/reference/#/p5/degrees
2791
+ #
2240
2792
  def degrees(radian)
2241
2793
  radian * RAD2DEG__
2242
2794
  end
@@ -2247,6 +2799,9 @@ module Processing
2247
2799
  #
2248
2800
  # @return [Numeric] the sine
2249
2801
  #
2802
+ # @see https://processing.org/reference/sin_.html
2803
+ # @see https://p5js.org/reference/#/p5/sin
2804
+ #
2250
2805
  def sin(angle)
2251
2806
  Math.sin angle
2252
2807
  end
@@ -2257,6 +2812,9 @@ module Processing
2257
2812
  #
2258
2813
  # @return [Numeric] the cosine
2259
2814
  #
2815
+ # @see https://processing.org/reference/cos_.html
2816
+ # @see https://p5js.org/reference/#/p5/cos
2817
+ #
2260
2818
  def cos(angle)
2261
2819
  Math.cos angle
2262
2820
  end
@@ -2267,6 +2825,9 @@ module Processing
2267
2825
  #
2268
2826
  # @return [Numeric] the tangent
2269
2827
  #
2828
+ # @see https://processing.org/reference/tan_.html
2829
+ # @see https://p5js.org/reference/#/p5/tan
2830
+ #
2270
2831
  def tan(angle)
2271
2832
  Math.tan angle
2272
2833
  end
@@ -2277,6 +2838,9 @@ module Processing
2277
2838
  #
2278
2839
  # @return [Numeric] the arc sine
2279
2840
  #
2841
+ # @see https://processing.org/reference/asin_.html
2842
+ # @see https://p5js.org/reference/#/p5/asin
2843
+ #
2280
2844
  def asin(value)
2281
2845
  Math.asin value
2282
2846
  end
@@ -2287,6 +2851,9 @@ module Processing
2287
2851
  #
2288
2852
  # @return [Numeric] the arc cosine
2289
2853
  #
2854
+ # @see https://processing.org/reference/acos_.html
2855
+ # @see https://p5js.org/reference/#/p5/acos
2856
+ #
2290
2857
  def acos(value)
2291
2858
  Math.acos value
2292
2859
  end
@@ -2297,6 +2864,9 @@ module Processing
2297
2864
  #
2298
2865
  # @return [Numeric] the arc tangent
2299
2866
  #
2867
+ # @see https://processing.org/reference/atan_.html
2868
+ # @see https://p5js.org/reference/#/p5/atan
2869
+ #
2300
2870
  def atan(value)
2301
2871
  Math.atan value
2302
2872
  end
@@ -2308,6 +2878,9 @@ module Processing
2308
2878
  #
2309
2879
  # @return [Numeric] the angle in radians
2310
2880
  #
2881
+ # @see https://processing.org/reference/atan2_.html
2882
+ # @see https://p5js.org/reference/#/p5/atan2
2883
+ #
2311
2884
  def atan2(y, x)
2312
2885
  Math.atan2 y, x
2313
2886
  end
@@ -2540,6 +3113,8 @@ module Processing
2540
3113
  #
2541
3114
  # @return [Vector] new vector
2542
3115
  #
3116
+ # @see https://p5js.org/reference/#/p5/createVector
3117
+ #
2543
3118
  def createVector(*args)
2544
3119
  Vector.new(*args, context: self)
2545
3120
  end
@@ -2549,6 +3124,10 @@ module Processing
2549
3124
  # @param name [String] font name
2550
3125
  # @param size [Numeric] font size (max 256)
2551
3126
  #
3127
+ # @return [Font] new font
3128
+ #
3129
+ # @see https://processing.org/reference/createFont_.html
3130
+ #
2552
3131
  def createFont(name, size)
2553
3132
  size = FONT_SIZE_MAX__ if size && size > FONT_SIZE_MAX__
2554
3133
  Font.new Rays::Font.new(name, size || FONT_SIZE_DEFAULT__)
@@ -2565,6 +3144,9 @@ module Processing
2565
3144
  #
2566
3145
  # @return [Image] new image
2567
3146
  #
3147
+ # @see https://processing.org/reference/createImage_.html
3148
+ # @see https://p5js.org/reference/#/p5/createImage
3149
+ #
2568
3150
  def createImage(w, h, format = RGBA)
2569
3151
  colorspace = {RGB => Rays::RGB, RGBA => Rays::RGBA}[format]
2570
3152
  raise ArgumentError, "Unknown image format" unless colorspace
@@ -2584,6 +3166,10 @@ module Processing
2584
3166
  #
2585
3167
  # @param kind [LINE, RECT, ELLIPSE, ARC, TRIANGLE, QUAD, GROUP]
2586
3168
  #
3169
+ # @return [Shape] new shape
3170
+ #
3171
+ # @see https://processing.org/reference/createShape_.html
3172
+ #
2587
3173
  def createShape(kind = nil, *args)
2588
3174
  case kind
2589
3175
  when LINE then createLineShape__( *args)
@@ -2599,19 +3185,19 @@ module Processing
2599
3185
  end
2600
3186
 
2601
3187
  # @private
2602
- private def createLineShape__(x1, y1, x2, y2)
3188
+ def createLineShape__(x1, y1, x2, y2)
2603
3189
  Shape.new Rays::Polygon.line(x1, y1, x2, y2), context: self
2604
3190
  end
2605
3191
 
2606
3192
  # @private
2607
- private def createRectShape__(a, b, c, d)
2608
- x, y, w, h = toXYWH__ @rectMode__, a, b, c, d
2609
- Shape.new Rays::Polygon.rect(x, y, w, h), context: self
3193
+ def createRectShape__(a, b, c, d, *args, mode: @rectMode__)
3194
+ x, y, w, h = toXYWH__ mode, a, b, c, d
3195
+ Shape.new Rays::Polygon.rect(x, y, w, h, *args), context: self
2610
3196
  end
2611
3197
 
2612
3198
  # @private
2613
- private def createEllipseShape__(a, b, c, d)
2614
- x, y, w, h = toXYWH__ @ellipseMode__, a, b, c, d
3199
+ def createEllipseShape__(a, b, c, d, mode: @ellipseMode__)
3200
+ x, y, w, h = toXYWH__ mode, a, b, c, d
2615
3201
  Shape.new Rays::Polygon.ellipse(x, y, w, h), context: self
2616
3202
  end
2617
3203
 
@@ -2640,6 +3226,9 @@ module Processing
2640
3226
  #
2641
3227
  # @return [Graphics] graphics object
2642
3228
  #
3229
+ # @see https://processing.org/reference/createGraphics_.html
3230
+ # @see https://p5js.org/reference/#/p5/createGraphics
3231
+ #
2643
3232
  def createGraphics(width, height, pixelDensity = 1)
2644
3233
  Graphics.new width, height, pixelDensity
2645
3234
  end
@@ -2676,6 +3265,8 @@ module Processing
2676
3265
  #
2677
3266
  # @return [Shader] shader object
2678
3267
  #
3268
+ # @see https://p5js.org/reference/#/p5/createShader
3269
+ #
2679
3270
  def createShader(vert, frag)
2680
3271
  vert = File.read if vert && File.exist?(vert)
2681
3272
  frag = File.read if frag && File.exist?(frag)
@@ -2747,6 +3338,10 @@ module Processing
2747
3338
  img
2748
3339
  end
2749
3340
 
3341
+ def loadShape(filename)
3342
+ Processing::SVGLoader.new(self).load filename
3343
+ end
3344
+
2750
3345
  # Loads shader file.
2751
3346
  #
2752
3347
  # @overload loadShader(fragPath)
@@ -2757,6 +3352,9 @@ module Processing
2757
3352
  #
2758
3353
  # @return [Shader] loaded shader object
2759
3354
  #
3355
+ # @see https://processing.org/reference/loadShader_.html
3356
+ # @see https://p5js.org/reference/#/p5/loadShader
3357
+ #
2760
3358
  def loadShader(fragPath, vertPath = nil)
2761
3359
  createShader vertPath, fragPath
2762
3360
  end