@@ -5,6 +5,7 @@
55module Graphics.Geometry where
66
77import List
8+import Native.Utils (toFloat)
89
910type Path = [(Float,Float)]
1011
@@ -19,12 +20,16 @@ rect w h = [ (0-w/2,0-h/2), (0-w/2,h/2), (w/2,h/2), (w/2,0-h/2) ]
1920
2021oval w h =
2122 let n = 50
22− f i = (w/2 * Math.cos (2*Math.pi/n * i), h/2 * Math.sin (2*Math.pi/n * i))
23+ t = 2 * Math.PI / n
24+ hw = w/2
25+ hh = h/2
26+ f i = (hw * Math.cos (t*i), hh * Math.sin (t*i))
2327 in map f [0..n-1]
2428
2529circle r = oval (2*r) (2*r)
2630
2731ngon n r =
2832 let m = toFloat n
29− f i = ( r * Math.cos (2*Math.pi/m * i), r * Math.sin (2*Math.pi/m * i))
33+ t = 2 * Math.PI / m
34+ f i = ( r * Math.cos (t*i), r * Math.sin (t*i) )
3035 in map f [0..n-1]