processing 0.5.30 → 0.5.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test-draw.yml +0 -1
- data/.github/workflows/test.yml +0 -1
- data/ChangeLog.md +11 -0
- data/Rakefile +14 -6
- data/VERSION +1 -1
- data/lib/processing/all.rb +1 -0
- data/lib/processing/graphics_context.rb +240 -16
- data/lib/processing/shape.rb +183 -0
- data/lib/processing/vector.rb +3 -3
- data/processing.gemspec +4 -4
- data/test/helper.rb +86 -3
- data/test/{draw/p5.rb → p5.rb} +17 -4
- data/test/test_graphics.rb +1 -7
- data/test/test_graphics_context.rb +451 -5
- data/test/test_shape.rb +387 -0
- data/test/test_vector.rb +1 -1
- metadata +15 -16
- data/test/draw/helper.rb +0 -31
- data/test/draw/test_draw.rb +0 -22
data/test/test_shape.rb
ADDED
@@ -0,0 +1,387 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
|
4
|
+
class TestShape < Test::Unit::TestCase
|
5
|
+
|
6
|
+
P = Processing
|
7
|
+
G = P::GraphicsContext
|
8
|
+
|
9
|
+
def createShape(kind = nil, *args, g: graphics)
|
10
|
+
g.createShape kind, *args
|
11
|
+
end
|
12
|
+
|
13
|
+
def vec(*args)
|
14
|
+
P::Vector.new(*args)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_size()
|
18
|
+
assert_equal [0, 0], createShape .then {|s| [s.w, s.h]}
|
19
|
+
assert_equal [30, 50], createShape(G::RECT, 10, 20, 30, 50).then {|s| [s.w, s.h]}
|
20
|
+
assert_equal [20, 30], createShape(G::LINE, 10, 20, 30, 50).then {|s| [s.w, s.h]}
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_visibility()
|
24
|
+
gfx = graphics 100, 100 do |g|
|
25
|
+
g.background 0
|
26
|
+
end
|
27
|
+
assert_equal 1, get_pixels(gfx).uniq.size
|
28
|
+
|
29
|
+
gfx = graphics 100, 100 do |g|
|
30
|
+
s = createShape G::RECT, 10, 20, 30, 40, g: g
|
31
|
+
assert_true s.isVisible
|
32
|
+
assert_true s.visible?
|
33
|
+
|
34
|
+
g.background 0
|
35
|
+
g.fill 255
|
36
|
+
g.noStroke
|
37
|
+
g.shape s
|
38
|
+
end
|
39
|
+
assert_equal 2, get_pixels(gfx).uniq.size
|
40
|
+
|
41
|
+
gfx = graphics 100, 100 do |g|
|
42
|
+
s = createShape G::RECT, 10, 20, 30, 40, g: g
|
43
|
+
s.setVisible false
|
44
|
+
assert_false s.isVisible
|
45
|
+
assert_false s.visible?
|
46
|
+
|
47
|
+
g.background 0
|
48
|
+
g.fill 255
|
49
|
+
g.noStroke
|
50
|
+
g.shape s
|
51
|
+
end
|
52
|
+
assert_equal 1, get_pixels(gfx).uniq.size
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_beginShape_points()
|
56
|
+
assert_equal_draw_vertices 'strokeWeight 200', <<~END
|
57
|
+
s.beginShape POINTS
|
58
|
+
s.vertex 200, 300
|
59
|
+
s.vertex 500, 600
|
60
|
+
s.endShape
|
61
|
+
END
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_beginShape_lines()
|
65
|
+
assert_equal_draw_vertices 'strokeWeight 200', <<~END
|
66
|
+
s.beginShape LINES
|
67
|
+
s.vertex 100, 200
|
68
|
+
s.vertex 300, 400
|
69
|
+
s.vertex 500, 600
|
70
|
+
s.vertex 700, 800
|
71
|
+
s.endShape
|
72
|
+
END
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_beginShape_triangles()
|
76
|
+
assert_equal_draw_vertices <<~END
|
77
|
+
s.beginShape TRIANGLES
|
78
|
+
s.vertex 100, 100
|
79
|
+
s.vertex 100, 500
|
80
|
+
s.vertex 400, 200
|
81
|
+
s.vertex 500, 100
|
82
|
+
s.vertex 500, 500
|
83
|
+
s.vertex 900, 200
|
84
|
+
s.endShape
|
85
|
+
END
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_beginShape_triangle_fan()
|
89
|
+
assert_equal_draw_vertices <<~END
|
90
|
+
s.beginShape TRIANGLE_FAN
|
91
|
+
s.vertex 100, 100
|
92
|
+
s.vertex 100, 500
|
93
|
+
s.vertex 200, 600
|
94
|
+
s.vertex 300, 500
|
95
|
+
s.vertex 400, 600
|
96
|
+
s.vertex 500, 200
|
97
|
+
s.vertex 400, 100
|
98
|
+
s.endShape
|
99
|
+
END
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_beginShape_triangle_strip()
|
103
|
+
assert_equal_draw_vertices <<~END
|
104
|
+
s.beginShape TRIANGLE_STRIP
|
105
|
+
s.vertex 100, 100
|
106
|
+
s.vertex 100, 900
|
107
|
+
s.vertex 500, 200
|
108
|
+
s.vertex 500, 800
|
109
|
+
s.vertex 900, 100
|
110
|
+
s.vertex 900, 900
|
111
|
+
s.endShape
|
112
|
+
END
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_beginShape_quads()
|
116
|
+
assert_equal_draw_vertices <<~END
|
117
|
+
s.beginShape QUADS
|
118
|
+
s.vertex 100, 100
|
119
|
+
s.vertex 200, 500
|
120
|
+
s.vertex 300, 400
|
121
|
+
s.vertex 400, 200
|
122
|
+
s.vertex 500, 100
|
123
|
+
s.vertex 600, 500
|
124
|
+
s.vertex 700, 400
|
125
|
+
s.vertex 800, 200
|
126
|
+
s.endShape
|
127
|
+
END
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_beginShape_quad_strip()
|
131
|
+
assert_equal_draw_vertices <<~END
|
132
|
+
s.beginShape QUAD_STRIP
|
133
|
+
s.vertex 100, 100
|
134
|
+
s.vertex 100, 500
|
135
|
+
s.vertex 500, 200
|
136
|
+
s.vertex 500, 400
|
137
|
+
s.vertex 900, 100
|
138
|
+
s.vertex 900, 500
|
139
|
+
s.endShape
|
140
|
+
END
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_beginShape_tess()
|
144
|
+
assert_equal_draw_vertices <<~END
|
145
|
+
s.beginShape TESS
|
146
|
+
s.vertex 100, 100
|
147
|
+
s.vertex 100, 500
|
148
|
+
s.vertex 500, 500
|
149
|
+
s.vertex 500, 400
|
150
|
+
s.vertex 300, 400
|
151
|
+
s.vertex 300, 300
|
152
|
+
s.vertex 500, 300
|
153
|
+
s.vertex 500, 100
|
154
|
+
s.endShape
|
155
|
+
END
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_beginShape_polygon()
|
159
|
+
assert_equal_draw_vertices <<~END
|
160
|
+
s.beginShape
|
161
|
+
s.vertex 100, 100
|
162
|
+
s.vertex 100, 500
|
163
|
+
s.vertex 500, 500
|
164
|
+
s.vertex 500, 400
|
165
|
+
s.vertex 300, 400
|
166
|
+
s.vertex 300, 300
|
167
|
+
s.vertex 500, 300
|
168
|
+
s.vertex 500, 100
|
169
|
+
s.endShape
|
170
|
+
END
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_beginShape_twice()
|
174
|
+
first, second = <<~FIRST, <<~SECOND
|
175
|
+
s.vertex 100, 100
|
176
|
+
s.vertex 100, 500
|
177
|
+
s.vertex 400, 500
|
178
|
+
s.vertex 400, 300
|
179
|
+
FIRST
|
180
|
+
s.vertex 500, 300
|
181
|
+
s.vertex 500, 500
|
182
|
+
s.vertex 800, 500
|
183
|
+
s.vertex 800, 100
|
184
|
+
SECOND
|
185
|
+
|
186
|
+
assert_equal_draw <<~EXPECTED, <<~ACTUAL
|
187
|
+
s = self
|
188
|
+
s.beginShape
|
189
|
+
#{first}
|
190
|
+
#{second}
|
191
|
+
s.endShape
|
192
|
+
EXPECTED
|
193
|
+
s = createShape
|
194
|
+
s.beginShape
|
195
|
+
#{first}
|
196
|
+
s.endShape
|
197
|
+
s.beginShape
|
198
|
+
#{second}
|
199
|
+
s.endShape
|
200
|
+
shape s
|
201
|
+
ACTUAL
|
202
|
+
|
203
|
+
assert_equal_draw <<~EXPECTED, <<~ACTUAL
|
204
|
+
s = self
|
205
|
+
s.beginShape
|
206
|
+
#{first}
|
207
|
+
#{second}
|
208
|
+
s.endShape CLOSE
|
209
|
+
EXPECTED
|
210
|
+
s = createShape
|
211
|
+
s.beginShape
|
212
|
+
#{first}
|
213
|
+
s.endShape
|
214
|
+
s.beginShape
|
215
|
+
#{second}
|
216
|
+
s.endShape CLOSE
|
217
|
+
shape s
|
218
|
+
ACTUAL
|
219
|
+
|
220
|
+
assert_equal_draw <<~EXPECTED, <<~ACTUAL
|
221
|
+
s = self
|
222
|
+
s.beginShape
|
223
|
+
#{first}
|
224
|
+
#{second}
|
225
|
+
s.endShape
|
226
|
+
EXPECTED
|
227
|
+
s = createShape
|
228
|
+
s.beginShape TRIANGLES
|
229
|
+
#{first}
|
230
|
+
s.endShape
|
231
|
+
s.beginShape
|
232
|
+
#{second}
|
233
|
+
s.endShape
|
234
|
+
shape s
|
235
|
+
ACTUAL
|
236
|
+
end
|
237
|
+
|
238
|
+
def test_getVertex()
|
239
|
+
s = createShape
|
240
|
+
s.beginShape
|
241
|
+
s.vertex 1, 2
|
242
|
+
s.vertex 3, 4
|
243
|
+
s.vertex 5, 6
|
244
|
+
s.endShape
|
245
|
+
|
246
|
+
assert_equal vec(1, 2), s.getVertex(0)
|
247
|
+
assert_equal vec(3, 4), s.getVertex(1)
|
248
|
+
assert_equal vec(5, 6), s.getVertex(-1)
|
249
|
+
assert_equal vec(3, 4), s.getVertex(-2)
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_setVertex()
|
253
|
+
s = createShape
|
254
|
+
s.beginShape
|
255
|
+
s.vertex 1, 2
|
256
|
+
s.vertex 3, 4
|
257
|
+
s.vertex 5, 6
|
258
|
+
s.endShape
|
259
|
+
|
260
|
+
points = -> do
|
261
|
+
s.getVertexCount.times.map {|i|
|
262
|
+
s.getVertex(i).then {|v| [v.x, v.y]}
|
263
|
+
}.flatten
|
264
|
+
end
|
265
|
+
|
266
|
+
s.setVertex(0, vec(7, 8))
|
267
|
+
assert_equal [7, 8, 3, 4, 5, 6], points.call
|
268
|
+
|
269
|
+
s.setVertex(-1, vec(9, 10))
|
270
|
+
assert_equal [7, 8, 3, 4, 9, 10], points.call
|
271
|
+
end
|
272
|
+
|
273
|
+
def test_getVertexCount()
|
274
|
+
s = createShape
|
275
|
+
s.beginShape G::TRIANGLES
|
276
|
+
assert_equal 0, s.getVertexCount
|
277
|
+
|
278
|
+
s.vertex 1, 2
|
279
|
+
assert_equal 1, s.getVertexCount
|
280
|
+
|
281
|
+
s.vertex 3, 4
|
282
|
+
assert_equal 2, s.getVertexCount
|
283
|
+
|
284
|
+
s.vertex 5, 6
|
285
|
+
assert_equal 3, s.getVertexCount
|
286
|
+
|
287
|
+
s.endShape
|
288
|
+
assert_equal 3, s.getVertexCount
|
289
|
+
end
|
290
|
+
|
291
|
+
def test_addChild()
|
292
|
+
group = createShape G::GROUP
|
293
|
+
assert_nil group.getChild(0)
|
294
|
+
|
295
|
+
rect = createShape G::RECT, 100, 100, 200, 300
|
296
|
+
group.addChild rect
|
297
|
+
assert_equal 1, group.getChildCount
|
298
|
+
assert_equal rect, group.getChild(0)
|
299
|
+
end
|
300
|
+
|
301
|
+
def test_addChild_to_non_group_shape()
|
302
|
+
s = createShape
|
303
|
+
assert_equal 0, s.getChildCount
|
304
|
+
|
305
|
+
assert_nothing_raised {
|
306
|
+
s.addChild createShape(G::RECT, 100, 100, 200, 300)
|
307
|
+
}
|
308
|
+
assert_equal 0, s.getChildCount
|
309
|
+
end
|
310
|
+
|
311
|
+
def test_getChildCount()
|
312
|
+
s = createShape G::GROUP
|
313
|
+
assert_equal 0, s.getChildCount
|
314
|
+
|
315
|
+
s.addChild createShape
|
316
|
+
assert_equal 1, s.getChildCount
|
317
|
+
|
318
|
+
s.addChild createShape
|
319
|
+
assert_equal 2, s.getChildCount
|
320
|
+
end
|
321
|
+
|
322
|
+
def test_translate()
|
323
|
+
assert_equal_draw <<~EXPECTED, <<~ACTUAL
|
324
|
+
translate 100, 200
|
325
|
+
rect 0, 0, 300, 400
|
326
|
+
EXPECTED
|
327
|
+
s = createShape RECT, 0, 0, 300, 400
|
328
|
+
s.translate 100, 200
|
329
|
+
shape s
|
330
|
+
ACTUAL
|
331
|
+
end
|
332
|
+
|
333
|
+
def test_rotate()
|
334
|
+
assert_equal_draw <<~EXPECTED, <<~ACTUAL
|
335
|
+
rotate PI / 10
|
336
|
+
rect 100, 200, 300, 400
|
337
|
+
EXPECTED
|
338
|
+
s = createShape RECT, 100, 200, 300, 400
|
339
|
+
s.rotate PI / 10
|
340
|
+
shape s
|
341
|
+
ACTUAL
|
342
|
+
end
|
343
|
+
|
344
|
+
def test_scale()
|
345
|
+
assert_equal_draw <<~EXPECTED, <<~ACTUAL
|
346
|
+
scale 0.5, 0.6
|
347
|
+
rect 100, 200, 300, 400
|
348
|
+
EXPECTED
|
349
|
+
s = createShape RECT, 100, 200, 300, 400
|
350
|
+
s.scale 0.5, 0.6
|
351
|
+
shape s
|
352
|
+
ACTUAL
|
353
|
+
end
|
354
|
+
|
355
|
+
def test_sequential_transformation()
|
356
|
+
assert_equal_draw <<~EXPECTED, <<~ACTUAL
|
357
|
+
translate 100, 200
|
358
|
+
rotate PI / 4
|
359
|
+
scale 0.5, 0.6
|
360
|
+
translate 100, 200
|
361
|
+
rotate(-PI / 4)
|
362
|
+
scale 2, 3
|
363
|
+
rect 0, 0, 300, 400
|
364
|
+
EXPECTED
|
365
|
+
s = createShape RECT, 0, 0, 300, 400
|
366
|
+
s.translate 100, 200
|
367
|
+
s.rotate PI / 4
|
368
|
+
s.scale 0.5, 0.6
|
369
|
+
s.translate 100, 200
|
370
|
+
s.rotate(-PI / 4)
|
371
|
+
s.scale 2, 3
|
372
|
+
shape s
|
373
|
+
ACTUAL
|
374
|
+
end
|
375
|
+
|
376
|
+
def assert_equal_draw_vertices(*shared_header, source)
|
377
|
+
assert_equal_draw(*shared_header, <<~EXPECTED, <<~ACTUAL, label: test_label)
|
378
|
+
s = self
|
379
|
+
#{source}
|
380
|
+
EXPECTED
|
381
|
+
s = createShape
|
382
|
+
#{source}
|
383
|
+
shape s
|
384
|
+
ACTUAL
|
385
|
+
end
|
386
|
+
|
387
|
+
end# TestShape
|
data/test/test_vector.rb
CHANGED
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.
|
4
|
+
version: 0.5.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xot
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.
|
19
|
+
version: 0.1.41
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1.
|
26
|
+
version: 0.1.41
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rucy
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.
|
33
|
+
version: 0.1.42
|
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.
|
40
|
+
version: 0.1.42
|
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
|
+
version: 0.1.47
|
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.
|
54
|
+
version: 0.1.47
|
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.
|
61
|
+
version: 0.1.55
|
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.
|
68
|
+
version: 0.1.55
|
69
69
|
description: Creative Coding Framework has API compatible to Processing or p5.js.
|
70
70
|
email: xordog@gmail.com
|
71
71
|
executables: []
|
@@ -106,20 +106,20 @@ files:
|
|
106
106
|
- lib/processing/graphics_context.rb
|
107
107
|
- lib/processing/image.rb
|
108
108
|
- lib/processing/shader.rb
|
109
|
+
- lib/processing/shape.rb
|
109
110
|
- lib/processing/touch.rb
|
110
111
|
- lib/processing/vector.rb
|
111
112
|
- lib/processing/window.rb
|
112
113
|
- processing.gemspec
|
113
|
-
- test/draw/helper.rb
|
114
|
-
- test/draw/p5.rb
|
115
|
-
- test/draw/test_draw.rb
|
116
114
|
- test/helper.rb
|
115
|
+
- test/p5.rb
|
117
116
|
- test/test_capture.rb
|
118
117
|
- test/test_font.rb
|
119
118
|
- test/test_graphics.rb
|
120
119
|
- test/test_graphics_context.rb
|
121
120
|
- test/test_image.rb
|
122
121
|
- test/test_shader.rb
|
122
|
+
- test/test_shape.rb
|
123
123
|
- test/test_text_bounds.rb
|
124
124
|
- test/test_touch.rb
|
125
125
|
- test/test_utility.rb
|
@@ -148,16 +148,15 @@ signing_key:
|
|
148
148
|
specification_version: 4
|
149
149
|
summary: Processing compatible Creative Coding Framework.
|
150
150
|
test_files:
|
151
|
-
- test/draw/helper.rb
|
152
|
-
- test/draw/p5.rb
|
153
|
-
- test/draw/test_draw.rb
|
154
151
|
- test/helper.rb
|
152
|
+
- test/p5.rb
|
155
153
|
- test/test_capture.rb
|
156
154
|
- test/test_font.rb
|
157
155
|
- test/test_graphics.rb
|
158
156
|
- test/test_graphics_context.rb
|
159
157
|
- test/test_image.rb
|
160
158
|
- test/test_shader.rb
|
159
|
+
- test/test_shape.rb
|
161
160
|
- test/test_text_bounds.rb
|
162
161
|
- test/test_touch.rb
|
163
162
|
- test/test_utility.rb
|
data/test/draw/helper.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'digest/md5'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
require_relative '../helper'
|
5
|
-
require_relative 'p5'
|
6
|
-
|
7
|
-
|
8
|
-
def md5(s)
|
9
|
-
Digest::MD5.hexdigest s
|
10
|
-
end
|
11
|
-
|
12
|
-
def mkdir(dir: nil, filename: nil)
|
13
|
-
path = dir || File.dirname(filename)
|
14
|
-
FileUtils.mkdir_p path unless File.exist? path
|
15
|
-
end
|
16
|
-
|
17
|
-
def assert_draw(width = 100, height = 100, draw_src, threshold: 1.0)
|
18
|
-
path = File.join __dir__, "p5rb", "#{md5(draw_src)}.png"
|
19
|
-
mkdir filename: path
|
20
|
-
density = draw_p5rb width, height, draw_src, path, headless: false
|
21
|
-
gfx = graphics(width, height, density).tap do |g|
|
22
|
-
g.beginDraw do
|
23
|
-
g.background 0
|
24
|
-
g.fill 255, 0, 0
|
25
|
-
g.noStroke
|
26
|
-
g.instance_eval draw_src
|
27
|
-
end
|
28
|
-
end
|
29
|
-
gfx.save path.sub(/\.png$/, '.actual.png')
|
30
|
-
assert_equal_pixels gfx.loadImage(path), gfx, threshold: threshold
|
31
|
-
end
|
data/test/draw/test_draw.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require_relative 'helper'
|
2
|
-
|
3
|
-
|
4
|
-
class TestDraw < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def test_rect()
|
7
|
-
assert_draw 'rect 10, 20, 30, 40'
|
8
|
-
assert_draw 'rectMode CORNER; rect 10, 20, 30, 40'
|
9
|
-
assert_draw 'rectMode CORNERS; rect 10, 20, 30, 50'
|
10
|
-
assert_draw 'rectMode CENTER; rect 40, 50, 30, 40'
|
11
|
-
assert_draw 'rectMode RADIUS; rect 40, 50, 30, 40'
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_ellipse()
|
15
|
-
assert_draw 'ellipse 40, 50, 30, 40', threshold: 0.98
|
16
|
-
assert_draw 'ellipseMode CORNER; ellipse 10, 20, 30, 40', threshold: 0.98
|
17
|
-
assert_draw 'ellipseMode CORNERS; ellipse 10, 20, 30, 50', threshold: 0.98
|
18
|
-
assert_draw 'ellipseMode CENTER; ellipse 40, 50, 30, 40', threshold: 0.98
|
19
|
-
assert_draw 'ellipseMode RADIUS; ellipse 40, 50, 30, 40', threshold: 0.98
|
20
|
-
end
|
21
|
-
|
22
|
-
end# TestDraw
|