processing 0.5.34 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,94 @@
1
+ require_relative 'helper'
2
+
3
+
4
+ class TestColor < Test::Unit::TestCase
5
+
6
+ P = Processing
7
+ G = P::Graphics
8
+
9
+ def test_rgb_color()
10
+ g = graphics
11
+
12
+ g.colorMode G::RGB, 255
13
+ c = g.color 10, 20, 30, 40
14
+ assert_equal 0x280a141e, c
15
+ assert_equal [10, 20, 30, 40], [g.red(c), g.green(c), g.blue(c), g.alpha(c)]
16
+
17
+ g.colorMode G::RGB, 1.0
18
+ c = g.color 0.1, 0.2, 0.3, 0.4
19
+ assert_equal 0x6619334c, c
20
+ assert_in_delta 0.1, g.red(c), 1 / 256.0
21
+ assert_in_delta 0.2, g.green(c), 1 / 256.0
22
+ assert_in_delta 0.3, g.blue(c), 1 / 256.0
23
+ assert_in_delta 0.4, g.alpha(c), 1 / 256.0
24
+
25
+ g.colorMode G::RGB, 0.5
26
+ c = g.color 0.1, 0.2, 0.3, 0.4
27
+ assert_equal 0xcc336699, c
28
+ assert_in_delta 0.1, g.red(c), 1 / 256.0
29
+ assert_in_delta 0.2, g.green(c), 1 / 256.0
30
+ assert_in_delta 0.3, g.blue(c), 1 / 256.0
31
+ assert_in_delta 0.4, g.alpha(c), 1 / 256.0
32
+ end
33
+
34
+ def test_hsb_color()
35
+ g = graphics
36
+
37
+ g.colorMode G::HSB, 1.0
38
+ c = g.color 0.1, 0.2, 0.3, 0.4
39
+ assert_in_delta 0.1, g.hue(c), 1 / 256.0
40
+ assert_in_delta 0.2, g.saturation(c), 1 / 256.0
41
+ assert_in_delta 0.3, g.brightness(c), 1 / 256.0
42
+ assert_in_delta 0.4, g.alpha(c), 1 / 256.0
43
+
44
+ g.colorMode G::HSB, 0.5
45
+ c = g.color 0.1, 0.2, 0.3, 0.4
46
+ assert_in_delta 0.1, g.hue(c), 1 / 256.0
47
+ assert_in_delta 0.2, g.saturation(c), 1 / 256.0
48
+ assert_in_delta 0.3, g.brightness(c), 1 / 256.0
49
+ assert_in_delta 0.4, g.alpha(c), 1 / 256.0
50
+ end
51
+
52
+ def test_parse_color()
53
+ g = graphics
54
+
55
+ assert_equal 0xff010203, g.color('#010203')
56
+ assert_equal 0x04010203, g.color('#01020304')
57
+ assert_equal 0xff112233, g.color('#123')
58
+ assert_equal 0x44112233, g.color('#1234')
59
+ assert_equal 0xff0000ff, g.color('blue')
60
+ assert_equal 0x040000ff, g.color('blue', 4)
61
+ end
62
+
63
+ def test_color_codes()
64
+ g = graphics
65
+
66
+ assert_equal 0xffff0000, g.color(:red)
67
+ assert_equal 0xff008000, g.color(:GREEN)
68
+ assert_equal 0xff0000ff, g.color('blue')
69
+
70
+ assert_raise(ArgumentError) {g.color :unknown}
71
+ end
72
+
73
+ def test_default_background_color()
74
+ assert_p5_draw '', default_header: '', threshold: THRESHOLD_TO_BE_FIXED
75
+ end
76
+
77
+ def test_default_fill_color()
78
+ assert_p5_draw <<~END, default_header: nil
79
+ background 100
80
+ noStroke
81
+ rect 100, 100, 500, 500
82
+ END
83
+ end
84
+
85
+ def test_default_stroke_color()
86
+ assert_p5_draw <<~END, default_header: nil
87
+ background 100
88
+ noFill
89
+ strokeWeight 50
90
+ line 100, 100, 500, 500
91
+ END
92
+ end
93
+
94
+ end# TestColor
@@ -6,51 +6,6 @@ class TestGraphicsContext < Test::Unit::TestCase
6
6
  P = Processing
7
7
  G = P::Graphics
8
8
 
9
- THRESHOLD_TO_BE_FIXED = 0.0
10
-
11
- def test_rgb_color()
12
- g = graphics
13
-
14
- g.colorMode G::RGB, 255
15
- c = g.color 10, 20, 30, 40
16
- assert_equal 0x280a141e, c
17
- assert_equal [10, 20, 30, 40], [g.red(c), g.green(c), g.blue(c), g.alpha(c)]
18
-
19
- g.colorMode G::RGB, 1.0
20
- c = g.color 0.1, 0.2, 0.3, 0.4
21
- assert_equal 0x6619334c, c
22
- assert_in_delta 0.1, g.red(c), 1 / 256.0
23
- assert_in_delta 0.2, g.green(c), 1 / 256.0
24
- assert_in_delta 0.3, g.blue(c), 1 / 256.0
25
- assert_in_delta 0.4, g.alpha(c), 1 / 256.0
26
-
27
- g.colorMode G::RGB, 0.5
28
- c = g.color 0.1, 0.2, 0.3, 0.4
29
- assert_equal 0xcc336699, c
30
- assert_in_delta 0.1, g.red(c), 1 / 256.0
31
- assert_in_delta 0.2, g.green(c), 1 / 256.0
32
- assert_in_delta 0.3, g.blue(c), 1 / 256.0
33
- assert_in_delta 0.4, g.alpha(c), 1 / 256.0
34
- end
35
-
36
- def test_hsb_color()
37
- g = graphics
38
-
39
- g.colorMode G::HSB, 1.0
40
- c = g.color 0.1, 0.2, 0.3, 0.4
41
- assert_in_delta 0.1, g.hue(c), 1 / 256.0
42
- assert_in_delta 0.2, g.saturation(c), 1 / 256.0
43
- assert_in_delta 0.3, g.brightness(c), 1 / 256.0
44
- assert_in_delta 0.4, g.alpha(c), 1 / 256.0
45
-
46
- g.colorMode G::HSB, 0.5
47
- c = g.color 0.1, 0.2, 0.3, 0.4
48
- assert_in_delta 0.1, g.hue(c), 1 / 256.0
49
- assert_in_delta 0.2, g.saturation(c), 1 / 256.0
50
- assert_in_delta 0.3, g.brightness(c), 1 / 256.0
51
- assert_in_delta 0.4, g.alpha(c), 1 / 256.0
52
- end
53
-
54
9
  def test_colorMode()
55
10
  g = graphics
56
11
  assert_equal G::RGB, g.colorMode
@@ -81,25 +36,37 @@ class TestGraphicsContext < Test::Unit::TestCase
81
36
  assert_raise {g.blendMode LEFT}
82
37
  end
83
38
 
84
- def test_default_background_color()
85
- assert_p5_draw '', default_header: '', threshold: THRESHOLD_TO_BE_FIXED
86
- end
87
-
88
- def test_default_fill_color()
89
- assert_p5_draw <<~END, default_header: nil
90
- background 100
91
- noStroke
92
- rect 100, 100, 500, 500
39
+ def test_strokeCap()
40
+ header = <<~END
41
+ noFill
42
+ strokeWeight 200
93
43
  END
44
+ footer = <<~END
45
+ line 200, 200, 800, 800
46
+ END
47
+ assert_p5_draw header, '', footer
48
+ assert_p5_draw header, 'strokeCap ROUND', footer
49
+ assert_p5_draw header, 'strokeCap SQUARE', footer
50
+ assert_p5_draw header, 'strokeCap PROJECT', footer
94
51
  end
95
52
 
96
- def test_default_stroke_color()
97
- assert_p5_draw <<~END, default_header: nil
98
- background 100
53
+ def test_strokeJoin()
54
+ header = <<~END
99
55
  noFill
100
- strokeWeight 50
101
- line 100, 100, 500, 500
56
+ strokeWeight 200
57
+ strokeCap SQUARE
58
+ END
59
+ footer = <<~END
60
+ beginShape
61
+ vertex 200, 200
62
+ vertex 800, 500
63
+ vertex 200, 800
64
+ endShape
102
65
  END
66
+ assert_p5_draw header, '', footer
67
+ assert_p5_draw header, 'strokeJoin MITER', footer
68
+ assert_p5_draw header, 'strokeJoin BEVEL', footer, threshold: THRESHOLD_TO_BE_FIXED
69
+ assert_p5_draw header, 'strokeJoin ROUND', footer
103
70
  end
104
71
 
105
72
  def test_textFont()
data/test/test_shape.rb CHANGED
@@ -366,14 +366,33 @@ class TestShape < Test::Unit::TestCase
366
366
 
367
367
  def test_fill()
368
368
  assert_equal_draw <<~HEADER, <<~EXPECTED, <<~ACTUAL
369
+ noFill
369
370
  noStroke
370
371
  HEADER
371
- fill 0, 255, 0
372
+ fill 0, 0, 255
372
373
  rect 100, 100, 500, 400
373
374
  EXPECTED
374
375
  s = createShape
375
376
  s.beginShape
376
- s.fill 0, 255, 0
377
+ s.fill 0, 0, 255
378
+ s.vertex 100, 100
379
+ s.vertex 600, 100
380
+ s.vertex 600, 500
381
+ s.vertex 100, 500
382
+ s.endShape
383
+ shape s
384
+ ACTUAL
385
+
386
+ assert_equal_draw <<~HEADER, <<~EXPECTED, <<~ACTUAL
387
+ noFill
388
+ noStroke
389
+ HEADER
390
+ fill 0, 0, 255
391
+ rect 100, 100, 500, 400
392
+ EXPECTED
393
+ fill 0, 0, 255
394
+ s = createShape
395
+ s.beginShape
377
396
  s.vertex 100, 100
378
397
  s.vertex 600, 100
379
398
  s.vertex 600, 500
@@ -383,11 +402,50 @@ class TestShape < Test::Unit::TestCase
383
402
  ACTUAL
384
403
  end
385
404
 
405
+ def test_stroke()
406
+ assert_equal_draw <<~HEADER, <<~EXPECTED, <<~ACTUAL
407
+ noFill
408
+ noStroke
409
+ HEADER
410
+ stroke 0, 0, 255
411
+ rect 100, 100, 500, 400
412
+ EXPECTED
413
+ s = createShape
414
+ s.beginShape
415
+ s.stroke 0, 0, 255
416
+ s.vertex 100, 100
417
+ s.vertex 600, 100
418
+ s.vertex 600, 500
419
+ s.vertex 100, 500
420
+ s.endShape CLOSE
421
+ shape s
422
+ ACTUAL
423
+
424
+ assert_equal_draw <<~HEADER, <<~EXPECTED, <<~ACTUAL
425
+ noFill
426
+ noStroke
427
+ HEADER
428
+ stroke 0, 0, 255
429
+ rect 100, 100, 500, 400
430
+ EXPECTED
431
+ stroke 0, 0, 255
432
+ s = createShape
433
+ s.beginShape
434
+ s.vertex 100, 100
435
+ s.vertex 600, 100
436
+ s.vertex 600, 500
437
+ s.vertex 100, 500
438
+ s.endShape CLOSE
439
+ shape s
440
+ ACTUAL
441
+ end
442
+
386
443
  def test_setFill()
387
444
  assert_equal_draw <<~HEADER, <<~EXPECTED, <<~ACTUAL
445
+ noFill
388
446
  noStroke
389
447
  HEADER
390
- fill 0, 255, 0
448
+ fill 0, 0, 255
391
449
  rect 100, 100, 500, 400
392
450
  EXPECTED
393
451
  s = createShape
@@ -397,18 +455,83 @@ class TestShape < Test::Unit::TestCase
397
455
  s.vertex 600, 500
398
456
  s.vertex 100, 500
399
457
  s.endShape
400
- s.setFill 0, 255, 0
458
+ s.setFill 0, 0, 255
459
+ shape s
460
+ ACTUAL
461
+
462
+ assert_equal_draw <<~HEADER, <<~EXPECTED, <<~ACTUAL
463
+ noFill
464
+ noStroke
465
+ HEADER
466
+ fill 0, 0, 255
467
+ ellipse 300, 400, 500, 400
468
+ EXPECTED
469
+ s = createShape ELLIPSE, 300, 400, 500, 400
470
+ s.setFill 0, 0, 255
471
+ shape s
472
+ ACTUAL
473
+ end
474
+
475
+ def test_setStroke()
476
+ assert_equal_draw <<~HEADER, <<~EXPECTED, <<~ACTUAL
477
+ noFill
478
+ noStroke
479
+ HEADER
480
+ stroke 0, 0, 255
481
+ rect 100, 100, 500, 400
482
+ EXPECTED
483
+ s = createShape
484
+ s.beginShape
485
+ s.vertex 100, 100
486
+ s.vertex 600, 100
487
+ s.vertex 600, 500
488
+ s.vertex 100, 500
489
+ s.endShape CLOSE
490
+ s.setStroke 0, 0, 255
401
491
  shape s
402
492
  ACTUAL
403
493
 
404
494
  assert_equal_draw <<~HEADER, <<~EXPECTED, <<~ACTUAL
495
+ noFill
405
496
  noStroke
406
497
  HEADER
407
- fill 0, 255, 0
498
+ stroke 0, 0, 255
499
+ ellipse 300, 400, 500, 400
500
+ EXPECTED
501
+ s = createShape ELLIPSE, 300, 400, 500, 400
502
+ s.setStroke 0, 0, 255
503
+ shape s
504
+ ACTUAL
505
+ end
506
+
507
+ def test_setStrokeWeight()
508
+ assert_equal_draw <<~HEADER, <<~EXPECTED, <<~ACTUAL
509
+ noFill
510
+ strokeWeight 1
511
+ HEADER
512
+ strokeWeight 100
513
+ rect 100, 100, 500, 400
514
+ EXPECTED
515
+ s = createShape
516
+ s.beginShape
517
+ s.vertex 100, 100
518
+ s.vertex 600, 100
519
+ s.vertex 600, 500
520
+ s.vertex 100, 500
521
+ s.endShape CLOSE
522
+ s.setStrokeWeight 100
523
+ shape s
524
+ ACTUAL
525
+
526
+ assert_equal_draw <<~HEADER, <<~EXPECTED, <<~ACTUAL
527
+ noFill
528
+ strokeWeight 1
529
+ HEADER
530
+ strokeWeight 100
408
531
  ellipse 300, 400, 500, 400
409
532
  EXPECTED
410
533
  s = createShape ELLIPSE, 300, 400, 500, 400
411
- s.setFill 0, 255, 0
534
+ s.setStrokeWeight 100
412
535
  shape s
413
536
  ACTUAL
414
537
  end
data/test/test_svg.rb ADDED
@@ -0,0 +1,257 @@
1
+ require_relative 'helper'
2
+
3
+
4
+ class TestSVG < Test::Unit::TestCase
5
+
6
+ def test_color_code()
7
+ assert_svg_draw '<rect width="500" height="600" fill="#ffaa55"/>'
8
+ assert_svg_draw '<rect width="500" height="600" fill="#ffaa5599"/>'
9
+ assert_svg_draw '<rect width="500" height="600" fill="#fa5"/>'
10
+ assert_svg_draw '<rect width="500" height="600" fill="#fa59"/>'
11
+ assert_svg_draw '<rect width="500" height="600" fill="red"/>'
12
+ end
13
+
14
+ def test_fill()
15
+ assert_svg_draw '<rect width="500" height="600" fill="green"/>'
16
+ end
17
+
18
+ def test_stroke_and_width()
19
+ assert_svg_draw <<~END
20
+ <line x1="200" y1="300" x2="500" y2="600"
21
+ stroke="green" stroke-width="200"/>
22
+ END
23
+ end
24
+
25
+ def test_strokeCap()
26
+ assert_svg_draw <<~END
27
+ <line x1="200" y1="300" x2="500" y2="600"
28
+ stroke="green" stroke-width="200" stroke-linecap="butt"/>
29
+ END
30
+ assert_svg_draw <<~END
31
+ <line x1="200" y1="300" x2="500" y2="600"
32
+ stroke="green" stroke-width="200" stroke-linecap="round"/>
33
+ END
34
+ assert_svg_draw <<~END
35
+ <line x1="200" y1="300" x2="500" y2="600"
36
+ stroke="green" stroke-width="200" stroke-linecap="square"/>
37
+ END
38
+ end
39
+
40
+ def test_strokeJoin()
41
+ assert_svg_draw <<~END
42
+ <path d="M 200,300 L 500,600 L 300,800"
43
+ stroke="green" stroke-width="200" stroke-linejoin="miter"/>
44
+ END
45
+ assert_svg_draw <<~END
46
+ <path d="M 200,300 L 500,600 L 300,800"
47
+ stroke="green" stroke-width="200" stroke-linejoin="miter-clip"/>
48
+ END
49
+ assert_svg_draw <<~END
50
+ <path d="M 200,300 L 500,600 L 300,800"
51
+ stroke="green" stroke-width="200" stroke-linejoin="round"/>
52
+ END
53
+ assert_svg_draw <<~END
54
+ <path d="M 200,300 L 500,600 L 300,800"
55
+ stroke="green" stroke-width="200" stroke-linejoin="bevel"/>
56
+ END
57
+ assert_svg_draw <<~END
58
+ <path d="M 200,300 L 500,600 L 300,800"
59
+ stroke="green" stroke-width="200" stroke-linejoin="arcs"/>
60
+ END
61
+ end
62
+
63
+ def test_line()
64
+ assert_svg_draw <<~END
65
+ <line x1="200" y1="300" x2="500" y2="600" stroke="black" stroke-width="300"/>
66
+ END
67
+ end
68
+
69
+ def test_rect()
70
+ assert_svg_draw '<rect width="500" height="600"/>'
71
+ assert_svg_draw '<rect width="500" height="600" x="100" y="200"/>'
72
+ assert_svg_draw '<rect width="500" height="600" x="100" y="200" rx="100" ry="100"/>'
73
+
74
+ assert_svg_draw <<~END, threshold: THRESHOLD_TO_BE_FIXED
75
+ <rect width="500" height="600" x="100" y="200" rx="100" ry="200"/>
76
+ END
77
+ assert_svg_draw <<~END, threshold: THRESHOLD_TO_BE_FIXED
78
+ <rect width="500" height="600" x="100" y="200" rx="200" ry="100"/>
79
+ END
80
+ end
81
+
82
+ def test_circle()
83
+ assert_svg_draw '<circle cx="500" cy="600" r="200"/>'
84
+ end
85
+
86
+ def test_ellipse()
87
+ assert_svg_draw '<ellipse cx="500" cy="600" rx="200" ry="300"/>'
88
+ end
89
+
90
+ def test_polyline()
91
+ assert_svg_draw <<~END
92
+ <polyline points="200,300 500,400 600,700 300,800" stroke="black" stroke-width="300"/>
93
+ END
94
+ assert_svg_draw <<~END
95
+ <polyline points="200,300 500,400 600,700 300,800" stroke="black" stroke-width="300"
96
+ fill="none"/>
97
+ END
98
+ end
99
+
100
+ def test_polygon()
101
+ assert_svg_draw <<~END
102
+ <polygon points="200,300 500,400 600,700 300,800" stroke="black" stroke-width="200"/>
103
+ END
104
+ assert_svg_draw <<~END
105
+ <polygon points="200,300 500,400 600,700 300,800" stroke="black" stroke-width="200"
106
+ fill="none"/>
107
+ END
108
+ end
109
+
110
+ def test_path_Mm()
111
+ assert_svg_draw path_xml "M 200,300 L 500,400"
112
+ assert_svg_draw path_xml "m 200,300 L 500,400"
113
+ assert_svg_draw path_xml "M 200,300 L 500,400 M 600,700 L 300,800"
114
+ assert_svg_draw path_xml "M 200,300 L 500,400 m 100,300 L 300,800"
115
+ assert_svg_draw path_xml "M 200,300 500,400 600,700 300,800"
116
+ assert_svg_draw path_xml "m 200,300 300,100 100,300 -300,100"
117
+ end
118
+
119
+ def test_path_Ll()
120
+ assert_svg_draw path_xml "M 200,300 L 500,400 L 600,700 L 300,800"
121
+ assert_svg_draw path_xml "M 200,300 L 500,400 600,700 300,800"
122
+ assert_svg_draw path_xml "M 200,300 l 300,100 l 100,300 l -300,100"
123
+ assert_svg_draw path_xml "M 200,300 l 300,100 100,300 -300,100"
124
+ end
125
+
126
+ def test_path_Hh()
127
+ assert_svg_draw path_xml "M 200,300 H 500 H 800"
128
+ assert_svg_draw path_xml "M 200,300 H 500 800"
129
+ assert_svg_draw path_xml "M 200,300 h 300 h 300"
130
+ assert_svg_draw path_xml "M 200,300 h 300 300"
131
+ end
132
+
133
+ def test_path_Vv()
134
+ assert_svg_draw path_xml "M 200,300 V 500 V 800"
135
+ assert_svg_draw path_xml "M 200,300 V 500 800"
136
+ assert_svg_draw path_xml "M 200,300 v 200 h 300"
137
+ assert_svg_draw path_xml "M 200,300 h 200 300"
138
+ end
139
+
140
+ def test_path_Qq()
141
+ assert_svg_draw path_xml "M 200,100 Q 800,300 300,400 Q 400,800 800,800"
142
+ assert_svg_draw path_xml "M 200,100 Q 800,300 300,400 400,800 800,800"
143
+ assert_svg_draw path_xml "M 200,100 q 600,200 100,300 q 100,400 500,400"
144
+ assert_svg_draw path_xml "M 200,100 q 600,200 100,300 100,400 500,400"
145
+ end
146
+
147
+ def test_path_Tt()
148
+ assert_svg_draw path_xml "M 200,100 T 300,400 T 800,800"
149
+ assert_svg_draw path_xml "M 200,100 T 300,400 800,800"
150
+ assert_svg_draw path_xml "M 200,100 t 100,300 t 500,400"
151
+ assert_svg_draw path_xml "M 200,100 t 100,300 500,400"
152
+ end
153
+
154
+ def test_path_Cc()
155
+ assert_svg_draw path_xml "M 200,100 C 800,200 300,300 700,400 C 600,800 300,500 200,700"
156
+ assert_svg_draw path_xml "M 200,100 C 800,200 300,300 700,400 600,800 300,500 200,700"
157
+ assert_svg_draw path_xml "M 200,100 c 600,100 100,200 500,300 c -100,400 -400,100 -500,300"
158
+ assert_svg_draw path_xml "M 200,100 c 600,100 100,200 500,300 -100,400 -400,100 -500,300"
159
+ end
160
+
161
+ def test_path_Ss()
162
+ assert_svg_draw path_xml "M 200,100 S 800,300 500,500 S 800,700 200,900"
163
+ assert_svg_draw path_xml "M 200,100 S 800,300 500,500 800,700 200,900"
164
+ assert_svg_draw path_xml "M 200,100 s 600,200 300,400 s 300,200 -300,400"
165
+ assert_svg_draw path_xml "M 200,100 s 600,200 300,400 300,200 -300,400"
166
+ end
167
+
168
+ def test_path_Aa()
169
+ assert_svg_draw path_xml(<<~END), threshold: THRESHOLD_TO_BE_FIXED
170
+ M 200,100 A 300,200 0 0 0 500,400 A 600,500 0 0 0 900,800
171
+ END
172
+ assert_svg_draw path_xml(<<~END), threshold: THRESHOLD_TO_BE_FIXED
173
+ M 200,100 A 300,200 0 0 0 500,400 600,500 0 0 0 900,800
174
+ END
175
+ assert_svg_draw path_xml(<<~END), threshold: THRESHOLD_TO_BE_FIXED
176
+ M 200,100 a 100,100 0 0 0 300,300 a 100,100 0 0 0 400,400
177
+ END
178
+ assert_svg_draw path_xml(<<~END), threshold: THRESHOLD_TO_BE_FIXED
179
+ M 200,100 a 100,100 0 0 0 300,300 100,100 0 0 0 400,400
180
+ END
181
+ end
182
+
183
+ def test_path_Zz()
184
+ assert_svg_draw path_xml "M 200,300 L 500,400 L 600,700 L 300,800 Z"
185
+ assert_svg_draw path_xml "M 200,300 L 500,400 L 600,700 L 300,800 z"
186
+ end
187
+
188
+ def test_group_fill()
189
+ assert_svg_draw <<~END
190
+ <g>
191
+ <rect x="200" y="300" width="500" height="600" fill="green"/>
192
+ </g>
193
+ END
194
+ assert_svg_draw <<~END
195
+ <g fill="red">
196
+ <rect x="200" y="300" width="500" height="600"/>
197
+ </g>
198
+ END
199
+ assert_svg_draw <<~END
200
+ <g fill="red">
201
+ <rect x="200" y="300" width="500" height="600" fill="green"/>
202
+ </g>
203
+ END
204
+ end
205
+
206
+ def test_group_stroke()
207
+ assert_svg_draw <<~END
208
+ <g>
209
+ <line x1="200" y1="300" x2="500" y2="600"
210
+ stroke-width="200" stroke="green"/>
211
+ </g>
212
+ END
213
+ assert_svg_draw <<~END
214
+ <g stroke="red">
215
+ <line x1="200" y1="300" x2="500" y2="600"
216
+ stroke-width="200"/>
217
+ </g>
218
+ END
219
+ assert_svg_draw <<~END
220
+ <g stroke="red">
221
+ <line x1="200" y1="300" x2="500" y2="600"
222
+ stroke-width="200" stroke="green"/>
223
+ </g>
224
+ END
225
+ end
226
+
227
+ def test_group_stroke_width()
228
+ assert_svg_draw <<~END
229
+ <g>
230
+ <line x1="200" y1="300" x2="500" y2="600" stroke="green" stroke-width="200"/>
231
+ </g>
232
+ END
233
+ assert_svg_draw <<~END
234
+ <g stroke-width="300">
235
+ <line x1="200" y1="300" x2="500" y2="600" stroke="green" />
236
+ </g>
237
+ END
238
+ assert_svg_draw <<~END
239
+ <g stroke-width="300">
240
+ <line x1="200" y1="300" x2="500" y2="600" stroke="green" stroke-width="400"/>
241
+ </g>
242
+ END
243
+ end
244
+
245
+ def test_path_data_shorthand()
246
+ assert_svg_draw path_xml "M200,300L500,400L600,700L300,800"
247
+ assert_svg_draw path_xml "M 200,300 l 500.99.400 0,200 -200,0.99.300,200"
248
+ assert_svg_draw path_xml "M 200,800 l 500-200-200-200-300-300"
249
+ end
250
+
251
+ def path_xml(d)
252
+ <<~END
253
+ <path fill="none" stroke="black" stroke-width="100" d="#{d}"/>
254
+ END
255
+ end
256
+
257
+ end# TestSVG