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
@@ -123,96 +123,127 @@ module Processing
|
|
123
123
|
REPLACE = :replace
|
124
124
|
|
125
125
|
# Key code or Mode for textAlign().
|
126
|
+
#
|
126
127
|
LEFT = :left
|
127
128
|
|
128
129
|
# Key code or Mode for textAlign().
|
130
|
+
#
|
129
131
|
RIGHT = :right
|
130
132
|
|
131
133
|
# Mode for textAlign().
|
134
|
+
#
|
132
135
|
TOP = :top
|
133
136
|
|
134
137
|
# Mode for textAlign().
|
138
|
+
#
|
135
139
|
BOTTOM = :bottom
|
136
140
|
|
137
141
|
# Mode for textAlign().
|
142
|
+
#
|
138
143
|
BASELINE = :baseline
|
139
144
|
|
140
145
|
# Mode for textureMode().
|
146
|
+
#
|
141
147
|
IMAGE = :image
|
142
148
|
|
143
149
|
# Mode for textureMode().
|
150
|
+
#
|
144
151
|
NORMAL = :normal
|
145
152
|
|
146
153
|
# Mode for textureWrap().
|
154
|
+
#
|
147
155
|
CLAMP = :clamp
|
148
156
|
|
149
157
|
# Mode for textureWrap().
|
158
|
+
#
|
150
159
|
REPEAT = :repeat
|
151
160
|
|
152
161
|
# Filter type for filter()
|
162
|
+
#
|
153
163
|
THRESHOLD = :threshold
|
154
164
|
|
155
165
|
# Filter type for filter()
|
166
|
+
#
|
156
167
|
GRAY = :gray
|
157
168
|
|
158
169
|
# Filter type for filter()
|
170
|
+
#
|
159
171
|
INVERT = :invert
|
160
172
|
|
161
173
|
# Filter type for filter()
|
174
|
+
#
|
162
175
|
BLUR = :blur
|
163
176
|
|
164
177
|
# Shape mode for createShape()
|
178
|
+
#
|
165
179
|
LINE = :line
|
166
180
|
|
167
181
|
# Shape mode for createShape()
|
182
|
+
#
|
168
183
|
RECT = :rect
|
169
184
|
|
170
185
|
# Shape mode for createShape()
|
186
|
+
#
|
171
187
|
ELLIPSE = :ellipse
|
172
188
|
|
173
189
|
# Shape mode for createShape()
|
190
|
+
#
|
174
191
|
ARC = :arc
|
175
192
|
|
176
193
|
# Shape mode for createShape()
|
194
|
+
#
|
177
195
|
TRIANGLE = :triangle
|
178
196
|
|
179
197
|
# Shape mode for createShape()
|
198
|
+
#
|
180
199
|
QUAD = :quad
|
181
200
|
|
182
201
|
# Shape mode for createShape()
|
202
|
+
#
|
183
203
|
GROUP = :group
|
184
204
|
|
185
205
|
# Shape mode for beginShape()
|
206
|
+
#
|
186
207
|
POINTS = :points
|
187
208
|
|
188
209
|
# Shape mode for beginShape()
|
210
|
+
#
|
189
211
|
LINES = :lines
|
190
212
|
|
191
213
|
# Shape mode for beginShape()
|
214
|
+
#
|
192
215
|
TRIANGLES = :triangles
|
193
216
|
|
194
217
|
# Shape mode for beginShape()
|
218
|
+
#
|
195
219
|
TRIANGLE_FAN = :triangle_fan
|
196
220
|
|
197
221
|
# Shape mode for beginShape()
|
222
|
+
#
|
198
223
|
TRIANGLE_STRIP = :triangle_strip
|
199
224
|
|
200
225
|
# Shape mode for beginShape()
|
226
|
+
#
|
201
227
|
QUADS = :quads
|
202
228
|
|
203
229
|
# Shape mode for beginShape()
|
230
|
+
#
|
204
231
|
QUAD_STRIP = :quad_strip
|
205
232
|
|
206
233
|
# Shape mode for beginShape()
|
234
|
+
#
|
207
235
|
TESS = :tess
|
208
236
|
|
209
237
|
# OPEN flag for endShape()
|
238
|
+
#
|
210
239
|
OPEN = :open
|
211
240
|
|
212
241
|
# CLOSE flag for endShape()
|
242
|
+
#
|
213
243
|
CLOSE = :close
|
214
244
|
|
215
245
|
# Key codes.
|
246
|
+
#
|
216
247
|
ENTER = :enter
|
217
248
|
SPACE = :space
|
218
249
|
TAB = :tab
|
@@ -382,6 +413,9 @@ module Processing
|
|
382
413
|
#
|
383
414
|
# @return [Numeric] width
|
384
415
|
#
|
416
|
+
# @see https://processing.org/reference/width.html
|
417
|
+
# @see https://p5js.org/reference/#/p5/width
|
418
|
+
#
|
385
419
|
def width()
|
386
420
|
getInternal__.width
|
387
421
|
end
|
@@ -390,6 +424,9 @@ module Processing
|
|
390
424
|
#
|
391
425
|
# @return [Numeric] height
|
392
426
|
#
|
427
|
+
# @see https://processing.org/reference/height.html
|
428
|
+
# @see https://p5js.org/reference/#/p5/height
|
429
|
+
#
|
393
430
|
def height()
|
394
431
|
getInternal__.height
|
395
432
|
end
|
@@ -398,6 +435,8 @@ module Processing
|
|
398
435
|
#
|
399
436
|
# @return [Numeric] width
|
400
437
|
#
|
438
|
+
# @see https://processing.org/reference/pixelWidth.html
|
439
|
+
#
|
401
440
|
def pixelWidth()
|
402
441
|
width * pixelDensity
|
403
442
|
end
|
@@ -406,6 +445,8 @@ module Processing
|
|
406
445
|
#
|
407
446
|
# @return [Numeric] height
|
408
447
|
#
|
448
|
+
# @see https://processing.org/reference/pixelHeight.html
|
449
|
+
#
|
409
450
|
def pixelHeight()
|
410
451
|
height * pixelDensity
|
411
452
|
end
|
@@ -414,6 +455,9 @@ module Processing
|
|
414
455
|
#
|
415
456
|
# @return [Numeric] pixel density
|
416
457
|
#
|
458
|
+
# @see https://processing.org/reference/pixelDensity_.html
|
459
|
+
# @see https://p5js.org/reference/#/p5/pixelDensity
|
460
|
+
#
|
417
461
|
def pixelDensity()
|
418
462
|
@painter__.pixel_density
|
419
463
|
end
|
@@ -448,6 +492,9 @@ module Processing
|
|
448
492
|
#
|
449
493
|
# @return [RGB, HSB] current mode
|
450
494
|
#
|
495
|
+
# @see https://processing.org/reference/colorMode_.html
|
496
|
+
# @see https://p5js.org/reference/#/p5/colorMode
|
497
|
+
#
|
451
498
|
def colorMode(mode = nil, *maxes)
|
452
499
|
if mode != nil
|
453
500
|
mode = mode.downcase.to_sym
|
@@ -479,6 +526,9 @@ module Processing
|
|
479
526
|
#
|
480
527
|
# @return [Integer] the rgba color value
|
481
528
|
#
|
529
|
+
# @see https://processing.org/reference/color_.html
|
530
|
+
# @see https://p5js.org/reference/#/p5/color
|
531
|
+
#
|
482
532
|
def color(*args)
|
483
533
|
toRGBA__(*args)
|
484
534
|
.map {|n| (n * 255).to_i.clamp 0, 255}
|
@@ -491,6 +541,9 @@ module Processing
|
|
491
541
|
#
|
492
542
|
# @return [Numeric] the red value
|
493
543
|
#
|
544
|
+
# @see https://processing.org/reference/red_.html
|
545
|
+
# @see https://p5js.org/reference/#/p5/red
|
546
|
+
#
|
494
547
|
def red(color)
|
495
548
|
((color >> 16) & 0xff) / 255.0 * @colorMaxes__[0]
|
496
549
|
end
|
@@ -501,6 +554,9 @@ module Processing
|
|
501
554
|
#
|
502
555
|
# @return [Numeric] the green value
|
503
556
|
#
|
557
|
+
# @see https://processing.org/reference/green_.html
|
558
|
+
# @see https://p5js.org/reference/#/p5/green
|
559
|
+
#
|
504
560
|
def green(color)
|
505
561
|
((color >> 8) & 0xff) / 255.0 * @colorMaxes__[1]
|
506
562
|
end
|
@@ -511,6 +567,9 @@ module Processing
|
|
511
567
|
#
|
512
568
|
# @return [Numeric] the blue value
|
513
569
|
#
|
570
|
+
# @see https://processing.org/reference/blue_.html
|
571
|
+
# @see https://p5js.org/reference/#/p5/blue
|
572
|
+
#
|
514
573
|
def blue(color)
|
515
574
|
(color & 0xff) / 255.0 * @colorMaxes__[2]
|
516
575
|
end
|
@@ -521,6 +580,9 @@ module Processing
|
|
521
580
|
#
|
522
581
|
# @return [Numeric] the red value
|
523
582
|
#
|
583
|
+
# @see https://processing.org/reference/alpha_.html
|
584
|
+
# @see https://p5js.org/reference/#/p5/alpha
|
585
|
+
#
|
524
586
|
def alpha(color)
|
525
587
|
((color >> 24) & 0xff) / 255.0 * @colorMaxes__[3]
|
526
588
|
end
|
@@ -531,6 +593,9 @@ module Processing
|
|
531
593
|
#
|
532
594
|
# @return [Numeric] the hue value
|
533
595
|
#
|
596
|
+
# @see https://processing.org/reference/hue_.html
|
597
|
+
# @see https://p5js.org/reference/#/p5/hue
|
598
|
+
#
|
534
599
|
def hue(color)
|
535
600
|
h, = toRawColor__(color).to_hsv
|
536
601
|
h * (@hsbColor__ ? @colorMaxes__[0] : 1)
|
@@ -542,6 +607,9 @@ module Processing
|
|
542
607
|
#
|
543
608
|
# @return [Numeric] the saturation value
|
544
609
|
#
|
610
|
+
# @see https://processing.org/reference/saturation_.html
|
611
|
+
# @see https://p5js.org/reference/#/p5/saturation
|
612
|
+
#
|
545
613
|
def saturation(color)
|
546
614
|
_, s, = toRawColor__(color).to_hsv
|
547
615
|
s * (@hsbColor__ ? @colorMaxes__[1] : 1)
|
@@ -553,6 +621,9 @@ module Processing
|
|
553
621
|
#
|
554
622
|
# @return [Numeric] the brightness value
|
555
623
|
#
|
624
|
+
# @see https://processing.org/reference/brightness_.html
|
625
|
+
# @see https://p5js.org/reference/#/p5/brightness
|
626
|
+
#
|
556
627
|
def brightness(color)
|
557
628
|
_, _, b = toRawColor__(color).to_hsv
|
558
629
|
b * (@hsbColor__ ? @colorMaxes__[2] : 1)
|
@@ -606,6 +677,8 @@ module Processing
|
|
606
677
|
#
|
607
678
|
# @return [RADIANS, DEGREES] current mode
|
608
679
|
#
|
680
|
+
# @see https://p5js.org/reference/#/p5/angleMode
|
681
|
+
#
|
609
682
|
def angleMode(mode = nil)
|
610
683
|
if mode != nil
|
611
684
|
@angleMode__ = mode
|
@@ -650,6 +723,9 @@ module Processing
|
|
650
723
|
#
|
651
724
|
# @return [nil] nil
|
652
725
|
#
|
726
|
+
# @see https://processing.org/reference/rectMode_.html
|
727
|
+
# @see https://p5js.org/reference/#/p5/rectMode
|
728
|
+
#
|
653
729
|
def rectMode(mode)
|
654
730
|
@rectMode__ = mode
|
655
731
|
end
|
@@ -665,6 +741,9 @@ module Processing
|
|
665
741
|
#
|
666
742
|
# @return [nil] nil
|
667
743
|
#
|
744
|
+
# @see https://processing.org/reference/ellipseMode_.html
|
745
|
+
# @see https://p5js.org/reference/#/p5/ellipseMode
|
746
|
+
#
|
668
747
|
def ellipseMode(mode)
|
669
748
|
@ellipseMode__ = mode
|
670
749
|
end
|
@@ -679,6 +758,9 @@ module Processing
|
|
679
758
|
#
|
680
759
|
# @return [nil] nil
|
681
760
|
#
|
761
|
+
# @see https://processing.org/reference/imageMode_.html
|
762
|
+
# @see https://p5js.org/reference/#/p5/imageMode
|
763
|
+
#
|
682
764
|
def imageMode(mode)
|
683
765
|
@imageMode__ = mode
|
684
766
|
end
|
@@ -693,6 +775,8 @@ module Processing
|
|
693
775
|
#
|
694
776
|
# @return [nil] nil
|
695
777
|
#
|
778
|
+
# @see https://processing.org/reference/shapeMode_.html
|
779
|
+
#
|
696
780
|
def shapeMode(mode)
|
697
781
|
@shapeMode__ = mode
|
698
782
|
end
|
@@ -714,6 +798,9 @@ module Processing
|
|
714
798
|
#
|
715
799
|
# @return [nil] nil
|
716
800
|
#
|
801
|
+
# @see https://processing.org/reference/blendMode_.html
|
802
|
+
# @see https://p5js.org/reference/#/p5/blendMode
|
803
|
+
#
|
717
804
|
def blendMode(mode = nil)
|
718
805
|
if mode != nil
|
719
806
|
@blendMode__ = mode
|
@@ -740,6 +827,9 @@ module Processing
|
|
740
827
|
#
|
741
828
|
# @return [nil] nil
|
742
829
|
#
|
830
|
+
# @see https://processing.org/reference/fill_.html
|
831
|
+
# @see https://p5js.org/reference/#/p5/fill
|
832
|
+
#
|
743
833
|
def fill(*args)
|
744
834
|
@painter__.fill(*toRGBA__(*args))
|
745
835
|
nil
|
@@ -754,6 +844,9 @@ module Processing
|
|
754
844
|
#
|
755
845
|
# @return [nil] nil
|
756
846
|
#
|
847
|
+
# @see https://processing.org/reference/noFill_.html
|
848
|
+
# @see https://p5js.org/reference/#/p5/noFill
|
849
|
+
#
|
757
850
|
def noFill()
|
758
851
|
@painter__.fill nil
|
759
852
|
nil
|
@@ -777,6 +870,9 @@ module Processing
|
|
777
870
|
#
|
778
871
|
# @return [nil] nil
|
779
872
|
#
|
873
|
+
# @see https://processing.org/reference/stroke_.html
|
874
|
+
# @see https://p5js.org/reference/#/p5/stroke
|
875
|
+
#
|
780
876
|
def stroke(*args)
|
781
877
|
@painter__.stroke(*toRGBA__(*args))
|
782
878
|
nil
|
@@ -786,6 +882,9 @@ module Processing
|
|
786
882
|
#
|
787
883
|
# @return [nil] nil
|
788
884
|
#
|
885
|
+
# @see https://processing.org/reference/noStroke_.html
|
886
|
+
# @see https://p5js.org/reference/#/p5/noStroke
|
887
|
+
#
|
789
888
|
def noStroke()
|
790
889
|
@painter__.stroke nil
|
791
890
|
nil
|
@@ -797,6 +896,9 @@ module Processing
|
|
797
896
|
#
|
798
897
|
# @return [nil] nil
|
799
898
|
#
|
899
|
+
# @see https://processing.org/reference/strokeWeight_.html
|
900
|
+
# @see https://p5js.org/reference/#/p5/strokeWeight
|
901
|
+
#
|
800
902
|
def strokeWeight(weight)
|
801
903
|
@painter__.stroke_width weight
|
802
904
|
nil
|
@@ -808,6 +910,9 @@ module Processing
|
|
808
910
|
#
|
809
911
|
# @return [nil] nil
|
810
912
|
#
|
913
|
+
# @see https://processing.org/reference/strokeCap_.html
|
914
|
+
# @see https://p5js.org/reference/#/p5/strokeCap
|
915
|
+
#
|
811
916
|
def strokeCap(cap)
|
812
917
|
@painter__.stroke_cap cap
|
813
918
|
nil
|
@@ -819,6 +924,9 @@ module Processing
|
|
819
924
|
#
|
820
925
|
# @return [nil] nil
|
821
926
|
#
|
927
|
+
# @see https://processing.org/reference/strokeJoin_.html
|
928
|
+
# @see https://p5js.org/reference/#/p5/strokeJoin
|
929
|
+
#
|
822
930
|
def strokeJoin(join)
|
823
931
|
@painter__.stroke_join join
|
824
932
|
nil
|
@@ -888,6 +996,9 @@ module Processing
|
|
888
996
|
#
|
889
997
|
# @return [nil] nil
|
890
998
|
#
|
999
|
+
# @see https://processing.org/reference/tint_.html
|
1000
|
+
# @see https://p5js.org/reference/#/p5/tint
|
1001
|
+
#
|
891
1002
|
def tint(*args)
|
892
1003
|
@tint__ = args
|
893
1004
|
nil
|
@@ -897,6 +1008,9 @@ module Processing
|
|
897
1008
|
#
|
898
1009
|
# @return [nil] nil
|
899
1010
|
#
|
1011
|
+
# @see https://processing.org/reference/noTint_.html
|
1012
|
+
# @see https://p5js.org/reference/#/p5/noTint
|
1013
|
+
#
|
900
1014
|
def noTint()
|
901
1015
|
@tint__ = nil
|
902
1016
|
end
|
@@ -917,6 +1031,9 @@ module Processing
|
|
917
1031
|
#
|
918
1032
|
# @return [nil] nil
|
919
1033
|
#
|
1034
|
+
# @see https://processing.org/reference/clip_.html
|
1035
|
+
# @see https://p5js.org/reference/#/p5/clip
|
1036
|
+
#
|
920
1037
|
def clip(a, b, c, d)
|
921
1038
|
x, y, w, h = toXYWH__ @imageMode__, a, b, c, d
|
922
1039
|
@painter__.clip x, y, w, h
|
@@ -927,6 +1044,8 @@ module Processing
|
|
927
1044
|
#
|
928
1045
|
# @return [nil] nil
|
929
1046
|
#
|
1047
|
+
# @see https://processing.org/reference/noClip_.html
|
1048
|
+
#
|
930
1049
|
def noClip()
|
931
1050
|
@painter__.no_clip
|
932
1051
|
nil
|
@@ -947,6 +1066,9 @@ module Processing
|
|
947
1066
|
#
|
948
1067
|
# @return [Font] current font
|
949
1068
|
#
|
1069
|
+
# @see https://processing.org/reference/textFont_.html
|
1070
|
+
# @see https://p5js.org/reference/#/p5/textFont
|
1071
|
+
#
|
950
1072
|
def textFont(font = nil, size = nil)
|
951
1073
|
if font != nil || size != nil
|
952
1074
|
size = FONT_SIZE_MAX__ if size && size > FONT_SIZE_MAX__
|
@@ -967,25 +1089,63 @@ module Processing
|
|
967
1089
|
#
|
968
1090
|
# @return [nil] nil
|
969
1091
|
#
|
1092
|
+
# @see https://processing.org/reference/textSize_.html
|
1093
|
+
# @see https://p5js.org/reference/#/p5/textSize
|
1094
|
+
#
|
970
1095
|
def textSize(size)
|
971
1096
|
textFont @textFont__, size
|
1097
|
+
nil
|
972
1098
|
end
|
973
1099
|
|
1100
|
+
# Returns the width of the text.
|
1101
|
+
#
|
1102
|
+
# @param str [String] text string
|
1103
|
+
#
|
1104
|
+
# @return [Numeric] width of the text
|
1105
|
+
#
|
1106
|
+
# @see https://processing.org/reference/textWidth_.html
|
1107
|
+
# @see https://p5js.org/reference/#/p5/textWidth
|
1108
|
+
#
|
974
1109
|
def textWidth(str)
|
975
1110
|
@painter__.font.width str
|
976
1111
|
end
|
977
1112
|
|
1113
|
+
# Returns ascent of the current font at its current size.
|
1114
|
+
#
|
1115
|
+
# @return [Numeric] ascent
|
1116
|
+
#
|
1117
|
+
# @see https://processing.org/reference/textAscent_.html
|
1118
|
+
# @see https://p5js.org/reference/#/p5/textAscent
|
1119
|
+
#
|
978
1120
|
def textAscent()
|
979
1121
|
@painter__.font.ascent
|
980
1122
|
end
|
981
1123
|
|
1124
|
+
# Returns descent of the current font at its current size.
|
1125
|
+
#
|
1126
|
+
# @return [Numeric] descent
|
1127
|
+
#
|
1128
|
+
# @see https://processing.org/reference/textDescent_.html
|
1129
|
+
# @see https://p5js.org/reference/#/p5/textDescent
|
1130
|
+
#
|
982
1131
|
def textDescent()
|
983
1132
|
@painter__.font.descent
|
984
1133
|
end
|
985
1134
|
|
1135
|
+
# Sets the alignment for drawing text.
|
1136
|
+
#
|
1137
|
+
# @param horizontal [LEFT, CENTER, RIGHT] horizontal alignment
|
1138
|
+
# @param vertical [TOP, BOTTOM, CENTER, BASELINE] vertical alignment
|
1139
|
+
#
|
1140
|
+
# @return [nil] nil
|
1141
|
+
#
|
1142
|
+
# @see https://processing.org/reference/textAlign_.html
|
1143
|
+
# @see https://p5js.org/reference/#/p5/textAlign
|
1144
|
+
#
|
986
1145
|
def textAlign(horizontal, vertical = BASELINE)
|
987
1146
|
@textAlignH__ = horizontal
|
988
1147
|
@textAlignV__ = vertical
|
1148
|
+
nil
|
989
1149
|
end
|
990
1150
|
|
991
1151
|
# Sets the spacing between lines of text in units of pixels.
|
@@ -997,11 +1157,23 @@ module Processing
|
|
997
1157
|
#
|
998
1158
|
# @return [Numeric] current spacing
|
999
1159
|
#
|
1160
|
+
# @see https://processing.org/reference/textLeading_.html
|
1161
|
+
# @see https://p5js.org/reference/#/p5/textLeading
|
1162
|
+
#
|
1000
1163
|
def textLeading(leading = nil)
|
1001
1164
|
@painter__.line_height = leading if leading
|
1002
1165
|
@painter__.line_height
|
1003
1166
|
end
|
1004
1167
|
|
1168
|
+
# Sets texture.
|
1169
|
+
#
|
1170
|
+
# @param image [Image] texture image
|
1171
|
+
#
|
1172
|
+
# @return [nil] nil
|
1173
|
+
#
|
1174
|
+
# @see https://processing.org/reference/texture_.html
|
1175
|
+
# @see https://p5js.org/reference/#/p5/texture
|
1176
|
+
#
|
1005
1177
|
def texture(image)
|
1006
1178
|
@painter__.texture image&.getInternal__
|
1007
1179
|
nil
|
@@ -1050,6 +1222,9 @@ module Processing
|
|
1050
1222
|
#
|
1051
1223
|
# @return [nil] nil
|
1052
1224
|
#
|
1225
|
+
# @see https://processing.org/reference/shader_.html
|
1226
|
+
# @see https://p5js.org/reference/#/p5/shader
|
1227
|
+
#
|
1053
1228
|
def shader(shader)
|
1054
1229
|
@painter__.shader shader&.getInternal__
|
1055
1230
|
nil
|
@@ -1059,6 +1234,9 @@ module Processing
|
|
1059
1234
|
#
|
1060
1235
|
# @return [nil] nil
|
1061
1236
|
#
|
1237
|
+
# @see https://processing.org/reference/resetShader_.html
|
1238
|
+
# @see https://p5js.org/reference/#/p5/resetShader
|
1239
|
+
#
|
1062
1240
|
def resetShader()
|
1063
1241
|
@painter__.no_shader
|
1064
1242
|
nil
|
@@ -1074,8 +1252,14 @@ module Processing
|
|
1074
1252
|
# @param type [THRESHOLD, GRAY, INVERT, BLUR] filter type
|
1075
1253
|
# @param param [Numeric] a parameter for each filter
|
1076
1254
|
#
|
1255
|
+
# @return [nil] nil
|
1256
|
+
#
|
1257
|
+
# @see https://processing.org/reference/filter_.html
|
1258
|
+
# @see https://p5js.org/reference/#/p5/filter
|
1259
|
+
#
|
1077
1260
|
def filter(*args)
|
1078
1261
|
@filter__ = Shader.createFilter__(*args)
|
1262
|
+
nil
|
1079
1263
|
end
|
1080
1264
|
|
1081
1265
|
# Clears screen.
|
@@ -1096,6 +1280,9 @@ module Processing
|
|
1096
1280
|
#
|
1097
1281
|
# @return [nil] nil
|
1098
1282
|
#
|
1283
|
+
# @see https://processing.org/reference/background_.html
|
1284
|
+
# @see https://p5js.org/reference/#/p5/background
|
1285
|
+
#
|
1099
1286
|
def background(*args)
|
1100
1287
|
assertDrawing__
|
1101
1288
|
rgba = toRGBA__(*args)
|
@@ -1122,6 +1309,9 @@ module Processing
|
|
1122
1309
|
#
|
1123
1310
|
# @return [nil] nil
|
1124
1311
|
#
|
1312
|
+
# @see https://processing.org/reference/point_.html
|
1313
|
+
# @see https://p5js.org/reference/#/p5/point
|
1314
|
+
#
|
1125
1315
|
def point(x, y)
|
1126
1316
|
assertDrawing__
|
1127
1317
|
@painter__.point x, y
|
@@ -1139,6 +1329,9 @@ module Processing
|
|
1139
1329
|
#
|
1140
1330
|
# @return [nil] nil
|
1141
1331
|
#
|
1332
|
+
# @see https://processing.org/reference/line_.html
|
1333
|
+
# @see https://p5js.org/reference/#/p5/line
|
1334
|
+
#
|
1142
1335
|
def line(x1, y1, x2, y2)
|
1143
1336
|
assertDrawing__
|
1144
1337
|
@painter__.line x1, y1, x2, y2
|
@@ -1167,6 +1360,9 @@ module Processing
|
|
1167
1360
|
#
|
1168
1361
|
# @return [nil] nil
|
1169
1362
|
#
|
1363
|
+
# @see https://processing.org/reference/rect_.html
|
1364
|
+
# @see https://p5js.org/reference/#/p5/rect
|
1365
|
+
#
|
1170
1366
|
def rect(a, b, c, d, *args)
|
1171
1367
|
assertDrawing__
|
1172
1368
|
x, y, w, h = toXYWH__ @rectMode__, a, b, c, d
|
@@ -1192,6 +1388,9 @@ module Processing
|
|
1192
1388
|
#
|
1193
1389
|
# @return [nil] nil
|
1194
1390
|
#
|
1391
|
+
# @see https://processing.org/reference/ellipse_.html
|
1392
|
+
# @see https://p5js.org/reference/#/p5/ellipse
|
1393
|
+
#
|
1195
1394
|
def ellipse(a, b, c, d)
|
1196
1395
|
assertDrawing__
|
1197
1396
|
x, y, w, h = toXYWH__ @ellipseMode__, a, b, c, d
|
@@ -1209,6 +1408,9 @@ module Processing
|
|
1209
1408
|
#
|
1210
1409
|
# @return [nil] nil
|
1211
1410
|
#
|
1411
|
+
# @see https://processing.org/reference/circle_.html
|
1412
|
+
# @see https://p5js.org/reference/#/p5/circle
|
1413
|
+
#
|
1212
1414
|
def circle(x, y, extent)
|
1213
1415
|
ellipse x, y, extent, extent
|
1214
1416
|
end
|
@@ -1228,6 +1430,9 @@ module Processing
|
|
1228
1430
|
#
|
1229
1431
|
# @return [nil] nil
|
1230
1432
|
#
|
1433
|
+
# @see https://processing.org/reference/arc_.html
|
1434
|
+
# @see https://p5js.org/reference/#/p5/arc
|
1435
|
+
#
|
1231
1436
|
def arc(a, b, c, d, start, stop)
|
1232
1437
|
assertDrawing__
|
1233
1438
|
x, y, w, h = toXYWH__ @ellipseMode__, a, b, c, d
|
@@ -1246,6 +1451,9 @@ module Processing
|
|
1246
1451
|
#
|
1247
1452
|
# @return [nil] nil
|
1248
1453
|
#
|
1454
|
+
# @see https://processing.org/reference/square_.html
|
1455
|
+
# @see https://p5js.org/reference/#/p5/square
|
1456
|
+
#
|
1249
1457
|
def square(x, y, extent)
|
1250
1458
|
rect x, y, extent, extent
|
1251
1459
|
end
|
@@ -1263,6 +1471,9 @@ module Processing
|
|
1263
1471
|
#
|
1264
1472
|
# @return [nil] nil
|
1265
1473
|
#
|
1474
|
+
# @see https://processing.org/reference/triangle_.html
|
1475
|
+
# @see https://p5js.org/reference/#/p5/triangle
|
1476
|
+
#
|
1266
1477
|
def triangle(x1, y1, x2, y2, x3, y3)
|
1267
1478
|
assertDrawing__
|
1268
1479
|
@painter__.line x1, y1, x2, y2, x3, y3, loop: true
|
@@ -1284,6 +1495,9 @@ module Processing
|
|
1284
1495
|
#
|
1285
1496
|
# @return [nil] nil
|
1286
1497
|
#
|
1498
|
+
# @see https://processing.org/reference/quad_.html
|
1499
|
+
# @see https://p5js.org/reference/#/p5/quad
|
1500
|
+
#
|
1287
1501
|
def quad(x1, y1, x2, y2, x3, y3, x4, y4)
|
1288
1502
|
assertDrawing__
|
1289
1503
|
@painter__.line x1, y1, x2, y2, x3, y3, x4, y4, loop: true
|
@@ -1305,6 +1519,9 @@ module Processing
|
|
1305
1519
|
#
|
1306
1520
|
# @return [nil] nil
|
1307
1521
|
#
|
1522
|
+
# @see https://processing.org/reference/curve_.html
|
1523
|
+
# @see https://p5js.org/reference/#/p5/curve
|
1524
|
+
#
|
1308
1525
|
def curve(cx1, cy1, x1, y1, x2, y2, cx2, cy2)
|
1309
1526
|
assertDrawing__
|
1310
1527
|
@painter__.nsegment = @curveDetail__
|
@@ -1328,6 +1545,9 @@ module Processing
|
|
1328
1545
|
#
|
1329
1546
|
# @return [nil] nil
|
1330
1547
|
#
|
1548
|
+
# @see https://processing.org/reference/bezier_.html
|
1549
|
+
# @see https://p5js.org/reference/#/p5/bezier
|
1550
|
+
#
|
1331
1551
|
def bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2)
|
1332
1552
|
assertDrawing__
|
1333
1553
|
@painter__.nsegment = @bezierDetail__
|
@@ -1356,6 +1576,9 @@ module Processing
|
|
1356
1576
|
#
|
1357
1577
|
# @return [nil] nil
|
1358
1578
|
#
|
1579
|
+
# @see https://processing.org/reference/text_.html
|
1580
|
+
# @see https://p5js.org/reference/#/p5/text
|
1581
|
+
#
|
1359
1582
|
def text(str, x, y, x2 = nil, y2 = nil)
|
1360
1583
|
assertDrawing__
|
1361
1584
|
if x2
|
@@ -1394,6 +1617,9 @@ module Processing
|
|
1394
1617
|
#
|
1395
1618
|
# @return [nil] nil
|
1396
1619
|
#
|
1620
|
+
# @see https://processing.org/reference/image_.html
|
1621
|
+
# @see https://p5js.org/reference/#/p5/image
|
1622
|
+
#
|
1397
1623
|
def image(img, a, b, c = nil, d = nil)
|
1398
1624
|
assertDrawing__
|
1399
1625
|
x, y, w, h = toXYWH__ @imageMode__, a, b, c || img.width, d || img.height
|
@@ -1418,6 +1644,8 @@ module Processing
|
|
1418
1644
|
#
|
1419
1645
|
# @return [nil] nil
|
1420
1646
|
#
|
1647
|
+
# @see https://processing.org/reference/shape_.html
|
1648
|
+
#
|
1421
1649
|
def shape(shp, a = 0, b = 0, c = nil, d = nil)
|
1422
1650
|
assertDrawing__
|
1423
1651
|
return nil unless shp.isVisible
|
@@ -1604,6 +1832,9 @@ module Processing
|
|
1604
1832
|
#
|
1605
1833
|
# @return [nil] nil
|
1606
1834
|
#
|
1835
|
+
# @see https://processing.org/reference/copy_.html
|
1836
|
+
# @see https://p5js.org/reference/#/p5/copy
|
1837
|
+
#
|
1607
1838
|
def copy(img = nil, sx, sy, sw, sh, dx, dy, dw, dh)
|
1608
1839
|
blend img, sx, sy, sw, sh, dx, dy, dw, dh, BLEND
|
1609
1840
|
end
|
@@ -1626,6 +1857,9 @@ module Processing
|
|
1626
1857
|
#
|
1627
1858
|
# @return [nil] nil
|
1628
1859
|
#
|
1860
|
+
# @see https://processing.org/reference/blend_.html
|
1861
|
+
# @see https://p5js.org/reference/#/p5/blend
|
1862
|
+
#
|
1629
1863
|
def blend(img = nil, sx, sy, sw, sh, dx, dy, dw, dh, mode)
|
1630
1864
|
assertDrawing__
|
1631
1865
|
(img || self).drawImage__(
|
@@ -1637,6 +1871,9 @@ module Processing
|
|
1637
1871
|
#
|
1638
1872
|
# @return [nil] nil
|
1639
1873
|
#
|
1874
|
+
# @see https://processing.org/reference/loadPixels_.html
|
1875
|
+
# @see https://p5js.org/reference/#/p5/loadPixels
|
1876
|
+
#
|
1640
1877
|
def loadPixels()
|
1641
1878
|
@pixels__ = getInternal__.pixels
|
1642
1879
|
end
|
@@ -1645,6 +1882,9 @@ module Processing
|
|
1645
1882
|
#
|
1646
1883
|
# @return [nil] nil
|
1647
1884
|
#
|
1885
|
+
# @see https://processing.org/reference/updatePixels_.html
|
1886
|
+
# @see https://p5js.org/reference/#/p5/updatePixels
|
1887
|
+
#
|
1648
1888
|
def updatePixels(&block)
|
1649
1889
|
return if !block && !@pixels__
|
1650
1890
|
if block
|
@@ -1661,6 +1901,11 @@ module Processing
|
|
1661
1901
|
# An array of all pixels.
|
1662
1902
|
# Call loadPixels() before accessing the array.
|
1663
1903
|
#
|
1904
|
+
# @return [Array] color array
|
1905
|
+
#
|
1906
|
+
# @see https://processing.org/reference/pixels.html
|
1907
|
+
# @see https://p5js.org/reference/#/p5/pixels
|
1908
|
+
#
|
1664
1909
|
def pixels()
|
1665
1910
|
@pixels__
|
1666
1911
|
end
|
@@ -1671,6 +1916,9 @@ module Processing
|
|
1671
1916
|
#
|
1672
1917
|
# @return [nil] nil
|
1673
1918
|
#
|
1919
|
+
# @see https://processing.org/reference/save_.html
|
1920
|
+
# @see https://p5js.org/reference/#/p5/save
|
1921
|
+
#
|
1674
1922
|
def save(filename)
|
1675
1923
|
getInternal__.save filename
|
1676
1924
|
nil
|
@@ -1683,10 +1931,13 @@ module Processing
|
|
1683
1931
|
#
|
1684
1932
|
# @param x [Numeric] left/right translation
|
1685
1933
|
# @param y [Numeric] up/down translation
|
1686
|
-
# @param
|
1934
|
+
# @param z [Numeric] forward/backward translation
|
1687
1935
|
#
|
1688
1936
|
# @return [nil] nil
|
1689
1937
|
#
|
1938
|
+
# @see https://processing.org/reference/translate_.html
|
1939
|
+
# @see https://p5js.org/reference/#/p5/translate
|
1940
|
+
#
|
1690
1941
|
def translate(x, y, z = 0)
|
1691
1942
|
assertDrawing__
|
1692
1943
|
@painter__.translate x, y, z
|
@@ -1697,13 +1948,18 @@ module Processing
|
|
1697
1948
|
#
|
1698
1949
|
# @overload scale(s)
|
1699
1950
|
# @overload scale(x, y)
|
1951
|
+
# @overload scale(x, y, z)
|
1700
1952
|
#
|
1701
1953
|
# @param s [Numeric] horizontal and vertical scale
|
1702
1954
|
# @param x [Numeric] horizontal scale
|
1703
1955
|
# @param y [Numeric] vertical scale
|
1956
|
+
# @param z [Numeric] depth scale
|
1704
1957
|
#
|
1705
1958
|
# @return [nil] nil
|
1706
1959
|
#
|
1960
|
+
# @see https://processing.org/reference/scale_.html
|
1961
|
+
# @see https://p5js.org/reference/#/p5/scale
|
1962
|
+
#
|
1707
1963
|
def scale(x, y = nil, z = 1)
|
1708
1964
|
assertDrawing__
|
1709
1965
|
@painter__.scale x, (y || x), z
|
@@ -1716,30 +1972,69 @@ module Processing
|
|
1716
1972
|
#
|
1717
1973
|
# @return [nil] nil
|
1718
1974
|
#
|
1975
|
+
# @see https://processing.org/reference/rotate_.html
|
1976
|
+
# @see https://p5js.org/reference/#/p5/rotate
|
1977
|
+
#
|
1719
1978
|
def rotate(angle)
|
1720
1979
|
assertDrawing__
|
1721
1980
|
@painter__.rotate toDegrees__ angle
|
1722
1981
|
nil
|
1723
1982
|
end
|
1724
1983
|
|
1984
|
+
# Applies rotation around the x-axis.
|
1985
|
+
#
|
1986
|
+
# @param angle [Numeric] angle for rotation
|
1987
|
+
#
|
1988
|
+
# @return [nil] nil
|
1989
|
+
#
|
1990
|
+
# @see https://processing.org/reference/rotateX_.html
|
1991
|
+
# @see https://p5js.org/reference/#/p5/rotateX
|
1992
|
+
#
|
1725
1993
|
def rotateX(angle)
|
1726
1994
|
assertDrawing__
|
1727
1995
|
@painter__.rotate toDegrees__(angle), 1, 0, 0
|
1728
1996
|
nil
|
1729
1997
|
end
|
1730
1998
|
|
1999
|
+
# Applies rotation around the y-axis.
|
2000
|
+
#
|
2001
|
+
# @param angle [Numeric] angle for rotation
|
2002
|
+
#
|
2003
|
+
# @return [nil] nil
|
2004
|
+
#
|
2005
|
+
# @see https://processing.org/reference/rotateY_.html
|
2006
|
+
# @see https://p5js.org/reference/#/p5/rotateY
|
2007
|
+
#
|
1731
2008
|
def rotateY(angle)
|
1732
2009
|
assertDrawing__
|
1733
2010
|
@painter__.rotate toDegrees__(angle), 0, 1, 0
|
1734
2011
|
nil
|
1735
2012
|
end
|
1736
2013
|
|
2014
|
+
# Applies rotation around the z-axis.
|
2015
|
+
#
|
2016
|
+
# @param angle [Numeric] angle for rotation
|
2017
|
+
#
|
2018
|
+
# @return [nil] nil
|
2019
|
+
#
|
2020
|
+
# @see https://processing.org/reference/rotateZ_.html
|
2021
|
+
# @see https://p5js.org/reference/#/p5/rotateZ
|
2022
|
+
#
|
1737
2023
|
def rotateZ(angle)
|
1738
2024
|
assertDrawing__
|
1739
2025
|
@painter__.rotate toDegrees__(angle), 0, 0, 1
|
1740
2026
|
nil
|
1741
2027
|
end
|
1742
2028
|
|
2029
|
+
# Applies shear around the x-axis.
|
2030
|
+
#
|
2031
|
+
# @param angle [Numeric] angle for shearing
|
2032
|
+
#
|
2033
|
+
# @return [nil] nil
|
2034
|
+
#
|
2035
|
+
# @see https://processing.org/reference/shearX_.html
|
2036
|
+
# @see https://p5js.org/reference/#/p5/shearX
|
2037
|
+
#
|
1743
2038
|
def shearX(angle)
|
1744
2039
|
t = Math.tan toRadians__(angle)
|
1745
2040
|
@painter__.matrix *= Rays::Matrix.new(
|
@@ -1747,8 +2042,18 @@ module Processing
|
|
1747
2042
|
0, 1, 0, 0,
|
1748
2043
|
0, 0, 1, 0,
|
1749
2044
|
0, 0, 0, 1)
|
2045
|
+
nil
|
1750
2046
|
end
|
1751
2047
|
|
2048
|
+
# Applies shear around the y-axis.
|
2049
|
+
#
|
2050
|
+
# @param angle [Numeric] angle for shearing
|
2051
|
+
#
|
2052
|
+
# @return [nil] nil
|
2053
|
+
#
|
2054
|
+
# @see https://processing.org/reference/shearY_.html
|
2055
|
+
# @see https://p5js.org/reference/#/p5/shearY
|
2056
|
+
#
|
1752
2057
|
def shearY(angle)
|
1753
2058
|
t = Math.tan toRadians__(angle)
|
1754
2059
|
@painter__.matrix *= Rays::Matrix.new(
|
@@ -1756,12 +2061,15 @@ module Processing
|
|
1756
2061
|
t, 1, 0, 0,
|
1757
2062
|
0, 0, 1, 0,
|
1758
2063
|
0, 0, 0, 1)
|
2064
|
+
nil
|
1759
2065
|
end
|
1760
2066
|
|
1761
2067
|
# Pushes the current transformation matrix to stack.
|
1762
2068
|
#
|
1763
2069
|
# @return [Object] result of the expression at the end of the block
|
1764
2070
|
#
|
2071
|
+
# @see https://processing.org/reference/pushMatrix_.html
|
2072
|
+
#
|
1765
2073
|
def pushMatrix(&block)
|
1766
2074
|
assertDrawing__
|
1767
2075
|
@matrixStack__.push @painter__.matrix
|
@@ -1774,6 +2082,8 @@ module Processing
|
|
1774
2082
|
#
|
1775
2083
|
# @return [nil] nil
|
1776
2084
|
#
|
2085
|
+
# @see https://processing.org/reference/popMatrix_.html
|
2086
|
+
#
|
1777
2087
|
def popMatrix()
|
1778
2088
|
assertDrawing__
|
1779
2089
|
raise "matrix stack underflow" if @matrixStack__.empty?
|
@@ -1807,6 +2117,9 @@ module Processing
|
|
1807
2117
|
#
|
1808
2118
|
# @return [nil] nil
|
1809
2119
|
#
|
2120
|
+
# @see https://processing.org/reference/applyMatrix_.html
|
2121
|
+
# @see https://p5js.org/reference/#/p5/applyMatrix
|
2122
|
+
#
|
1810
2123
|
def applyMatrix(*args)
|
1811
2124
|
assertDrawing__
|
1812
2125
|
args = args.first if args.first.kind_of?(Array)
|
@@ -1830,6 +2143,9 @@ module Processing
|
|
1830
2143
|
#
|
1831
2144
|
# @return [nil] nil
|
1832
2145
|
#
|
2146
|
+
# @see https://processing.org/reference/resetMatrix_.html
|
2147
|
+
# @see https://p5js.org/reference/#/p5/resetMatrix
|
2148
|
+
#
|
1833
2149
|
def resetMatrix()
|
1834
2150
|
assertDrawing__
|
1835
2151
|
@painter__.matrix = 1
|
@@ -1840,6 +2156,8 @@ module Processing
|
|
1840
2156
|
#
|
1841
2157
|
# @return [nil] nil
|
1842
2158
|
#
|
2159
|
+
# @see https://processing.org/reference/printMatrix_.html
|
2160
|
+
#
|
1843
2161
|
def printMatrix()
|
1844
2162
|
m = @painter__.matrix
|
1845
2163
|
m.transpose! if @p5jsMode__
|
@@ -1851,6 +2169,8 @@ module Processing
|
|
1851
2169
|
#
|
1852
2170
|
# @return [Object] result of the expression at the end of the block
|
1853
2171
|
#
|
2172
|
+
# @see https://processing.org/reference/pushStyle_.html
|
2173
|
+
#
|
1854
2174
|
def pushStyle(&block)
|
1855
2175
|
assertDrawing__
|
1856
2176
|
@styleStack__.push [
|
@@ -1898,6 +2218,8 @@ module Processing
|
|
1898
2218
|
#
|
1899
2219
|
# @return [nil] nil
|
1900
2220
|
#
|
2221
|
+
# @see https://processing.org/reference/popStyle_.html
|
2222
|
+
#
|
1901
2223
|
def popStyle()
|
1902
2224
|
assertDrawing__
|
1903
2225
|
raise "style stack underflow" if @styleStack__.empty?
|
@@ -1943,6 +2265,9 @@ module Processing
|
|
1943
2265
|
#
|
1944
2266
|
# @return [Object] result of the expression at the end of the block
|
1945
2267
|
#
|
2268
|
+
# @see https://processing.org/reference/push_.html
|
2269
|
+
# @see https://p5js.org/reference/#/p5/push
|
2270
|
+
#
|
1946
2271
|
def push(&block)
|
1947
2272
|
pushMatrix
|
1948
2273
|
pushStyle
|
@@ -1955,6 +2280,9 @@ module Processing
|
|
1955
2280
|
#
|
1956
2281
|
# @return [nil] nil
|
1957
2282
|
#
|
2283
|
+
# @see https://processing.org/reference/pop_.html
|
2284
|
+
# @see https://p5js.org/reference/#/p5/pop
|
2285
|
+
#
|
1958
2286
|
def pop()
|
1959
2287
|
popMatrix
|
1960
2288
|
popStyle
|
@@ -1988,6 +2316,9 @@ module Processing
|
|
1988
2316
|
#
|
1989
2317
|
# @return [Numeric] absolute number
|
1990
2318
|
#
|
2319
|
+
# @see https://processing.org/reference/abs_.html
|
2320
|
+
# @see https://p5js.org/reference/#/p5/abs
|
2321
|
+
#
|
1991
2322
|
def abs(value)
|
1992
2323
|
value.abs
|
1993
2324
|
end
|
@@ -1998,6 +2329,9 @@ module Processing
|
|
1998
2329
|
#
|
1999
2330
|
# @return [Numeric] rounded up number
|
2000
2331
|
#
|
2332
|
+
# @see https://processing.org/reference/ceil_.html
|
2333
|
+
# @see https://p5js.org/reference/#/p5/ceil
|
2334
|
+
#
|
2001
2335
|
def ceil(value)
|
2002
2336
|
value.ceil
|
2003
2337
|
end
|
@@ -2008,6 +2342,9 @@ module Processing
|
|
2008
2342
|
#
|
2009
2343
|
# @return [Numeric] rounded down number
|
2010
2344
|
#
|
2345
|
+
# @see https://processing.org/reference/floor_.html
|
2346
|
+
# @see https://p5js.org/reference/#/p5/floor
|
2347
|
+
#
|
2011
2348
|
def floor(value)
|
2012
2349
|
value.floor
|
2013
2350
|
end
|
@@ -2018,6 +2355,9 @@ module Processing
|
|
2018
2355
|
#
|
2019
2356
|
# @return [Numeric] rounded number
|
2020
2357
|
#
|
2358
|
+
# @see https://processing.org/reference/round_.html
|
2359
|
+
# @see https://p5js.org/reference/#/p5/round
|
2360
|
+
#
|
2021
2361
|
def round(value)
|
2022
2362
|
value.round
|
2023
2363
|
end
|
@@ -2028,6 +2368,9 @@ module Processing
|
|
2028
2368
|
#
|
2029
2369
|
# @return [Numeric] result number
|
2030
2370
|
#
|
2371
|
+
# @see https://processing.org/reference/log_.html
|
2372
|
+
# @see https://p5js.org/reference/#/p5/log
|
2373
|
+
#
|
2031
2374
|
def log(n)
|
2032
2375
|
Math.log n
|
2033
2376
|
end
|
@@ -2038,6 +2381,9 @@ module Processing
|
|
2038
2381
|
#
|
2039
2382
|
# @return [Numeric] result number
|
2040
2383
|
#
|
2384
|
+
# @see https://processing.org/reference/exp_.html
|
2385
|
+
# @see https://p5js.org/reference/#/p5/exp
|
2386
|
+
#
|
2041
2387
|
def exp(n)
|
2042
2388
|
Math.exp n
|
2043
2389
|
end
|
@@ -2049,6 +2395,9 @@ module Processing
|
|
2049
2395
|
#
|
2050
2396
|
# @return [Numeric] value ** exponent
|
2051
2397
|
#
|
2398
|
+
# @see https://processing.org/reference/pow_.html
|
2399
|
+
# @see https://p5js.org/reference/#/p5/pow
|
2400
|
+
#
|
2052
2401
|
def pow(value, exponent)
|
2053
2402
|
value ** exponent
|
2054
2403
|
end
|
@@ -2059,6 +2408,9 @@ module Processing
|
|
2059
2408
|
#
|
2060
2409
|
# @return [Numeric] squared value
|
2061
2410
|
#
|
2411
|
+
# @see https://processing.org/reference/sq_.html
|
2412
|
+
# @see https://p5js.org/reference/#/p5/sq
|
2413
|
+
#
|
2062
2414
|
def sq(value)
|
2063
2415
|
value * value
|
2064
2416
|
end
|
@@ -2069,6 +2421,9 @@ module Processing
|
|
2069
2421
|
#
|
2070
2422
|
# @return [Numeric] squared value
|
2071
2423
|
#
|
2424
|
+
# @see https://processing.org/reference/sqrt_.html
|
2425
|
+
# @see https://p5js.org/reference/#/p5/sqrt
|
2426
|
+
#
|
2072
2427
|
def sqrt(value)
|
2073
2428
|
Math.sqrt value
|
2074
2429
|
end
|
@@ -2084,6 +2439,9 @@ module Processing
|
|
2084
2439
|
#
|
2085
2440
|
# @return [Numeric] magnitude
|
2086
2441
|
#
|
2442
|
+
# @see https://processing.org/reference/mag_.html
|
2443
|
+
# @see https://p5js.org/reference/#/p5/mag
|
2444
|
+
#
|
2087
2445
|
def mag(*args)
|
2088
2446
|
x, y, z = *args
|
2089
2447
|
case args.size
|
@@ -2107,6 +2465,9 @@ module Processing
|
|
2107
2465
|
#
|
2108
2466
|
# @return [Numeric] distance between 2 points
|
2109
2467
|
#
|
2468
|
+
# @see https://processing.org/reference/dist_.html
|
2469
|
+
# @see https://p5js.org/reference/#/p5/dist
|
2470
|
+
#
|
2110
2471
|
def dist(*args)
|
2111
2472
|
case args.size
|
2112
2473
|
when 4
|
@@ -2129,6 +2490,9 @@ module Processing
|
|
2129
2490
|
#
|
2130
2491
|
# @return [Numeric] normalized value between 0..1
|
2131
2492
|
#
|
2493
|
+
# @see https://processing.org/reference/norm_.html
|
2494
|
+
# @see https://p5js.org/reference/#/p5/norm
|
2495
|
+
#
|
2132
2496
|
def norm(value, start, stop)
|
2133
2497
|
(value.to_f - start.to_f) / (stop.to_f - start.to_f)
|
2134
2498
|
end
|
@@ -2141,6 +2505,9 @@ module Processing
|
|
2141
2505
|
#
|
2142
2506
|
# @return [Numeric] interporated number
|
2143
2507
|
#
|
2508
|
+
# @see https://processing.org/reference/lerp_.html
|
2509
|
+
# @see https://p5js.org/reference/#/p5/lerp
|
2510
|
+
#
|
2144
2511
|
def lerp(start, stop, amount)
|
2145
2512
|
start + (stop - start) * amount
|
2146
2513
|
end
|
@@ -2153,6 +2520,9 @@ module Processing
|
|
2153
2520
|
#
|
2154
2521
|
# @return [Integer] interporated color
|
2155
2522
|
#
|
2523
|
+
# @see https://processing.org/reference/lerpColor_.html
|
2524
|
+
# @see https://p5js.org/reference/#/p5/lerpColor
|
2525
|
+
#
|
2156
2526
|
def lerpColor(color1, color2, amount)
|
2157
2527
|
color(
|
2158
2528
|
lerp(red( color1), red( color2), amount),
|
@@ -2171,6 +2541,9 @@ module Processing
|
|
2171
2541
|
#
|
2172
2542
|
# @return [Numeric] mapped number
|
2173
2543
|
#
|
2544
|
+
# @see https://processing.org/reference/map_.html
|
2545
|
+
# @see https://p5js.org/reference/#/p5/map
|
2546
|
+
#
|
2174
2547
|
def map(value, start1, stop1, start2, stop2)
|
2175
2548
|
lerp start2, stop2, norm(value, start1, stop1)
|
2176
2549
|
end
|
@@ -2188,6 +2561,9 @@ module Processing
|
|
2188
2561
|
#
|
2189
2562
|
# @return [Numeric] minimum value
|
2190
2563
|
#
|
2564
|
+
# @see https://processing.org/reference/min_.html
|
2565
|
+
# @see https://p5js.org/reference/#/p5/min
|
2566
|
+
#
|
2191
2567
|
def min(*args)
|
2192
2568
|
args.flatten.min
|
2193
2569
|
end
|
@@ -2205,6 +2581,9 @@ module Processing
|
|
2205
2581
|
#
|
2206
2582
|
# @return [Numeric] maximum value
|
2207
2583
|
#
|
2584
|
+
# @see https://processing.org/reference/max_.html
|
2585
|
+
# @see https://p5js.org/reference/#/p5/max
|
2586
|
+
#
|
2208
2587
|
def max(*args)
|
2209
2588
|
args.flatten.max
|
2210
2589
|
end
|
@@ -2217,6 +2596,9 @@ module Processing
|
|
2217
2596
|
#
|
2218
2597
|
# @return [Numeric] constrained number
|
2219
2598
|
#
|
2599
|
+
# @see https://processing.org/reference/constrain_.html
|
2600
|
+
# @see https://p5js.org/reference/#/p5/constrain
|
2601
|
+
#
|
2220
2602
|
def constrain(value, min, max)
|
2221
2603
|
value < min ? min : (value > max ? max : value)
|
2222
2604
|
end
|
@@ -2227,6 +2609,9 @@ module Processing
|
|
2227
2609
|
#
|
2228
2610
|
# @return [Numeric] radian
|
2229
2611
|
#
|
2612
|
+
# @see https://processing.org/reference/radians_.html
|
2613
|
+
# @see https://p5js.org/reference/#/p5/radians
|
2614
|
+
#
|
2230
2615
|
def radians(degree)
|
2231
2616
|
degree * DEG2RAD__
|
2232
2617
|
end
|
@@ -2237,6 +2622,9 @@ module Processing
|
|
2237
2622
|
#
|
2238
2623
|
# @return [Numeric] degree
|
2239
2624
|
#
|
2625
|
+
# @see https://processing.org/reference/degrees_.html
|
2626
|
+
# @see https://p5js.org/reference/#/p5/degrees
|
2627
|
+
#
|
2240
2628
|
def degrees(radian)
|
2241
2629
|
radian * RAD2DEG__
|
2242
2630
|
end
|
@@ -2247,6 +2635,9 @@ module Processing
|
|
2247
2635
|
#
|
2248
2636
|
# @return [Numeric] the sine
|
2249
2637
|
#
|
2638
|
+
# @see https://processing.org/reference/sin_.html
|
2639
|
+
# @see https://p5js.org/reference/#/p5/sin
|
2640
|
+
#
|
2250
2641
|
def sin(angle)
|
2251
2642
|
Math.sin angle
|
2252
2643
|
end
|
@@ -2257,6 +2648,9 @@ module Processing
|
|
2257
2648
|
#
|
2258
2649
|
# @return [Numeric] the cosine
|
2259
2650
|
#
|
2651
|
+
# @see https://processing.org/reference/cos_.html
|
2652
|
+
# @see https://p5js.org/reference/#/p5/cos
|
2653
|
+
#
|
2260
2654
|
def cos(angle)
|
2261
2655
|
Math.cos angle
|
2262
2656
|
end
|
@@ -2267,6 +2661,9 @@ module Processing
|
|
2267
2661
|
#
|
2268
2662
|
# @return [Numeric] the tangent
|
2269
2663
|
#
|
2664
|
+
# @see https://processing.org/reference/tan_.html
|
2665
|
+
# @see https://p5js.org/reference/#/p5/tan
|
2666
|
+
#
|
2270
2667
|
def tan(angle)
|
2271
2668
|
Math.tan angle
|
2272
2669
|
end
|
@@ -2277,6 +2674,9 @@ module Processing
|
|
2277
2674
|
#
|
2278
2675
|
# @return [Numeric] the arc sine
|
2279
2676
|
#
|
2677
|
+
# @see https://processing.org/reference/asin_.html
|
2678
|
+
# @see https://p5js.org/reference/#/p5/asin
|
2679
|
+
#
|
2280
2680
|
def asin(value)
|
2281
2681
|
Math.asin value
|
2282
2682
|
end
|
@@ -2287,6 +2687,9 @@ module Processing
|
|
2287
2687
|
#
|
2288
2688
|
# @return [Numeric] the arc cosine
|
2289
2689
|
#
|
2690
|
+
# @see https://processing.org/reference/acos_.html
|
2691
|
+
# @see https://p5js.org/reference/#/p5/acos
|
2692
|
+
#
|
2290
2693
|
def acos(value)
|
2291
2694
|
Math.acos value
|
2292
2695
|
end
|
@@ -2297,6 +2700,9 @@ module Processing
|
|
2297
2700
|
#
|
2298
2701
|
# @return [Numeric] the arc tangent
|
2299
2702
|
#
|
2703
|
+
# @see https://processing.org/reference/atan_.html
|
2704
|
+
# @see https://p5js.org/reference/#/p5/atan
|
2705
|
+
#
|
2300
2706
|
def atan(value)
|
2301
2707
|
Math.atan value
|
2302
2708
|
end
|
@@ -2308,6 +2714,9 @@ module Processing
|
|
2308
2714
|
#
|
2309
2715
|
# @return [Numeric] the angle in radians
|
2310
2716
|
#
|
2717
|
+
# @see https://processing.org/reference/atan2_.html
|
2718
|
+
# @see https://p5js.org/reference/#/p5/atan2
|
2719
|
+
#
|
2311
2720
|
def atan2(y, x)
|
2312
2721
|
Math.atan2 y, x
|
2313
2722
|
end
|
@@ -2540,6 +2949,8 @@ module Processing
|
|
2540
2949
|
#
|
2541
2950
|
# @return [Vector] new vector
|
2542
2951
|
#
|
2952
|
+
# @see https://p5js.org/reference/#/p5/createVector
|
2953
|
+
#
|
2543
2954
|
def createVector(*args)
|
2544
2955
|
Vector.new(*args, context: self)
|
2545
2956
|
end
|
@@ -2549,6 +2960,10 @@ module Processing
|
|
2549
2960
|
# @param name [String] font name
|
2550
2961
|
# @param size [Numeric] font size (max 256)
|
2551
2962
|
#
|
2963
|
+
# @return [Font] new font
|
2964
|
+
#
|
2965
|
+
# @see https://processing.org/reference/createFont_.html
|
2966
|
+
#
|
2552
2967
|
def createFont(name, size)
|
2553
2968
|
size = FONT_SIZE_MAX__ if size && size > FONT_SIZE_MAX__
|
2554
2969
|
Font.new Rays::Font.new(name, size || FONT_SIZE_DEFAULT__)
|
@@ -2565,6 +2980,9 @@ module Processing
|
|
2565
2980
|
#
|
2566
2981
|
# @return [Image] new image
|
2567
2982
|
#
|
2983
|
+
# @see https://processing.org/reference/createImage_.html
|
2984
|
+
# @see https://p5js.org/reference/#/p5/createImage
|
2985
|
+
#
|
2568
2986
|
def createImage(w, h, format = RGBA)
|
2569
2987
|
colorspace = {RGB => Rays::RGB, RGBA => Rays::RGBA}[format]
|
2570
2988
|
raise ArgumentError, "Unknown image format" unless colorspace
|
@@ -2584,6 +3002,10 @@ module Processing
|
|
2584
3002
|
#
|
2585
3003
|
# @param kind [LINE, RECT, ELLIPSE, ARC, TRIANGLE, QUAD, GROUP]
|
2586
3004
|
#
|
3005
|
+
# @return [Shape] new shape
|
3006
|
+
#
|
3007
|
+
# @see https://processing.org/reference/createShape_.html
|
3008
|
+
#
|
2587
3009
|
def createShape(kind = nil, *args)
|
2588
3010
|
case kind
|
2589
3011
|
when LINE then createLineShape__( *args)
|
@@ -2640,6 +3062,9 @@ module Processing
|
|
2640
3062
|
#
|
2641
3063
|
# @return [Graphics] graphics object
|
2642
3064
|
#
|
3065
|
+
# @see https://processing.org/reference/createGraphics_.html
|
3066
|
+
# @see https://p5js.org/reference/#/p5/createGraphics
|
3067
|
+
#
|
2643
3068
|
def createGraphics(width, height, pixelDensity = 1)
|
2644
3069
|
Graphics.new width, height, pixelDensity
|
2645
3070
|
end
|
@@ -2676,6 +3101,8 @@ module Processing
|
|
2676
3101
|
#
|
2677
3102
|
# @return [Shader] shader object
|
2678
3103
|
#
|
3104
|
+
# @see https://p5js.org/reference/#/p5/createShader
|
3105
|
+
#
|
2679
3106
|
def createShader(vert, frag)
|
2680
3107
|
vert = File.read if vert && File.exist?(vert)
|
2681
3108
|
frag = File.read if frag && File.exist?(frag)
|
@@ -2757,6 +3184,9 @@ module Processing
|
|
2757
3184
|
#
|
2758
3185
|
# @return [Shader] loaded shader object
|
2759
3186
|
#
|
3187
|
+
# @see https://processing.org/reference/loadShader_.html
|
3188
|
+
# @see https://p5js.org/reference/#/p5/loadShader
|
3189
|
+
#
|
2760
3190
|
def loadShader(fragPath, vertPath = nil)
|
2761
3191
|
createShader vertPath, fragPath
|
2762
3192
|
end
|