processing 0.5.31 → 0.5.32

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_image.rb CHANGED
@@ -37,6 +37,27 @@ class TestImage < Test::Unit::TestCase
37
37
  assert_equal g.color(0, 0, 255), i.get(0, 1)
38
38
  end
39
39
 
40
+ def test_pixels()
41
+ i = image 2, 2
42
+
43
+ i.loadPixels
44
+ assert_equal [0] * 4, i.pixels
45
+ assert_equal [0] * 4, i.getInternal__.pixels
46
+
47
+ i.pixels.replace [0xffff0000, 0xff00ff00, 0xff0000ff, 0xff000000]
48
+ assert_equal [0xffff0000, 0xff00ff00, 0xff0000ff, 0xff000000], i.pixels
49
+ assert_equal [0] * 4, i.getInternal__.pixels
50
+
51
+ i.updatePixels
52
+ assert_nil i.pixels
53
+ assert_equal [0xffff0000, 0xff00ff00, 0xff0000ff, 0xff000000], i.getInternal__.pixels
54
+ assert_nothing_raised {i.updatePixels}
55
+
56
+ i.loadPixels
57
+ i.pixels.replace [0xff000000]
58
+ assert_raise(ArgumentError) {i.updatePixels}
59
+ end
60
+
40
61
  def test_inspect()
41
62
  assert_match %r|#<Processing::Image:0x\w{16}>|, image.inspect
42
63
  end
data/test/test_shape.rb CHANGED
@@ -235,6 +235,82 @@ class TestShape < Test::Unit::TestCase
235
235
  ACTUAL
236
236
  end
237
237
 
238
+ def test_curveVertex()
239
+ assert_equal_draw_vertices <<~END
240
+ s.beginShape
241
+ s.curveVertex 100, 100
242
+ s.curveVertex 800, 100
243
+ s.curveVertex 800, 800
244
+ s.curveVertex 100, 800
245
+ s.endShape
246
+ END
247
+
248
+ assert_equal_draw_vertices <<~END
249
+ s.beginShape
250
+ s.curveVertex 200, 200
251
+ s.curveVertex 200, 200
252
+ s.curveVertex 800, 200
253
+ s.curveVertex 800, 400
254
+ s.curveVertex 200, 400
255
+ s.curveVertex 200, 800
256
+ s.curveVertex 800, 800
257
+ s.curveVertex 800, 700
258
+ s.curveVertex 800, 700
259
+ s.endShape
260
+ END
261
+ end
262
+
263
+ def test_bezierVertex()
264
+ assert_equal_draw_vertices <<~END
265
+ s.beginShape
266
+ s.vertex 100, 100
267
+ s.bezierVertex 900, 100, 900, 900, 200, 500
268
+ s.endShape
269
+ END
270
+
271
+ assert_equal_draw_vertices <<~END
272
+ s.beginShape
273
+ s.vertex 100, 100
274
+ s.bezierVertex 900, 100, 900, 500, 300, 500
275
+ s.bezierVertex 100, 900, 900, 900, 900, 600
276
+ s.endShape
277
+ END
278
+ end
279
+
280
+ def test_quadraticVertex()
281
+ assert_equal_draw_vertices <<~END
282
+ s.beginShape
283
+ s.vertex 100, 100
284
+ s.quadraticVertex 800, 500, 200, 800
285
+ s.endShape
286
+ END
287
+
288
+ assert_equal_draw_vertices <<~END
289
+ s.beginShape
290
+ s.vertex 100, 100
291
+ s.quadraticVertex 800, 100, 500, 500
292
+ s.quadraticVertex 100, 800, 800, 800
293
+ s.endShape
294
+ END
295
+ end
296
+
297
+ def test_contour()
298
+ assert_equal_draw_vertices <<~END
299
+ s.beginShape
300
+ s.vertex 100, 100
301
+ s.vertex 100, 900
302
+ s.vertex 900, 900
303
+ s.vertex 900, 100
304
+ s.beginContour
305
+ s.vertex 200, 200
306
+ s.vertex 800, 200
307
+ s.vertex 700, 700
308
+ s.vertex 200, 800
309
+ s.endContour
310
+ s.endShape
311
+ END
312
+ end
313
+
238
314
  def test_getVertex()
239
315
  s = createShape
240
316
  s.beginShape
@@ -288,6 +364,55 @@ class TestShape < Test::Unit::TestCase
288
364
  assert_equal 3, s.getVertexCount
289
365
  end
290
366
 
367
+ def test_fill()
368
+ assert_equal_draw <<~HEADER, <<~EXPECTED, <<~ACTUAL
369
+ noStroke
370
+ HEADER
371
+ fill 0, 255, 0
372
+ rect 100, 100, 500, 400
373
+ EXPECTED
374
+ s = createShape
375
+ s.beginShape
376
+ s.fill 0, 255, 0
377
+ s.vertex 100, 100
378
+ s.vertex 600, 100
379
+ s.vertex 600, 500
380
+ s.vertex 100, 500
381
+ s.endShape
382
+ shape s
383
+ ACTUAL
384
+ end
385
+
386
+ def test_setFill()
387
+ assert_equal_draw <<~HEADER, <<~EXPECTED, <<~ACTUAL
388
+ noStroke
389
+ HEADER
390
+ fill 0, 255, 0
391
+ rect 100, 100, 500, 400
392
+ EXPECTED
393
+ s = createShape
394
+ s.beginShape
395
+ s.vertex 100, 100
396
+ s.vertex 600, 100
397
+ s.vertex 600, 500
398
+ s.vertex 100, 500
399
+ s.endShape
400
+ s.setFill 0, 255, 0
401
+ shape s
402
+ ACTUAL
403
+
404
+ assert_equal_draw <<~HEADER, <<~EXPECTED, <<~ACTUAL
405
+ noStroke
406
+ HEADER
407
+ fill 0, 255, 0
408
+ ellipse 300, 400, 500, 400
409
+ EXPECTED
410
+ s = createShape ELLIPSE, 300, 400, 500, 400
411
+ s.setFill 0, 255, 0
412
+ shape s
413
+ ACTUAL
414
+ end
415
+
291
416
  def test_addChild()
292
417
  group = createShape G::GROUP
293
418
  assert_nil group.getChild(0)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: processing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.31
4
+ version: 0.5.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-09 00:00:00.000000000 Z
11
+ date: 2024-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -30,42 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.42
33
+ version: 0.1.43
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.42
40
+ version: 0.1.43
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rays
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.47
47
+ version: 0.1.48
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.47
54
+ version: 0.1.48
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: reflexion
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.55
61
+ version: 0.1.56
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.1.55
68
+ version: 0.1.56
69
69
  description: Creative Coding Framework has API compatible to Processing or p5.js.
70
70
  email: xordog@gmail.com
71
71
  executables: []