on bbbd6ee help sign in
elk/libraries/Graphics/Collage.elm
68 lines 1.6 kB history raw
2module Graphics.Collage where
4import Either
5import Graphics.LineStyle as LS
6import Graphics.Geometry
7import Native.Graphics.Matrix as Matrix
8import Native.Graphics.Collage as N
9import Graphics.Element
11type Form = {
12 theta : Float,
13 scale : Float,
14 x : Float,
15 y : Float,
16 form : BasicForm
17 }
19data FillStyle
20 = Solid Color
21 | Texture String
22 | Gradient Gradient
24data BasicForm
25 = FPath LineStyle Path
26 | FShape (Either LineStyle FillStyle) Shape
27 | FImage Int Int (Int,Int) String
28 | FElement Element
29 | FGroup [Form]
31form f = { theta = 0, scale = 1, x = 0, y = 0, form = f }
33fill style shape = form (FShape (Right style) shape)
35filled : Color -> Shape -> Form
36filled color shape = fill (Solid color) shape
38textured : String -> Shape -> Form
39textured src shape = fill (Texture src) shape
41gradient : Gradient -> Shape -> Form
42gradient grad shape = fill (Gradient grad) shape
44outline : LineStyle -> Shape -> Form
45outline style shape = form (FShape (Left style) shape)
47trace : LineStyle -> Path -> Form
48trace style path = form (FPath style path)
50sprite : Int -> Int -> (Int,Int) -> String -> Form
51sprite w h pos src = form (FImage w h pos src)
53toForm : Element -> Form
54toForm e = form (FElement e)
56group : [Form] -> Form
57group fs = form (FGroup fs)
59rotate : Float -> Form -> Form
60rotate t f = { f | theta <- f.theta + t }
62scale s f = { f | scale <- f.scale * s }
64move x y f = { f | x <- f.x + x, y <- f.y + y }
65moveX x f = { f | x <- f.x + x }
66moveY y f = { f | y <- f.y + y }
68collage : Int -> Int -> [Form] -> Element