1 ! (c)2009 Joe Groff, see BSD license
2 USING: accessors literals math math.affine-transforms
3 math.functions math.trig multiline sequences svg tools.test xml
7 ${ { 1.0 2.25 } { -3.0 4.0 } { 5.5 0.5 } <affine-transform> } [
8 "matrix ( 1 +2.25 -3 , 0.4e+1 ,5.5, 5e-1 )" svg-transform>affine-transform
11 ${ { 1.0 0.0 } { 0.0 1.0 } { 5.0 10.0 } <affine-transform> } [
12 "translate(5.0, 1e1 )" svg-transform>affine-transform
15 ${ { 1.0 0.0 } { 0.0 1.0 } { 5.0 10.0 } <affine-transform> } [
16 "translate( 5.0 1e+1)" svg-transform>affine-transform
19 ${ { 2.0 0.0 } { 0.0 2.0 } { 0.0 0.0 } <affine-transform> } [
20 "scale(2.0)" svg-transform>affine-transform
23 ${ { 2.0 0.0 } { 0.0 4.0 } { 0.0 0.0 } <affine-transform> } [
24 "scale(2.0 4.0)" svg-transform>affine-transform
27 ${ { 2.0 0.0 } { 0.0 4.0 } { 0.0 0.0 } <affine-transform> } [
28 "scale(2.0 4.0)" svg-transform>affine-transform
32 "skewX(45)" svg-transform>affine-transform
33 { 1.0 0.0 } { 1.0 1.0 } { 0.0 0.0 } <affine-transform> 0.001 a~
37 "skewY(-4.5e1)" svg-transform>affine-transform
38 { 1.0 -1.0 } { 0.0 1.0 } { 0.0 0.0 } <affine-transform> 0.001 a~
42 "rotate(30)" svg-transform>affine-transform
43 { $[ 0.75 sqrt ] 0.5 }
44 { -0.5 $[ 0.75 sqrt ] }
45 { 0.0 0.0 } <affine-transform>
50 "rotate(30 1.0,2.0)" svg-transform>affine-transform
51 { $[ 30 deg>rad cos ] $[ 30 deg>rad sin ] }
52 { $[ -30 deg>rad sin ] $[ 30 deg>rad cos ] } {
53 $[ 1.0 30 deg>rad cos 1.0 * - 30 deg>rad sin 2.0 * + ]
54 $[ 2.0 30 deg>rad cos 2.0 * - 30 deg>rad sin 1.0 * - ]
55 } <affine-transform> 0.001 a~
59 { $[ 30 deg>rad cos ] $[ 30 deg>rad sin ] }
60 { $[ -30 deg>rad sin ] $[ 30 deg>rad cos ] }
61 { 1.0 2.0 } <affine-transform>
63 "translate(1 2) rotate(30)" svg-transform>affine-transform
67 T{ moveto f { 1.0 1.0 } f }
68 T{ lineto f { 3.0 -1.0 } f }
70 T{ lineto f { 2.0 2.0 } t }
71 T{ lineto f { 2.0 -2.0 } t }
72 T{ lineto f { 2.0 2.0 } t }
74 T{ vertical-lineto f -9.0 t }
75 T{ vertical-lineto f 1.0 t }
76 T{ horizontal-lineto f 9.0 f }
77 T{ horizontal-lineto f 8.0 f }
81 T{ moveto f { 0.0 0.0 } f }
83 T{ curveto f { -4.0 0.0 } { -8.0 4.0 } { -8.0 8.0 } f }
84 T{ curveto f { -8.0 4.0 } { -12.0 8.0 } { -16.0 8.0 } f }
86 T{ smooth-curveto f { 0.0 2.0 } { 2.0 0.0 } t }
88 T{ quadratic-bezier-curveto f { -2.0 0.0 } { 0.0 -2.0 } f }
89 T{ quadratic-bezier-curveto f { -3.0 0.0 } { 0.0 3.0 } f }
91 T{ smooth-quadratic-bezier-curveto f { 1.0 2.0 } t }
92 T{ smooth-quadratic-bezier-curveto f { 3.0 4.0 } t }
94 T{ elliptical-arc f { 5.0 6.0 } 7.0 t f { 8.0 9.0 } f }
97 M 1.0,+1 3,-10e-1 l 2 2, 2 -2, 2 2 v -9 1 H 9 8 z
98 M 0 0 C -4.0 0.0 -8.0 4.0 -8.0 8.0 -8.0 4.0 -12.0 8.0 -16.0 8.0
100 Q -2 0 0 -2 -3. 0 0 3
106 STRING: test-svg-string
107 <svg xmlns="http://www.w3.org/2000/svg">
108 <path transform="translate(1 2)" d="M -1 -1 l 2 2" />
112 : test-svg-path ( -- obj )
113 test-svg-string string>xml body>> children-tags first ;
115 { { T{ moveto f { -1.0 -1.0 } f } T{ lineto f { 2.0 2.0 } t } } }
116 [ test-svg-path tag-d ] unit-test
118 { T{ affine-transform f { 1.0 0.0 } { 0.0 1.0 } { 1.0 2.0 } } }
119 [ test-svg-path tag-transform ] unit-test