@@ -1,25 +1,9 @@
2−module Collage where
2+module Graphics.Collage where
4−data Path = Path [(Float,Float)]
4+import Either
5−
5+import Graphics.LineStyle
6−path = Path
6+import Geometry
7−segment p1 p2 = Path [p1,p2]
9−data Shape = Shape [(Float,Float)]
13−rect w h = polygon [ (0-w/2,0-h/2), (0-w/2,h/2), (w/2,h/2), (w/2,0-h/2) ]
16− f i = (w/2 * cos (2*pi/n * i), h/2 * sin (2*pi/n * i))
17− in Shape $ map f [0..n-1]
18−circle r = oval (2*r) (2*r)
21− f i = ( r * cos (2*pi/m * i), r * sin (2*pi/m * i))
22− in Shape $ map f [0..n-1]
24data Transform
8data Transform
25 = Rotate Float
9 = Rotate Float
@@ -29,47 +13,37 @@ data Transform
30data Form = Form [Transform] BasicForm
14data Form = Form [Transform] BasicForm
33−data LineCap = Butt | Round | Square
34−data LineJoin = Round | Bevel | Miter
36data FillStyle
16data FillStyle
38 | Solid Color
18 | Solid Color
39 | Texture String
19 | Texture String
40− | LinearGradient [(Float,Color)] (Float,Float) (Float,Float)
20+ | Gradient Gradient
41− | RadialGradient [(Float,Color)] (Float,Float) Float (Float,Float) Float
43−-- dash pattern, dash offset, line width, cap, join, miter limit, fill style
49− fillStyle : FillStyle,
54data BasicForm
22data BasicForm
55 = FLine LineStyle Line
23 = FLine LineStyle Line
56− | FShape LineStyle FillStyle Shape
24+ | FShape (Either LineStyle FillStyle) Shape
57 | FImage Int Int Int Int String
25 | FImage Int Int Int Int String
58 | FElement Element
26 | FElement Element
59 | FGroup [Form]
27 | FGroup [Form]
61−setFillStyle fs form =
29+fill style shape = FShape (Right style) shape
63− FLine ls _ ln -> FLine ls fs ln
31+filled : Color -> Shape -> Form
64− FShape ls _ shp -> FLine ls fs shp
32+filled color shape = fill (Solid color) shape
34+textured : String -> Shape -> Form
35+textured src shape = fill (Texture src) shape
37+gradient : Gradient -> Shape -> Form
38+gradient grad shape = fill (Gradient grad) shape
40+outline style shape = FShape (Left style) shape
67−noFill = setFillStyle NoFill
68−fillColor clr = setFillStyle (Solid clr)
69−texture src = setFillStyle (Texture src)
70linearGradient stops start end = setFillStyle (LinearGradient stops start end)
44linearGradient stops start end = setFillStyle (LinearGradient stops start end)
71radialGradient stops innerP innerR outerP outerR =
45radialGradient stops innerP innerR outerP outerR =
72− setFillStyle (RadialGradient stops innerP innerR outerP outerR)
46+ setStyle (RadialGradient stops innerP innerR outerP outerR)
74plain = { width=1, cap=Butt, join=Miter, miterLimit=10,
48plain = { width=1, cap=Butt, join=Miter, miterLimit=10,
75 fillStyle=...,
49 fillStyle=...,