on 263bf1c help sign in
elk/libraries/Graphics/Geometry.elm
28 lines 611 B history raw
1-- Paths and Shapes.
2-- These structures are purely geometric forms, no colors or styles.
3-- Could be the basis of some cool geometry stuff :)
5module Geometry where
7data Path = Path [(Float,Float)]
9path = Path
10segment p1 p2 = Path [p1,p2]
12type Shape = [(Float,Float)]
14polygon points = points
16rect w h = [ (0-w/2,0-h/2), (0-w/2,h/2), (w/2,h/2), (w/2,0-h/2) ]
18oval w h =
19 let n = 50
20 f i = (w/2 * cos (2*pi/n * i), h/2 * sin (2*pi/n * i))
21 in map f [0..n-1]
23circle r = oval (2*r) (2*r)
25ngon n r =
26 let m = toFloat n
27 f i = ( r * cos (2*pi/m * i), r * sin (2*pi/m * i))
28 in map f [0..n-1]