processing 1.1 → 1.1.2
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/.github/workflows/utils.rb +1 -1
- data/ChangeLog.md +14 -0
- data/Gemfile.lock +2 -4
- data/LICENSE +1 -1
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/lib/processing/context.rb +43 -43
- data/lib/processing/font.rb +2 -2
- data/lib/processing/graphics.rb +4 -3
- data/lib/processing/graphics_context.rb +125 -125
- data/lib/processing/image.rb +13 -13
- data/lib/processing/shader.rb +2 -2
- data/lib/processing/shape.rb +6 -6
- data/lib/processing/svg.rb +2 -2
- data/lib/processing/vector.rb +42 -42
- data/lib/processing/window.rb +15 -8
- data/lib/processing.rb +10 -8
- data/processing.gemspec +5 -5
- metadata +34 -10
data/lib/processing/image.rb
CHANGED
@@ -4,7 +4,7 @@ module Processing
|
|
4
4
|
# Image object.
|
5
5
|
#
|
6
6
|
# @see https://processing.org/reference/PImage.html
|
7
|
-
# @see https://p5js.org/reference
|
7
|
+
# @see https://p5js.org/reference/p5/p5.Image/
|
8
8
|
#
|
9
9
|
class Image
|
10
10
|
|
@@ -21,7 +21,7 @@ module Processing
|
|
21
21
|
# @return [Numeric] width of image
|
22
22
|
#
|
23
23
|
# @see https://processing.org/reference/PImage_width.html
|
24
|
-
# @see https://p5js.org/reference
|
24
|
+
# @see https://p5js.org/reference/p5.Image/width/
|
25
25
|
#
|
26
26
|
def width()
|
27
27
|
@image&.width || (@error ? -1 : 0)
|
@@ -32,7 +32,7 @@ module Processing
|
|
32
32
|
# @return [Numeric] height of image
|
33
33
|
#
|
34
34
|
# @see https://processing.org/reference/PImage_height.html
|
35
|
-
# @see https://p5js.org/reference
|
35
|
+
# @see https://p5js.org/reference/p5.Image/height/
|
36
36
|
#
|
37
37
|
def height()
|
38
38
|
@image&.height || (@error ? -1 : 0)
|
@@ -58,7 +58,7 @@ module Processing
|
|
58
58
|
# @return [nil] nil
|
59
59
|
#
|
60
60
|
# @see https://processing.org/reference/PImage_set_.html
|
61
|
-
# @see https://p5js.org/reference
|
61
|
+
# @see https://p5js.org/reference/p5.Image/set/
|
62
62
|
#
|
63
63
|
def set(x, y, c)
|
64
64
|
getInternal__.bitmap(true)[x, y] = self.class.fromColor__(c).map {|n| n / 255.0}
|
@@ -70,7 +70,7 @@ module Processing
|
|
70
70
|
# @return [Integer] color value (0xAARRGGBB)
|
71
71
|
#
|
72
72
|
# @see https://processing.org/reference/PImage_get_.html
|
73
|
-
# @see https://p5js.org/reference
|
73
|
+
# @see https://p5js.org/reference/p5.Image/get/
|
74
74
|
#
|
75
75
|
def get(x, y)
|
76
76
|
getInternal__.bitmap[x, y]
|
@@ -83,7 +83,7 @@ module Processing
|
|
83
83
|
# @return [nil] nil
|
84
84
|
#
|
85
85
|
# @see https://processing.org/reference/PImage_loadPixels_.html
|
86
|
-
# @see https://p5js.org/reference
|
86
|
+
# @see https://p5js.org/reference/p5.Image/loadPixels/
|
87
87
|
#
|
88
88
|
def loadPixels()
|
89
89
|
@pixels = getInternal__.pixels
|
@@ -94,7 +94,7 @@ module Processing
|
|
94
94
|
# @return [nil] nil
|
95
95
|
#
|
96
96
|
# @see https://processing.org/reference/PImage_updatePixels_.html
|
97
|
-
# @see https://p5js.org/reference
|
97
|
+
# @see https://p5js.org/reference/p5.Image/updatePixels/
|
98
98
|
#
|
99
99
|
def updatePixels()
|
100
100
|
return unless @pixels
|
@@ -108,7 +108,7 @@ module Processing
|
|
108
108
|
# @return [Array] color array
|
109
109
|
#
|
110
110
|
# @see https://processing.org/reference/PImage_pixels.html
|
111
|
-
# @see https://p5js.org/reference
|
111
|
+
# @see https://p5js.org/reference/p5.Image/pixels/
|
112
112
|
#
|
113
113
|
attr_reader :pixels
|
114
114
|
|
@@ -123,7 +123,7 @@ module Processing
|
|
123
123
|
# @param param [Numeric] a parameter for each filter
|
124
124
|
#
|
125
125
|
# @see https://processing.org/reference/PImage_filter_.html
|
126
|
-
# @see https://p5js.org/reference
|
126
|
+
# @see https://p5js.org/reference/p5.Image/filter/
|
127
127
|
#
|
128
128
|
def filter(*args)
|
129
129
|
@filter = Shader.createFilter__(*args)
|
@@ -137,7 +137,7 @@ module Processing
|
|
137
137
|
# @return [nil] nil
|
138
138
|
#
|
139
139
|
# @see https://processing.org/reference/PImage_resize_.html
|
140
|
-
# @see https://p5js.org/reference
|
140
|
+
# @see https://p5js.org/reference/p5.Image/resize/
|
141
141
|
#
|
142
142
|
def resize(width, height)
|
143
143
|
@image = Rays::Image.new(width, height).paint do |painter|
|
@@ -164,7 +164,7 @@ module Processing
|
|
164
164
|
# @return [nil] nil
|
165
165
|
#
|
166
166
|
# @see https://processing.org/reference/PImage_copy_.html
|
167
|
-
# @see https://p5js.org/reference
|
167
|
+
# @see https://p5js.org/reference/p5.Image/copy/
|
168
168
|
#
|
169
169
|
def copy(img = nil, sx, sy, sw, sh, dx, dy, dw, dh)
|
170
170
|
blend img, sx, sy, sw, sh, dx, dy, dw, dh, :normal
|
@@ -194,7 +194,7 @@ module Processing
|
|
194
194
|
# @return [nil] nil
|
195
195
|
#
|
196
196
|
# @see https://processing.org/reference/PImage_blend_.html
|
197
|
-
# @see https://p5js.org/reference
|
197
|
+
# @see https://p5js.org/reference/p5.Image/blend/
|
198
198
|
#
|
199
199
|
def blend(img = nil, sx, sy, sw, sh, dx, dy, dw, dh, mode)
|
200
200
|
img ||= self
|
@@ -251,7 +251,7 @@ module Processing
|
|
251
251
|
# @return [nil] nil
|
252
252
|
#
|
253
253
|
# @see https://processing.org/reference/PImage_save_.html
|
254
|
-
# @see https://p5js.org/reference
|
254
|
+
# @see https://p5js.org/reference/p5.Image/save/
|
255
255
|
#
|
256
256
|
def save(filename)
|
257
257
|
getInternal__.save filename
|
data/lib/processing/shader.rb
CHANGED
@@ -4,7 +4,7 @@ module Processing
|
|
4
4
|
# Shader object.
|
5
5
|
#
|
6
6
|
# @see https://processing.org/reference/PShader.html
|
7
|
-
# @see https://p5js.org/reference
|
7
|
+
# @see https://p5js.org/reference/p5/p5.Shader/
|
8
8
|
#
|
9
9
|
class Shader
|
10
10
|
|
@@ -41,7 +41,7 @@ module Processing
|
|
41
41
|
# @param tex [Image] texture image
|
42
42
|
#
|
43
43
|
# @see https://processing.org/reference/PShader_set_.html
|
44
|
-
# @see https://p5js.org/reference
|
44
|
+
# @see https://p5js.org/reference/p5.Shader/setUniform/
|
45
45
|
#
|
46
46
|
def set(name, *args)
|
47
47
|
arg = args.first
|
data/lib/processing/shape.rb
CHANGED
@@ -148,7 +148,7 @@ module Processing
|
|
148
148
|
# @return [nil] nil
|
149
149
|
#
|
150
150
|
# @see https://processing.org/reference/vertex_.html
|
151
|
-
# @see https://p5js.org/reference
|
151
|
+
# @see https://p5js.org/reference/p5/vertex/
|
152
152
|
#
|
153
153
|
def vertex(x, y, u = nil, v = nil)
|
154
154
|
raise "vertex() must be called after beginShape()" unless drawingShape__
|
@@ -176,7 +176,7 @@ module Processing
|
|
176
176
|
# @return [nil] nil
|
177
177
|
#
|
178
178
|
# @see https://processing.org/reference/curveVertex_.html
|
179
|
-
# @see https://p5js.org/reference
|
179
|
+
# @see https://p5js.org/reference/p5/curveVertex/
|
180
180
|
#
|
181
181
|
def curveVertex(x, y)
|
182
182
|
raise "curveVertex() must be called after beginShape()" unless drawingShape__
|
@@ -197,7 +197,7 @@ module Processing
|
|
197
197
|
# @return [nil] nil
|
198
198
|
#
|
199
199
|
# @see https://processing.org/reference/bezierVertex_.html
|
200
|
-
# @see https://p5js.org/reference
|
200
|
+
# @see https://p5js.org/reference/p5/bezierVertex/
|
201
201
|
#
|
202
202
|
def bezierVertex(x2, y2, x3, y3, x4, y4)
|
203
203
|
raise "bezierVertex() must be called after beginShape()" unless drawingShape__
|
@@ -217,7 +217,7 @@ module Processing
|
|
217
217
|
# @return [nil] nil
|
218
218
|
#
|
219
219
|
# @see https://processing.org/reference/quadraticVertex_.html
|
220
|
-
# @see https://p5js.org/reference
|
220
|
+
# @see https://p5js.org/reference/p5/quadraticVertex/
|
221
221
|
#
|
222
222
|
def quadraticVertex(cx, cy, x3, y3)
|
223
223
|
x1, y1 = @points[-2, 2]
|
@@ -255,7 +255,7 @@ module Processing
|
|
255
255
|
# @return [nil] nil
|
256
256
|
#
|
257
257
|
# @see https://processing.org/reference/fill_.html
|
258
|
-
# @see https://p5js.org/reference
|
258
|
+
# @see https://p5js.org/reference/p5/fill/
|
259
259
|
#
|
260
260
|
def fill(*args)
|
261
261
|
@fill = @context.toRawColor__(*args)
|
@@ -278,7 +278,7 @@ module Processing
|
|
278
278
|
# @return [nil] nil
|
279
279
|
#
|
280
280
|
# @see https://processing.org/reference/stroke_.html
|
281
|
-
# @see https://p5js.org/reference
|
281
|
+
# @see https://p5js.org/reference/p5/stroke/
|
282
282
|
#
|
283
283
|
def stroke(*args)
|
284
284
|
@stroke = @context.toRawColor__(*args)
|
data/lib/processing/svg.rb
CHANGED
@@ -201,8 +201,8 @@ module Processing
|
|
201
201
|
lastX, lastY = nextPos scanner, lastX, lastY, relative
|
202
202
|
child.bezierVertex cx, cy, lastCX, lastCY, lastX, lastY
|
203
203
|
when 'A', 'a'
|
204
|
-
|
205
|
-
|
204
|
+
_rx, _ry = nextPos scanner
|
205
|
+
_a, _b, _c = nextNum(scanner), nextNum(scanner), nextNum(scanner)
|
206
206
|
lastX, lastY = nextPos scanner, lastX, lastY, command == 'a'
|
207
207
|
child.vertex lastX, lastY
|
208
208
|
when 'Z', 'z'
|
data/lib/processing/vector.rb
CHANGED
@@ -4,7 +4,7 @@ module Processing
|
|
4
4
|
# Vector class.
|
5
5
|
#
|
6
6
|
# @see https://processing.org/reference/PVector.html
|
7
|
-
# @see https://p5js.org/reference
|
7
|
+
# @see https://p5js.org/reference/p5/p5.Vector/
|
8
8
|
#
|
9
9
|
class Vector
|
10
10
|
|
@@ -26,7 +26,7 @@ module Processing
|
|
26
26
|
# @param a [Array] array like [x, y, z]
|
27
27
|
#
|
28
28
|
# @see https://processing.org/reference/PVector.html
|
29
|
-
# @see https://p5js.org/reference
|
29
|
+
# @see https://p5js.org/reference/p5/p5.Vector/
|
30
30
|
#
|
31
31
|
def initialize(x = 0, y = 0, z = 0, context: nil)
|
32
32
|
@point = case x
|
@@ -49,7 +49,7 @@ module Processing
|
|
49
49
|
# @return [Vector] duplicated vector object
|
50
50
|
#
|
51
51
|
# @see https://processing.org/reference/PVector_copy_.html
|
52
|
-
# @see https://p5js.org/reference
|
52
|
+
# @see https://p5js.org/reference/p5.Vector/copy/
|
53
53
|
#
|
54
54
|
alias copy dup
|
55
55
|
|
@@ -70,7 +70,7 @@ module Processing
|
|
70
70
|
# @return [nil] nil
|
71
71
|
#
|
72
72
|
# @see https://processing.org/reference/PVector_set_.html
|
73
|
-
# @see https://p5js.org/reference
|
73
|
+
# @see https://p5js.org/reference/p5.Vector/set/
|
74
74
|
#
|
75
75
|
def set(*args)
|
76
76
|
initialize(*args)
|
@@ -82,7 +82,7 @@ module Processing
|
|
82
82
|
# @return [Numeric] x value of vector
|
83
83
|
#
|
84
84
|
# @see https://processing.org/reference/PVector_x.html
|
85
|
-
# @see https://p5js.org/reference
|
85
|
+
# @see https://p5js.org/reference/p5.Vector/x/
|
86
86
|
#
|
87
87
|
def x()
|
88
88
|
@point.x
|
@@ -93,7 +93,7 @@ module Processing
|
|
93
93
|
# @return [Numeric] y value of vector
|
94
94
|
#
|
95
95
|
# @see https://processing.org/reference/PVector_y.html
|
96
|
-
# @see https://p5js.org/reference
|
96
|
+
# @see https://p5js.org/reference/p5.Vector/y/
|
97
97
|
#
|
98
98
|
def y()
|
99
99
|
@point.y
|
@@ -104,7 +104,7 @@ module Processing
|
|
104
104
|
# @return [Numeric] z value of vector
|
105
105
|
#
|
106
106
|
# @see https://processing.org/reference/PVector_z.html
|
107
|
-
# @see https://p5js.org/reference
|
107
|
+
# @see https://p5js.org/reference/p5.Vector/z/
|
108
108
|
#
|
109
109
|
def z()
|
110
110
|
@point.z
|
@@ -115,7 +115,7 @@ module Processing
|
|
115
115
|
# @return [Numeric] x value of vector
|
116
116
|
#
|
117
117
|
# @see https://processing.org/reference/PVector_x.html
|
118
|
-
# @see https://p5js.org/reference
|
118
|
+
# @see https://p5js.org/reference/p5.Vector/x/
|
119
119
|
#
|
120
120
|
def x=(x)
|
121
121
|
@point.x = x
|
@@ -126,7 +126,7 @@ module Processing
|
|
126
126
|
# @return [Numeric] y value of vector
|
127
127
|
#
|
128
128
|
# @see https://processing.org/reference/PVector_y.html
|
129
|
-
# @see https://p5js.org/reference
|
129
|
+
# @see https://p5js.org/reference/p5.Vector/y/
|
130
130
|
#
|
131
131
|
def y=(y)
|
132
132
|
@point.y = y
|
@@ -137,7 +137,7 @@ module Processing
|
|
137
137
|
# @return [Numeric] z value of vector
|
138
138
|
#
|
139
139
|
# @see https://processing.org/reference/PVector_z.html
|
140
|
-
# @see https://p5js.org/reference
|
140
|
+
# @see https://p5js.org/reference/p5.Vector/z/
|
141
141
|
#
|
142
142
|
def z=(z)
|
143
143
|
@point.z = z
|
@@ -158,7 +158,7 @@ module Processing
|
|
158
158
|
# @return [Vector] interporated vector
|
159
159
|
#
|
160
160
|
# @see https://processing.org/reference/PVector_lerp_.html
|
161
|
-
# @see https://p5js.org/reference
|
161
|
+
# @see https://p5js.org/reference/p5.Vector/lerp/
|
162
162
|
#
|
163
163
|
def lerp(*args, amount)
|
164
164
|
v = toVector__(*args)
|
@@ -177,7 +177,7 @@ module Processing
|
|
177
177
|
# @return [Vector] interporated vector
|
178
178
|
#
|
179
179
|
# @see https://processing.org/reference/PVector_lerp_.html
|
180
|
-
# @see https://p5js.org/reference
|
180
|
+
# @see https://p5js.org/reference/p5.Vector/lerp/
|
181
181
|
#
|
182
182
|
def self.lerp(v1, v2, amount)
|
183
183
|
v1.dup.lerp v2, amount
|
@@ -190,7 +190,7 @@ module Processing
|
|
190
190
|
# @return [Array] array of x, y, z
|
191
191
|
#
|
192
192
|
# @see https://processing.org/reference/PVector_array_.html
|
193
|
-
# @see https://p5js.org/reference
|
193
|
+
# @see https://p5js.org/reference/p5.Vector/array/
|
194
194
|
#
|
195
195
|
def array(n = 3)
|
196
196
|
@point.to_a n
|
@@ -212,7 +212,7 @@ module Processing
|
|
212
212
|
# @return [Vector] added vector
|
213
213
|
#
|
214
214
|
# @see https://processing.org/reference/PVector_add_.html
|
215
|
-
# @see https://p5js.org/reference
|
215
|
+
# @see https://p5js.org/reference/p5.Vector/add/
|
216
216
|
#
|
217
217
|
def add(*args)
|
218
218
|
@point += toVector__(*args).getInternal__
|
@@ -233,7 +233,7 @@ module Processing
|
|
233
233
|
# @return [Vector] subtracted vector
|
234
234
|
#
|
235
235
|
# @see https://processing.org/reference/PVector_sub_.html
|
236
|
-
# @see https://p5js.org/reference
|
236
|
+
# @see https://p5js.org/reference/p5.Vector/sub/
|
237
237
|
#
|
238
238
|
def sub(*args)
|
239
239
|
@point -= toVector__(*args).getInternal__
|
@@ -247,7 +247,7 @@ module Processing
|
|
247
247
|
# @return [Vector] multiplied vector
|
248
248
|
#
|
249
249
|
# @see https://processing.org/reference/PVector_mult_.html
|
250
|
-
# @see https://p5js.org/reference
|
250
|
+
# @see https://p5js.org/reference/p5.Vector/mult/
|
251
251
|
#
|
252
252
|
def mult(num)
|
253
253
|
@point *= num
|
@@ -261,7 +261,7 @@ module Processing
|
|
261
261
|
# @return [Vector] divided vector
|
262
262
|
#
|
263
263
|
# @see https://processing.org/reference/PVector_div_.html
|
264
|
-
# @see https://p5js.org/reference
|
264
|
+
# @see https://p5js.org/reference/p5.Vector/div/
|
265
265
|
#
|
266
266
|
def div(num)
|
267
267
|
@point /= num
|
@@ -275,7 +275,7 @@ module Processing
|
|
275
275
|
# @return [Vector] added vector
|
276
276
|
#
|
277
277
|
# @see https://processing.org/reference/PVector_add_.html
|
278
|
-
# @see https://p5js.org/reference
|
278
|
+
# @see https://p5js.org/reference/p5.Vector/add/
|
279
279
|
#
|
280
280
|
def +(v)
|
281
281
|
dup.add v
|
@@ -288,7 +288,7 @@ module Processing
|
|
288
288
|
# @return [Vector] subtracted vector
|
289
289
|
#
|
290
290
|
# @see https://processing.org/reference/PVector_sub_.html
|
291
|
-
# @see https://p5js.org/reference
|
291
|
+
# @see https://p5js.org/reference/p5.Vector/sub/
|
292
292
|
#
|
293
293
|
def -(v)
|
294
294
|
dup.sub v
|
@@ -301,7 +301,7 @@ module Processing
|
|
301
301
|
# @return [Vector] multiplied vector
|
302
302
|
#
|
303
303
|
# @see https://processing.org/reference/PVector_mult_.html
|
304
|
-
# @see https://p5js.org/reference
|
304
|
+
# @see https://p5js.org/reference/p5.Vector/mult/
|
305
305
|
#
|
306
306
|
def *(num)
|
307
307
|
dup.mult num
|
@@ -314,7 +314,7 @@ module Processing
|
|
314
314
|
# @return [Vector] divided vector
|
315
315
|
#
|
316
316
|
# @see https://processing.org/reference/PVector_div_.html
|
317
|
-
# @see https://p5js.org/reference
|
317
|
+
# @see https://p5js.org/reference/p5.Vector/div/
|
318
318
|
#
|
319
319
|
def /(num)
|
320
320
|
dup.div num
|
@@ -332,7 +332,7 @@ module Processing
|
|
332
332
|
# @return [Vector] added vector
|
333
333
|
#
|
334
334
|
# @see https://processing.org/reference/PVector_add_.html
|
335
|
-
# @see https://p5js.org/reference
|
335
|
+
# @see https://p5js.org/reference/p5.Vector/add/
|
336
336
|
#
|
337
337
|
def self.add(v1, v2, target = nil)
|
338
338
|
v = v1 + v2
|
@@ -352,7 +352,7 @@ module Processing
|
|
352
352
|
# @return [Vector] subtracted vector
|
353
353
|
#
|
354
354
|
# @see https://processing.org/reference/PVector_sub_.html
|
355
|
-
# @see https://p5js.org/reference
|
355
|
+
# @see https://p5js.org/reference/p5.Vector/sub/
|
356
356
|
#
|
357
357
|
def self.sub(v1, v2, target = nil)
|
358
358
|
v = v1 - v2
|
@@ -372,7 +372,7 @@ module Processing
|
|
372
372
|
# @return [Vector] multiplied vector
|
373
373
|
#
|
374
374
|
# @see https://processing.org/reference/PVector_mult_.html
|
375
|
-
# @see https://p5js.org/reference
|
375
|
+
# @see https://p5js.org/reference/p5.Vector/mult/
|
376
376
|
#
|
377
377
|
def self.mult(v1, num, target = nil)
|
378
378
|
v = v1 * num
|
@@ -392,7 +392,7 @@ module Processing
|
|
392
392
|
# @return [Vector] divided vector
|
393
393
|
#
|
394
394
|
# @see https://processing.org/reference/PVector_div_.html
|
395
|
-
# @see https://p5js.org/reference
|
395
|
+
# @see https://p5js.org/reference/p5.Vector/div/
|
396
396
|
#
|
397
397
|
def self.div(v1, num, target = nil)
|
398
398
|
v = v1 / num
|
@@ -405,7 +405,7 @@ module Processing
|
|
405
405
|
# @return [Numeric] length
|
406
406
|
#
|
407
407
|
# @see https://processing.org/reference/PVector_mag_.html
|
408
|
-
# @see https://p5js.org/reference
|
408
|
+
# @see https://p5js.org/reference/p5.Vector/mag/
|
409
409
|
#
|
410
410
|
def mag()
|
411
411
|
@point.length
|
@@ -416,7 +416,7 @@ module Processing
|
|
416
416
|
# @return [Numeric] squared length
|
417
417
|
#
|
418
418
|
# @see https://processing.org/reference/PVector_magSq_.html
|
419
|
-
# @see https://p5js.org/reference
|
419
|
+
# @see https://p5js.org/reference/p5.Vector/magSq/
|
420
420
|
#
|
421
421
|
def magSq()
|
422
422
|
Rays::Point::dot(@point, @point)
|
@@ -433,7 +433,7 @@ module Processing
|
|
433
433
|
# @return [Vector] vector with new length
|
434
434
|
#
|
435
435
|
# @see https://processing.org/reference/PVector_setMag_.html
|
436
|
-
# @see https://p5js.org/reference
|
436
|
+
# @see https://p5js.org/reference/p5.Vector/setMag/
|
437
437
|
#
|
438
438
|
def setMag(target = nil, len)
|
439
439
|
(target || self).set @point.normal * len
|
@@ -446,7 +446,7 @@ module Processing
|
|
446
446
|
# @return [Vector] normalized vector
|
447
447
|
#
|
448
448
|
# @see https://processing.org/reference/PVector_normalize_.html
|
449
|
-
# @see https://p5js.org/reference
|
449
|
+
# @see https://p5js.org/reference/p5.Vector/normalize/
|
450
450
|
#
|
451
451
|
def normalize(target = nil)
|
452
452
|
(target || self).set @point.normal
|
@@ -459,7 +459,7 @@ module Processing
|
|
459
459
|
# @return [Vector] new vector
|
460
460
|
#
|
461
461
|
# @see https://processing.org/reference/PVector_limit_.html
|
462
|
-
# @see https://p5js.org/reference
|
462
|
+
# @see https://p5js.org/reference/p5.Vector/limit/
|
463
463
|
#
|
464
464
|
def limit(max)
|
465
465
|
setMag max if magSq > max ** 2
|
@@ -473,7 +473,7 @@ module Processing
|
|
473
473
|
# @return [Numeric] the distance
|
474
474
|
#
|
475
475
|
# @see https://processing.org/reference/PVector_dist_.html
|
476
|
-
# @see https://p5js.org/reference
|
476
|
+
# @see https://p5js.org/reference/p5.Vector/dist/
|
477
477
|
#
|
478
478
|
def dist(v)
|
479
479
|
(self - v).mag
|
@@ -487,7 +487,7 @@ module Processing
|
|
487
487
|
# @return [Numeric] the distance
|
488
488
|
#
|
489
489
|
# @see https://processing.org/reference/PVector_dist_.html
|
490
|
-
# @see https://p5js.org/reference
|
490
|
+
# @see https://p5js.org/reference/p5.Vector/dist/
|
491
491
|
#
|
492
492
|
def self.dist(v1, v2)
|
493
493
|
v1.dist v2
|
@@ -507,7 +507,7 @@ module Processing
|
|
507
507
|
# @return [Numeric] result of dot product
|
508
508
|
#
|
509
509
|
# @see https://processing.org/reference/PVector_dot_.html
|
510
|
-
# @see https://p5js.org/reference
|
510
|
+
# @see https://p5js.org/reference/p5.Vector/dot/
|
511
511
|
#
|
512
512
|
def dot(*args)
|
513
513
|
Rays::Point::dot getInternal__, toVector__(*args).getInternal__
|
@@ -521,7 +521,7 @@ module Processing
|
|
521
521
|
# @return [Numeric] result of dot product
|
522
522
|
#
|
523
523
|
# @see https://processing.org/reference/PVector_dot_.html
|
524
|
-
# @see https://p5js.org/reference
|
524
|
+
# @see https://p5js.org/reference/p5.Vector/dot/
|
525
525
|
#
|
526
526
|
def self.dot(v1, v2)
|
527
527
|
v1.dot v2
|
@@ -541,7 +541,7 @@ module Processing
|
|
541
541
|
# @return [Numeric] result of cross product
|
542
542
|
#
|
543
543
|
# @see https://processing.org/reference/PVector_cross_.html
|
544
|
-
# @see https://p5js.org/reference
|
544
|
+
# @see https://p5js.org/reference/p5.Vector/cross/
|
545
545
|
#
|
546
546
|
def cross(a, *rest)
|
547
547
|
target = self.class === rest.last ? rest.pop : nil
|
@@ -558,7 +558,7 @@ module Processing
|
|
558
558
|
# @return [Numeric] result of cross product
|
559
559
|
#
|
560
560
|
# @see https://processing.org/reference/PVector_cross_.html
|
561
|
-
# @see https://p5js.org/reference
|
561
|
+
# @see https://p5js.org/reference/p5.Vector/cross/
|
562
562
|
#
|
563
563
|
def self.cross(v1, v2, target = nil)
|
564
564
|
v1.cross v2, target
|
@@ -571,7 +571,7 @@ module Processing
|
|
571
571
|
# @return [Vector] rotated this object
|
572
572
|
#
|
573
573
|
# @see https://processing.org/reference/PVector_rotate_.html
|
574
|
-
# @see https://p5js.org/reference
|
574
|
+
# @see https://p5js.org/reference/p5.Vector/rotate/
|
575
575
|
#
|
576
576
|
def rotate(angle)
|
577
577
|
deg = @context ?
|
@@ -585,7 +585,7 @@ module Processing
|
|
585
585
|
# @return [Numeric] the angle in radians
|
586
586
|
#
|
587
587
|
# @see https://processing.org/reference/PVector_heading_.html
|
588
|
-
# @see https://p5js.org/reference
|
588
|
+
# @see https://p5js.org/reference/p5.Vector/heading/
|
589
589
|
#
|
590
590
|
def heading()
|
591
591
|
Math.atan2 y, x
|
@@ -599,7 +599,7 @@ module Processing
|
|
599
599
|
# @return [Vector] rotated vector
|
600
600
|
#
|
601
601
|
# @see https://processing.org/reference/PVector_fromAngle_.html
|
602
|
-
# @see https://p5js.org/reference
|
602
|
+
# @see https://p5js.org/reference/p5.Vector/fromAngle/
|
603
603
|
#
|
604
604
|
def self.fromAngle(angle, target = nil)
|
605
605
|
v = self.new(1, 0, 0).rotate(angle)
|
@@ -615,7 +615,7 @@ module Processing
|
|
615
615
|
# @return [Numeric] angle in radians
|
616
616
|
#
|
617
617
|
# @see https://processing.org/reference/PVector_angleBetween_.html
|
618
|
-
# @see https://p5js.org/reference
|
618
|
+
# @see https://p5js.org/reference/p5.Vector/angleBetween/
|
619
619
|
#
|
620
620
|
def self.angleBetween(v1, v2)
|
621
621
|
x1, y1, z1 = v1.array
|
@@ -635,7 +635,7 @@ module Processing
|
|
635
635
|
# @return [Vector] a random vector
|
636
636
|
#
|
637
637
|
# @see https://processing.org/reference/PVector_random2D_.html
|
638
|
-
# @see https://p5js.org/reference
|
638
|
+
# @see https://p5js.org/reference/p5.Vector/random2D/
|
639
639
|
#
|
640
640
|
def self.random2D(target = nil)
|
641
641
|
v = self.new(1, 0, 0)
|
@@ -651,7 +651,7 @@ module Processing
|
|
651
651
|
# @return [Vector] a random vector
|
652
652
|
#
|
653
653
|
# @see https://processing.org/reference/PVector_random3D_.html
|
654
|
-
# @see https://p5js.org/reference
|
654
|
+
# @see https://p5js.org/reference/p5.Vector/random3D/
|
655
655
|
#
|
656
656
|
def self.random3D(target = nil)
|
657
657
|
angle = rand 0.0...(Math::PI * 2)
|
data/lib/processing/window.rb
CHANGED
@@ -41,6 +41,10 @@ module Processing
|
|
41
41
|
@overlay_view.add view
|
42
42
|
end
|
43
43
|
|
44
|
+
def remove_overlay(view)
|
45
|
+
@overlay_view.remove view
|
46
|
+
end
|
47
|
+
|
44
48
|
def start(&block)
|
45
49
|
draw_canvas do
|
46
50
|
block.call if block
|
@@ -161,15 +165,17 @@ module Processing
|
|
161
165
|
def get_scroll_and_zoom()
|
162
166
|
ww, wh = width.to_f, height.to_f
|
163
167
|
cw, ch = @canvas.image.width.to_f, @canvas.image.height.to_f
|
164
|
-
return
|
168
|
+
return 0, 0, 1 if ww == 0 || wh == 0 || cw == 0 || ch == 0
|
165
169
|
|
166
170
|
wratio, cratio = ww / wh, cw / ch
|
167
|
-
if wratio
|
168
|
-
|
169
|
-
|
171
|
+
if wratio == cratio
|
172
|
+
return 0, 0, ww / cw
|
173
|
+
elsif wratio > cratio
|
174
|
+
w = wh * cratio
|
175
|
+
return (ww - w) / 2, 0, w / cw
|
170
176
|
else
|
171
|
-
|
172
|
-
return 0, (wh -
|
177
|
+
h = ww / cratio
|
178
|
+
return 0, (wh - h) / 2, ww / cw
|
173
179
|
end
|
174
180
|
end
|
175
181
|
|
@@ -241,8 +247,9 @@ module Processing
|
|
241
247
|
|
242
248
|
old_paintable, old_painter = @paintable, @painter
|
243
249
|
|
244
|
-
@framebuffer = Rays::Image.new width, height, cs, pd
|
245
|
-
@paintable = aa ?
|
250
|
+
@framebuffer = Rays::Image.new width, height, cs, pixel_density: pd
|
251
|
+
@paintable = aa ?
|
252
|
+
Rays::Image.new(width, height, cs, pixel_density: pd * 2) : @framebuffer
|
246
253
|
@painter = @paintable.painter
|
247
254
|
|
248
255
|
@painter.paint {image old_paintable} if old_paintable
|
data/lib/processing.rb
CHANGED
@@ -4,23 +4,25 @@ require 'processing/all'
|
|
4
4
|
module Processing
|
5
5
|
w = (ENV['WIDTH'] || 500).to_i
|
6
6
|
h = (ENV['HEIGHT'] || 500).to_i
|
7
|
-
|
8
|
-
|
7
|
+
WINDOW__ = Processing::Window.new(w, h) {start}
|
8
|
+
CONTEXT__ = Processing::Context.new WINDOW__
|
9
9
|
|
10
10
|
refine Object do
|
11
|
-
(
|
12
|
-
|
13
|
-
|
11
|
+
(CONTEXT__.methods - Object.instance_methods)
|
12
|
+
.reject {_1 =~ /__$/} # methods for internal use
|
13
|
+
.each do |method|
|
14
|
+
define_method method do |*args, **kwargs, &block|
|
15
|
+
CONTEXT__.__send__ method, *args, **kwargs, &block
|
16
|
+
end
|
14
17
|
end
|
15
|
-
end
|
16
18
|
end
|
17
19
|
end# Processing
|
18
20
|
|
19
21
|
|
20
22
|
begin
|
21
|
-
w, c = Processing::
|
23
|
+
w, c = Processing::WINDOW__, Processing::CONTEXT__
|
22
24
|
|
23
|
-
c.class.constants.each do |const|
|
25
|
+
c.class.constants.reject {_1 =~ /__$/}.each do |const|
|
24
26
|
self.class.const_set const, c.class.const_get(const)
|
25
27
|
end
|
26
28
|
|
data/processing.gemspec
CHANGED
@@ -25,11 +25,11 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.platform = Gem::Platform::RUBY
|
26
26
|
s.required_ruby_version = '>= 3.0.0'
|
27
27
|
|
28
|
-
s.
|
29
|
-
s.
|
30
|
-
s.
|
31
|
-
s.
|
32
|
-
s.
|
28
|
+
s.add_dependency 'rexml'
|
29
|
+
s.add_dependency 'xot', '~> 0.3.2', '>= 0.3.2'
|
30
|
+
s.add_dependency 'rucy', '~> 0.3.2', '>= 0.3.2'
|
31
|
+
s.add_dependency 'rays', '~> 0.3.2', '>= 0.3.2'
|
32
|
+
s.add_dependency 'reflexion', '~> 0.3.2', '>= 0.3.2'
|
33
33
|
|
34
34
|
s.files = `git ls-files`.split $/
|
35
35
|
s.test_files = s.files.grep %r{^(test|spec|features)/}
|