on master help sign in
Switch to matrix representation of transformations.
commit481c2daab8a9ea92b0395dab15f57244c220c5b5 authorevancz <info@elm-lang.org> dateFri 15 Mar 2013, 10:56 (14 years ago) parent6761fbb
1 file changed+12−17
libraries/Graphics/Collage.elm+12−17
libraries/Graphics/Collage.elm+12−17
@@ -3,15 +3,10 @@ module Graphics.Collage where
33
44import Either
55import Graphics.LineStyle as LS
6−import Geometry
6+import Graphics.Geometry
7+import Graphics.Matrix as Matrix
78
8−data Transform
9− = Rotate Float
10− | Move Float Float
11− | Scale Float Float
12− | Transform Float Float Float Float Float Float
13−
14−type Form = { transforms : [Transform], form : BasicForm }
9+type Form = { transform : Matrix, form : BasicForm }
1510
1611data FillStyle
1712 = NoFill
@@ -45,20 +40,20 @@ toForm e = Form [] (FElement e)
4540
4641group fs = Form [] (FGroup fs)
4742
48−add t f = { transforms = t :: f.transforms, form = f.form }
43+add t f = { transforms = Matrix.multiply t f.transforms, form = f.form }
4944
5045radians t = t
5146degrees dep = pi * deg / 180
5247rotations rot = 2 * pi * rot
5348
54−rotate t = add (Rotate t)
49+rotate t = add (Matrix.rotate t)
5550
56−scale s = add (Scale s s)
57−scaleX s = add (Scale s 1)
58−scaleY s = add (Scale 1 s)
51+scale s = add (Matrix.scale s s)
52+scaleX s = add (Matrix.scale s 1)
53+scaleY s = add (Matrix.scale 1 s)
5954
60−move x y = add (Move x y)
61−moveX x = add (Move x 0)
62−moveY y = add (Move 0 y)
55+move x y = add (Matrix.translate x y)
56+moveX x = add (Matrix.translate x 0)
57+moveY y = add (Matrix.translate 0 y)
6358
64−transform a b c d e f = add (Transform a b c d e f)
59+transform a b c d e f = add (Matrix.matrix a b c d e f)