processing 0.5.33 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,248 @@
1
+ module Processing
2
+
3
+
4
+ # @private
5
+ class SVGLoader
6
+
7
+ def initialize(context)
8
+ @c, @cc = context, context.class
9
+ end
10
+
11
+ def load(filename)
12
+ parse File.read(filename)
13
+ end
14
+
15
+ def parse(xml)
16
+ addGroup nil, REXML::Document.new(xml).elements.first
17
+ end
18
+
19
+ def addGroup(parent, e, **attribs)
20
+ group = @c.createShape @cc::GROUP
21
+ attribs = getAttribs e, attribs
22
+ e.elements.each do |child|
23
+ case child.name.to_sym
24
+ when :g, :a then addGroup group, child, **attribs
25
+ when :line then addLine group, child, **attribs
26
+ when :rect then addRect group, child, **attribs
27
+ when :circle then addCircle group, child, **attribs
28
+ when :ellipse then addEllipse group, child, **attribs
29
+ when :polyline then addPolyline group, child, **attribs
30
+ when :polygon then addPolyline group, child, true, **attribs
31
+ when :path then addPath group, child, **attribs
32
+ end
33
+ end
34
+ parent.addChild group if parent
35
+ group
36
+ end
37
+
38
+ def addLine(parent, e, **attribs)
39
+ x1, y1 = float(e, :x1), float(e, :y1)
40
+ x2, y2 = float(e, :x2), float(e, :y2)
41
+ s = @c.createLineShape__ x1, y1, x2, y2
42
+ applyAttribs s, e, attribs
43
+ parent.addChild s
44
+ end
45
+
46
+ def addRect(parent, e, **attribs)
47
+ x, y = float(e, :x), float(e, :y)
48
+ w, h = float(e, :width), float(e, :height)
49
+ rx, ry = float(e, :rx), float(e, :ry)
50
+ s = @c.createRectShape__ x, y, w, h, (rx || ry), mode: @cc::CORNER
51
+ applyAttribs s, e, attribs
52
+ parent.addChild s
53
+ end
54
+
55
+ def addCircle(parent, e, **attribs)
56
+ cx, cy = float(e, :cx), float(e, :cy)
57
+ r = float(e, :r)
58
+ s = @c.createEllipseShape__ cx, cy, r * 2, r * 2, mode: @cc::CENTER
59
+ applyAttribs s, e, attribs
60
+ parent.addChild s
61
+ end
62
+
63
+ def addEllipse(parent, e, **attribs)
64
+ cx, cy = float(e, :cx), float(e, :cy)
65
+ rx, ry = float(e, :rx), float(e, :ry)
66
+ s = @c.createEllipseShape__ cx, cy, rx * 2, ry * 2, mode: @cc::CENTER
67
+ applyAttribs s, e, attribs
68
+ parent.addChild s
69
+ end
70
+
71
+ def addPolyline(parent, e, close = false, **attribs)
72
+ points = e[:points] or raise Error, "missing 'points'"
73
+ scanner = StringScanner.new points
74
+ child = @c.createShape
75
+ child.beginShape
76
+
77
+ skipSpaces scanner
78
+ until scanner.eos?
79
+ child.vertex(*nextPos(scanner))
80
+ skipSpaces scanner
81
+ end
82
+
83
+ child.endShape close ? @cc::CLOSE : @cc::OPEN
84
+ applyAttribs child, e, attribs
85
+ parent.addChild child
86
+ end
87
+
88
+ def applyAttribs(shape, e, attribs)
89
+ a = getAttribs e, attribs
90
+ shape.setFill a[:fill] || :black
91
+ shape.setStroke a[:stroke] || :none
92
+ shape.setStrokeWeight a[:strokeWeight] || 1
93
+ shape.setStrokeCap a[:strokeCap] || @cc::SQUARE
94
+ shape.setStrokeJoin a[:strokeJoin] || @cc::MITER
95
+ end
96
+
97
+ def getAttribs(e, attribs)
98
+ @caps ||= {
99
+ 'butt' => @cc::SQUARE,
100
+ 'round' => @cc::ROUND,
101
+ 'square' => @cc::PROJECT
102
+ }
103
+ @joins ||= {
104
+ 'miter' => @cc::MITER,
105
+ 'miter-clip' => @cc::MITER,
106
+ 'round' => @cc::ROUND,
107
+ 'bevel' => @cc::BEVEL,
108
+ 'arcs' => @cc::MITER
109
+ }
110
+ attribs.merge({
111
+ fill: e[:fill],
112
+ stroke: e[:stroke],
113
+ strokeWeight: e[:'stroke-width'],
114
+ strokeCap: @caps[ e[:'stroke-linecap']],
115
+ strokeJoin: @joins[e[:'stroke-linejoin']]
116
+ }.compact)
117
+ end
118
+
119
+ def int(e, key, defval = 0)
120
+ e[key]&.to_i || defval
121
+ end
122
+
123
+ def float(e, key, defval = 0)
124
+ e[key]&.to_f || defval
125
+ end
126
+
127
+ def addPath(parent, e, **attribs)
128
+ data = e[:d] or raise Error, "missing 'd'"
129
+ scanner = StringScanner.new data
130
+ skipSpaces scanner
131
+
132
+ child = nil
133
+ close = false
134
+ beginChild = -> {
135
+ close = false
136
+ child = @c.createShape
137
+ child.beginShape
138
+ }
139
+ endChild = -> {
140
+ if child# && child.getVertexCount >= 2
141
+ child.endShape close ? @cc::CLOSE : @cc::OPEN
142
+ applyAttribs child, e, attribs
143
+ parent.addChild child
144
+ end
145
+ }
146
+
147
+ lastCommand = nil
148
+ lastX, lastY = 0, 0
149
+ lastCX, lastCY = 0, 0
150
+ until scanner.eos?
151
+ command = nextCommand scanner
152
+ if command =~ /^[Mm]$/
153
+ endChild.call
154
+ beginChild.call
155
+ end
156
+ raise Error, "no leading 'M' or 'm'" unless child
157
+
158
+ command ||= lastCommand
159
+ case command
160
+ when 'M', 'm'
161
+ lastX, lastY = nextPos scanner, lastX, lastY, command == 'm'
162
+ child.vertex lastX, lastY
163
+ when 'L', 'l'
164
+ lastX, lastY = nextPos scanner, lastX, lastY, command == 'l'
165
+ child.vertex lastX, lastY
166
+ when 'H', 'h'
167
+ lastX = nextNum scanner, lastX, command == 'h'
168
+ child.vertex lastX, lastY
169
+ when 'V', 'v'
170
+ lastY = nextNum scanner, lastY, command == 'v'
171
+ child.vertex lastX, lastY
172
+ when 'Q', 'q'
173
+ relative = command == 'q'
174
+ lastCX, lastCY = nextPos scanner, lastX, lastY, relative
175
+ lastX, lastY = nextPos scanner, lastX, lastY, relative
176
+ child.quadraticVertex lastCX, lastCY, lastX, lastY
177
+ when 'T', 't'
178
+ lastCX, lastCY =
179
+ if lastCommand =~ /[QqTt]/
180
+ [lastX + (lastX - lastCX), lastY + (lastY - lastCY)]
181
+ else
182
+ [lastX, lastY]
183
+ end
184
+ lastX, lastY = nextPos scanner, lastX, lastY, command == 't'
185
+ child.quadraticVertex lastCX, lastCY, lastX, lastY
186
+ when 'C', 'c'
187
+ relative = command == 'c'
188
+ cx, cy = nextPos scanner, lastX, lastY, relative
189
+ lastCX, lastCY = nextPos scanner, lastX, lastY, relative
190
+ lastX, lastY = nextPos scanner, lastX, lastY, relative
191
+ child.bezierVertex cx, cy, lastCX, lastCY, lastX, lastY
192
+ when 'S', 's'
193
+ cx, cy =
194
+ if lastCommand =~ /[CcSs]/
195
+ [lastX + (lastX - lastCX), lastY + (lastY - lastCY)]
196
+ else
197
+ [lastX, lastY]
198
+ end
199
+ relative = command == 's'
200
+ lastCX, lastCY = nextPos scanner, lastX, lastY, relative
201
+ lastX, lastY = nextPos scanner, lastX, lastY, relative
202
+ child.bezierVertex cx, cy, lastCX, lastCY, lastX, lastY
203
+ when 'A', 'a'
204
+ rx, ry = nextPos scanner
205
+ a, b, c = nextNum(scanner), nextNum(scanner), nextNum(scanner)
206
+ lastX, lastY = nextPos scanner, lastX, lastY, command == 'a'
207
+ child.vertex lastX, lastY
208
+ when 'Z', 'z'
209
+ v0 = child.getVertex 0
210
+ lastX, lastY = v0 ? [v0.x, v0.y] : [0, 0]
211
+ close = true
212
+ end
213
+ lastCommand = command
214
+ end
215
+ endChild.call
216
+ end
217
+
218
+ def nextCommand(scanner)
219
+ w = scanner.scan(/[[:alpha:]]/)
220
+ skipSpaces scanner
221
+ w
222
+ end
223
+
224
+ def nextNum(scanner, base = 0, relative = true)
225
+ n = scanner.scan(/(?:[\+\-]\s*)?\d*(?:\.\d+)?/)&.strip&.to_f
226
+ raise Error, 'invalid path' unless n
227
+ skipSpaces scanner
228
+ n + (relative ? base : 0)
229
+ end
230
+
231
+ def nextPos(scanner, baseX = 0, baseY = 0, relative = true)
232
+ [nextNum(scanner, baseX, relative), nextNum(scanner, baseY, relative)]
233
+ end
234
+
235
+ def skipSpaces(scanner)
236
+ scanner.scan(/\s*,?\s*/)
237
+ end
238
+
239
+ class Error < StandardError
240
+ def initialize(message = "error")
241
+ super "SVG: #{message}"
242
+ end
243
+ end# Error
244
+
245
+ end# SVG
246
+
247
+
248
+ end# Processing
@@ -3,6 +3,9 @@ module Processing
3
3
 
4
4
  # Vector class.
5
5
  #
6
+ # @see https://processing.org/reference/PVector.html
7
+ # @see https://p5js.org/reference/#/p5.Vector
8
+ #
6
9
  class Vector
7
10
 
8
11
  include Comparable
@@ -22,6 +25,9 @@ module Processing
22
25
  # @param v [Vector] vector object to copy
23
26
  # @param a [Array] array like [x, y, z]
24
27
  #
28
+ # @see https://processing.org/reference/PVector.html
29
+ # @see https://p5js.org/reference/#/p5.Vector
30
+ #
25
31
  def initialize(x = 0, y = 0, z = 0, context: nil)
26
32
  @point = case x
27
33
  when Rays::Point then x.dup
@@ -42,6 +48,9 @@ module Processing
42
48
  #
43
49
  # @return [Vector] duplicated vector object
44
50
  #
51
+ # @see https://processing.org/reference/PVector_copy_.html
52
+ # @see https://p5js.org/reference/#/p5.Vector/copy
53
+ #
45
54
  alias copy dup
46
55
 
47
56
  # Sets x, y and z.
@@ -60,6 +69,9 @@ module Processing
60
69
  #
61
70
  # @return [nil] nil
62
71
  #
72
+ # @see https://processing.org/reference/PVector_set_.html
73
+ # @see https://p5js.org/reference/#/p5.Vector/set
74
+ #
63
75
  def set(*args)
64
76
  initialize(*args)
65
77
  self
@@ -69,6 +81,9 @@ module Processing
69
81
  #
70
82
  # @return [Numeric] x value of vector
71
83
  #
84
+ # @see https://processing.org/reference/PVector_x.html
85
+ # @see https://p5js.org/reference/#/p5.Vector/x
86
+ #
72
87
  def x()
73
88
  @point.x
74
89
  end
@@ -77,6 +92,9 @@ module Processing
77
92
  #
78
93
  # @return [Numeric] y value of vector
79
94
  #
95
+ # @see https://processing.org/reference/PVector_y.html
96
+ # @see https://p5js.org/reference/#/p5.Vector/y
97
+ #
80
98
  def y()
81
99
  @point.y
82
100
  end
@@ -85,6 +103,9 @@ module Processing
85
103
  #
86
104
  # @return [Numeric] z value of vector
87
105
  #
106
+ # @see https://processing.org/reference/PVector_z.html
107
+ # @see https://p5js.org/reference/#/p5.Vector/z
108
+ #
88
109
  def z()
89
110
  @point.z
90
111
  end
@@ -93,6 +114,9 @@ module Processing
93
114
  #
94
115
  # @return [Numeric] x value of vector
95
116
  #
117
+ # @see https://processing.org/reference/PVector_x.html
118
+ # @see https://p5js.org/reference/#/p5.Vector/x
119
+ #
96
120
  def x=(x)
97
121
  @point.x = x
98
122
  end
@@ -101,6 +125,9 @@ module Processing
101
125
  #
102
126
  # @return [Numeric] y value of vector
103
127
  #
128
+ # @see https://processing.org/reference/PVector_y.html
129
+ # @see https://p5js.org/reference/#/p5.Vector/y
130
+ #
104
131
  def y=(y)
105
132
  @point.y = y
106
133
  end
@@ -109,6 +136,9 @@ module Processing
109
136
  #
110
137
  # @return [Numeric] z value of vector
111
138
  #
139
+ # @see https://processing.org/reference/PVector_z.html
140
+ # @see https://p5js.org/reference/#/p5.Vector/z
141
+ #
112
142
  def z=(z)
113
143
  @point.z = z
114
144
  end
@@ -127,6 +157,9 @@ module Processing
127
157
  #
128
158
  # @return [Vector] interporated vector
129
159
  #
160
+ # @see https://processing.org/reference/PVector_lerp_.html
161
+ # @see https://p5js.org/reference/#/p5.Vector/lerp
162
+ #
130
163
  def lerp(*args, amount)
131
164
  v = toVector__(*args)
132
165
  self.x = x + (v.x - x) * amount
@@ -143,6 +176,9 @@ module Processing
143
176
  #
144
177
  # @return [Vector] interporated vector
145
178
  #
179
+ # @see https://processing.org/reference/PVector_lerp_.html
180
+ # @see https://p5js.org/reference/#/p5.Vector/lerp
181
+ #
146
182
  def self.lerp(v1, v2, amount)
147
183
  v1.dup.lerp v2, amount
148
184
  end
@@ -153,6 +189,9 @@ module Processing
153
189
  #
154
190
  # @return [Array] array of x, y, z
155
191
  #
192
+ # @see https://processing.org/reference/PVector_array_.html
193
+ # @see https://p5js.org/reference/#/p5.Vector/array
194
+ #
156
195
  def array(n = 3)
157
196
  @point.to_a n
158
197
  end
@@ -172,6 +211,9 @@ module Processing
172
211
  #
173
212
  # @return [Vector] added vector
174
213
  #
214
+ # @see https://processing.org/reference/PVector_add_.html
215
+ # @see https://p5js.org/reference/#/p5.Vector/add
216
+ #
175
217
  def add(*args)
176
218
  @point += toVector__(*args).getInternal__
177
219
  self
@@ -190,6 +232,9 @@ module Processing
190
232
  #
191
233
  # @return [Vector] subtracted vector
192
234
  #
235
+ # @see https://processing.org/reference/PVector_sub_.html
236
+ # @see https://p5js.org/reference/#/p5.Vector/sub
237
+ #
193
238
  def sub(*args)
194
239
  @point -= toVector__(*args).getInternal__
195
240
  self
@@ -201,6 +246,9 @@ module Processing
201
246
  #
202
247
  # @return [Vector] multiplied vector
203
248
  #
249
+ # @see https://processing.org/reference/PVector_mult_.html
250
+ # @see https://p5js.org/reference/#/p5.Vector/mult
251
+ #
204
252
  def mult(num)
205
253
  @point *= num
206
254
  self
@@ -212,6 +260,9 @@ module Processing
212
260
  #
213
261
  # @return [Vector] divided vector
214
262
  #
263
+ # @see https://processing.org/reference/PVector_div_.html
264
+ # @see https://p5js.org/reference/#/p5.Vector/div
265
+ #
215
266
  def div(num)
216
267
  @point /= num
217
268
  self
@@ -223,6 +274,9 @@ module Processing
223
274
  #
224
275
  # @return [Vector] added vector
225
276
  #
277
+ # @see https://processing.org/reference/PVector_add_.html
278
+ # @see https://p5js.org/reference/#/p5.Vector/add
279
+ #
226
280
  def +(v)
227
281
  dup.add v
228
282
  end
@@ -233,6 +287,9 @@ module Processing
233
287
  #
234
288
  # @return [Vector] subtracted vector
235
289
  #
290
+ # @see https://processing.org/reference/PVector_sub_.html
291
+ # @see https://p5js.org/reference/#/p5.Vector/sub
292
+ #
236
293
  def -(v)
237
294
  dup.sub v
238
295
  end
@@ -243,6 +300,9 @@ module Processing
243
300
  #
244
301
  # @return [Vector] multiplied vector
245
302
  #
303
+ # @see https://processing.org/reference/PVector_mult_.html
304
+ # @see https://p5js.org/reference/#/p5.Vector/mult
305
+ #
246
306
  def *(num)
247
307
  dup.mult num
248
308
  end
@@ -253,6 +313,9 @@ module Processing
253
313
  #
254
314
  # @return [Vector] divided vector
255
315
  #
316
+ # @see https://processing.org/reference/PVector_div_.html
317
+ # @see https://p5js.org/reference/#/p5.Vector/div
318
+ #
256
319
  def /(num)
257
320
  dup.div num
258
321
  end
@@ -268,6 +331,9 @@ module Processing
268
331
  #
269
332
  # @return [Vector] added vector
270
333
  #
334
+ # @see https://processing.org/reference/PVector_add_.html
335
+ # @see https://p5js.org/reference/#/p5.Vector/add
336
+ #
271
337
  def self.add(v1, v2, target = nil)
272
338
  v = v1 + v2
273
339
  target.set v if self === target
@@ -285,6 +351,9 @@ module Processing
285
351
  #
286
352
  # @return [Vector] subtracted vector
287
353
  #
354
+ # @see https://processing.org/reference/PVector_sub_.html
355
+ # @see https://p5js.org/reference/#/p5.Vector/sub
356
+ #
288
357
  def self.sub(v1, v2, target = nil)
289
358
  v = v1 - v2
290
359
  target.set v if self === target
@@ -302,6 +371,9 @@ module Processing
302
371
  #
303
372
  # @return [Vector] multiplied vector
304
373
  #
374
+ # @see https://processing.org/reference/PVector_mult_.html
375
+ # @see https://p5js.org/reference/#/p5.Vector/mult
376
+ #
305
377
  def self.mult(v1, num, target = nil)
306
378
  v = v1 * num
307
379
  target.set v if self === target
@@ -319,6 +391,9 @@ module Processing
319
391
  #
320
392
  # @return [Vector] divided vector
321
393
  #
394
+ # @see https://processing.org/reference/PVector_div_.html
395
+ # @see https://p5js.org/reference/#/p5.Vector/div
396
+ #
322
397
  def self.div(v1, num, target = nil)
323
398
  v = v1 / num
324
399
  target.set v if self === target
@@ -329,6 +404,9 @@ module Processing
329
404
  #
330
405
  # @return [Numeric] length
331
406
  #
407
+ # @see https://processing.org/reference/PVector_mag_.html
408
+ # @see https://p5js.org/reference/#/p5.Vector/mag
409
+ #
332
410
  def mag()
333
411
  @point.length
334
412
  end
@@ -337,6 +415,9 @@ module Processing
337
415
  #
338
416
  # @return [Numeric] squared length
339
417
  #
418
+ # @see https://processing.org/reference/PVector_magSq_.html
419
+ # @see https://p5js.org/reference/#/p5.Vector/magSq
420
+ #
340
421
  def magSq()
341
422
  Rays::Point::dot(@point, @point)
342
423
  end
@@ -351,6 +432,9 @@ module Processing
351
432
  #
352
433
  # @return [Vector] vector with new length
353
434
  #
435
+ # @see https://processing.org/reference/PVector_setMag_.html
436
+ # @see https://p5js.org/reference/#/p5.Vector/setMag
437
+ #
354
438
  def setMag(target = nil, len)
355
439
  (target || self).set @point.normal * len
356
440
  end
@@ -361,6 +445,9 @@ module Processing
361
445
  #
362
446
  # @return [Vector] normalized vector
363
447
  #
448
+ # @see https://processing.org/reference/PVector_normalize_.html
449
+ # @see https://p5js.org/reference/#/p5.Vector/normalize
450
+ #
364
451
  def normalize(target = nil)
365
452
  (target || self).set @point.normal
366
453
  end
@@ -371,6 +458,9 @@ module Processing
371
458
  #
372
459
  # @return [Vector] new vector
373
460
  #
461
+ # @see https://processing.org/reference/PVector_limit_.html
462
+ # @see https://p5js.org/reference/#/p5.Vector/limit
463
+ #
374
464
  def limit(max)
375
465
  setMag max if magSq > max ** 2
376
466
  self
@@ -382,6 +472,9 @@ module Processing
382
472
  #
383
473
  # @return [Numeric] the distance
384
474
  #
475
+ # @see https://processing.org/reference/PVector_dist_.html
476
+ # @see https://p5js.org/reference/#/p5.Vector/dist
477
+ #
385
478
  def dist(v)
386
479
  (self - v).mag
387
480
  end
@@ -393,6 +486,9 @@ module Processing
393
486
  #
394
487
  # @return [Numeric] the distance
395
488
  #
489
+ # @see https://processing.org/reference/PVector_dist_.html
490
+ # @see https://p5js.org/reference/#/p5.Vector/dist
491
+ #
396
492
  def self.dist(v1, v2)
397
493
  v1.dist v2
398
494
  end
@@ -410,6 +506,9 @@ module Processing
410
506
  #
411
507
  # @return [Numeric] result of dot product
412
508
  #
509
+ # @see https://processing.org/reference/PVector_dot_.html
510
+ # @see https://p5js.org/reference/#/p5.Vector/dot
511
+ #
413
512
  def dot(*args)
414
513
  Rays::Point::dot getInternal__, toVector__(*args).getInternal__
415
514
  end
@@ -421,6 +520,9 @@ module Processing
421
520
  #
422
521
  # @return [Numeric] result of dot product
423
522
  #
523
+ # @see https://processing.org/reference/PVector_dot_.html
524
+ # @see https://p5js.org/reference/#/p5.Vector/dot
525
+ #
424
526
  def self.dot(v1, v2)
425
527
  v1.dot v2
426
528
  end
@@ -438,6 +540,9 @@ module Processing
438
540
  #
439
541
  # @return [Numeric] result of cross product
440
542
  #
543
+ # @see https://processing.org/reference/PVector_cross_.html
544
+ # @see https://p5js.org/reference/#/p5.Vector/cross
545
+ #
441
546
  def cross(a, *rest)
442
547
  target = self.class === rest.last ? rest.pop : nil
443
548
  v = self.class.new Rays::Point::cross getInternal__, toVector__(a, *rest).getInternal__
@@ -452,6 +557,9 @@ module Processing
452
557
  #
453
558
  # @return [Numeric] result of cross product
454
559
  #
560
+ # @see https://processing.org/reference/PVector_cross_.html
561
+ # @see https://p5js.org/reference/#/p5.Vector/cross
562
+ #
455
563
  def self.cross(v1, v2, target = nil)
456
564
  v1.cross v2, target
457
565
  end
@@ -462,6 +570,9 @@ module Processing
462
570
  #
463
571
  # @return [Vector] rotated this object
464
572
  #
573
+ # @see https://processing.org/reference/PVector_rotate_.html
574
+ # @see https://p5js.org/reference/#/p5.Vector/rotate
575
+ #
465
576
  def rotate(angle)
466
577
  deg = @context ?
467
578
  @context.toDegrees__(angle) : angle * GraphicsContext::RAD2DEG__
@@ -473,6 +584,9 @@ module Processing
473
584
  #
474
585
  # @return [Numeric] the angle in radians
475
586
  #
587
+ # @see https://processing.org/reference/PVector_heading_.html
588
+ # @see https://p5js.org/reference/#/p5.Vector/heading
589
+ #
476
590
  def heading()
477
591
  Math.atan2 y, x
478
592
  end
@@ -484,6 +598,9 @@ module Processing
484
598
  #
485
599
  # @return [Vector] rotated vector
486
600
  #
601
+ # @see https://processing.org/reference/PVector_fromAngle_.html
602
+ # @see https://p5js.org/reference/#/p5.Vector/fromAngle
603
+ #
487
604
  def self.fromAngle(angle, target = nil)
488
605
  v = self.new(1, 0, 0).rotate(angle)
489
606
  target.set v if target
@@ -497,6 +614,9 @@ module Processing
497
614
  #
498
615
  # @return [Numeric] angle in radians
499
616
  #
617
+ # @see https://processing.org/reference/PVector_angleBetween_.html
618
+ # @see https://p5js.org/reference/#/p5.Vector/angleBetween
619
+ #
500
620
  def self.angleBetween(v1, v2)
501
621
  x1, y1, z1 = v1.array
502
622
  x2, y2, z2 = v2.array
@@ -514,6 +634,9 @@ module Processing
514
634
  #
515
635
  # @return [Vector] a random vector
516
636
  #
637
+ # @see https://processing.org/reference/PVector_random2D_.html
638
+ # @see https://p5js.org/reference/#/p5.Vector/random2D
639
+ #
517
640
  def self.random2D(target = nil)
518
641
  v = self.new(1, 0, 0)
519
642
  v.getInternal__.rotate! rand 0.0...360.0
@@ -527,6 +650,9 @@ module Processing
527
650
  #
528
651
  # @return [Vector] a random vector
529
652
  #
653
+ # @see https://processing.org/reference/PVector_random3D_.html
654
+ # @see https://p5js.org/reference/#/p5.Vector/random3D
655
+ #
530
656
  def self.random3D(target = nil)
531
657
  angle = rand 0.0...(Math::PI * 2)
532
658
  z = rand(-1.0..1.0)
@@ -212,6 +212,7 @@ module Processing
212
212
  end# Window
213
213
 
214
214
 
215
+ # @private
215
216
  class Window::Canvas
216
217
 
217
218
  def initialize(window, width, height)
@@ -297,6 +298,7 @@ module Processing
297
298
  end# Window::Canvas
298
299
 
299
300
 
301
+ # @private
300
302
  class Window::CanvasView < Reflex::View
301
303
 
302
304
  def on_update(e)
data/processing.gemspec CHANGED
@@ -25,10 +25,10 @@ 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.add_runtime_dependency 'xot', '~> 0.1.42'
29
- s.add_runtime_dependency 'rucy', '~> 0.1.44'
30
- s.add_runtime_dependency 'rays', '~> 0.1.49'
31
- s.add_runtime_dependency 'reflexion', '~> 0.1.57'
28
+ s.add_runtime_dependency 'xot', '~> 0.2'
29
+ s.add_runtime_dependency 'rucy', '~> 0.2'
30
+ s.add_runtime_dependency 'rays', '~> 0.2'
31
+ s.add_runtime_dependency 'reflexion', '~> 0.2'
32
32
 
33
33
  s.files = `git ls-files`.split $/
34
34
  s.test_files = s.files.grep %r{^(test|spec|features)/}