@@ -1,8 +1,9 @@
11
22module Graphics.Collage where
33
4+import List
5+import Native.Utils (toFloat)
46import Either
5−import Graphics.Geometry
67import Native.Matrix2D as Matrix
78import Native.Graphics.Collage as N
89import Graphics.Element
@@ -96,3 +97,39 @@ moveX x f = { f | x <- f.x + x }
9697moveY y f = { f | y <- f.y + y }
9798
9899collage : Int -> Int -> [Form] -> Element
100+
101+
102+type Path = [(Float,Float)]
103+
104+path : [(Number a,Number a)] -> Path
105+path ps = ps
106+
107+segment : (Number a,Number a) -> (Number a,Number a) -> Path
108+segment p1 p2 = [p1,p2]
109+
110+type Shape = [(Float,Float)]
111+
112+polygon : [(Number a,Number a)] -> Shape
113+polygon points = points
114+
115+rect : Number a -> Number a -> Shape
116+rect w h = [ (0-w/2,0-h/2), (0-w/2,h/2), (w/2,h/2), (w/2,0-h/2) ]
117+
118+oval : Number a -> Number a -> Shape
119+oval w h =
120+ let n = 50
121+ t = 2 * Math.PI / n
122+ hw = w/2
123+ hh = h/2
124+ f i = (hw * Math.cos (t*i), hh * Math.sin (t*i))
125+ in map f [0..n-1]
126+
127+circle : Number a -> Shape
128+circle r = oval (2*r) (2*r)
129+
130+ngon : Int -> Number a -> Shape
131+ngon n r =
132+ let m = toFloat n
133+ t = 2 * Math.PI / m
134+ f i = ( r * Math.cos (t*i), r * Math.sin (t*i) )
135+ in map f [0..n-1]