on master help sign in
Switch to matrix representation of transformations.
481c2daevancz
libraries/Graphics/Collage.elm+12−17
@@ -3,15 +3,10 @@ module Graphics.Collage where
3
3
4import Either
4import Either
5import Graphics.LineStyle as LS
5import Graphics.LineStyle as LS
6−import Geometry
6+import Graphics.Geometry
7+import Graphics.Matrix as Matrix
7
8
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 }
15
10
16data FillStyle
11data FillStyle
17 = NoFill
12 = NoFill
@@ -45,20 +40,20 @@ toForm e = Form [] (FElement e)
45
40
46group fs = Form [] (FGroup fs)
41group fs = Form [] (FGroup fs)
47
42
48−add t f = { transforms = t :: f.transforms, form = f.form }
43+add t f = { transforms = Matrix.multiply t f.transforms, form = f.form }
49
44
50radians t = t
45radians t = t
51degrees dep = pi * deg / 180
46degrees dep = pi * deg / 180
52rotations rot = 2 * pi * rot
47rotations rot = 2 * pi * rot
53
48
54−rotate t = add (Rotate t)
49+rotate t = add (Matrix.rotate t)
55
50
56−scale s = add (Scale s s)
51+scale s = add (Matrix.scale s s)
57−scaleX s = add (Scale s 1)
52+scaleX s = add (Matrix.scale s 1)
58−scaleY s = add (Scale 1 s)
53+scaleY s = add (Matrix.scale 1 s)
59
54
60−move x y = add (Move x y)
55+move x y = add (Matrix.translate x y)
61−moveX x = add (Move x 0)
56+moveX x = add (Matrix.translate x 0)
62−moveY y = add (Move 0 y)
57+moveY y = add (Matrix.translate 0 y)
63
58
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)