on master help sign in
Move Geometry into Collage. Get rid of Graphics prefix as appropriate.
6ca373bevancz
compiler/Gen/CompileToJS.hs+1−1
@@ -20,7 +20,7 @@ import Types.Types ( Type(RecordT) )
20showErr :: String -> String
20showErr :: String -> String
21showErr err = globalAssign "Elm.Main" (jsFunc "elm" body)
21showErr err = globalAssign "Elm.Main" (jsFunc "elm" body)
22 where msg = show . concatMap (++"<br>") . lines $ err
22 where msg = show . concatMap (++"<br>") . lines $ err
23− body = "var T = Elm.Graphics.Text(elm);\n\
23+ body = "var T = Elm.Text(elm);\n\
24 \return { main : T.text(T.monospace(" ++ msg ++ ")) };"
24 \return { main : T.text(T.monospace(" ++ msg ++ ")) };"
25
25
26indent = concatMap f
26indent = concatMap f
compiler/Gen/ExtractNoscript.hs−1
@@ -36,7 +36,6 @@ instance Extract Expr where
36 (_ , ss1 , ss2 ) -> ss1 ++ ss2
36 (_ , ss1 , ss2 ) -> ss1 ++ ss2
37 Lambda v e -> f e
37 Lambda v e -> f e
38 App (C _ _ (App (C _ _ (Var "link")) src)) txt -> linkExtract src txt
38 App (C _ _ (App (C _ _ (Var "link")) src)) txt -> linkExtract src txt
39− App (C _ _ (App (C _ _ (Var "Graphics.link")) src)) txt -> linkExtract src txt
40 App (C _ _ (App (C _ _ (Var "Text.link")) src)) txt -> linkExtract src txt
39 App (C _ _ (App (C _ _ (Var "Text.link")) src)) txt -> linkExtract src txt
41 App (C _ _ (Var "header")) e -> tag "h1" e
40 App (C _ _ (Var "header")) e -> tag "h1" e
42 App (C _ _ (Var "bold")) e -> tag "b" e
41 App (C _ _ (Var "bold")) e -> tag "b" e
compiler/Model/Libraries.hs+2−3
@@ -18,10 +18,9 @@ addPrelude (Module name exs ims stmts) = Module name exs (customIms ++ ims) stmt
18
18
19prelude = text : map (\n -> (n, Hiding [])) modules
19prelude = text : map (\n -> (n, Hiding [])) modules
20 where
20 where
21− text = ("Graphics.Text", Hiding ["link", "color", "height"])
21+ text = ("Text", Hiding ["link", "color", "height"])
22 modules = [ "Prelude", "Signal", "List", "Maybe", "Time"
22 modules = [ "Prelude", "Signal", "List", "Maybe", "Time"
23− , "Graphics.Element", "Graphics.Color"
23+ , "Graphics.Element", "Color", "Graphics.Collage" ]
24− , "Graphics.Collage", "Graphics.Geometry" ]
25
24
26libraries :: Map.Map String (Map.Map String String)
25libraries :: Map.Map String (Map.Map String String)
27libraries =
26libraries =
libraries/Graphics/Collage.elm+38−1
@@ -1,8 +1,9 @@
1
1
2module Graphics.Collage where
2module Graphics.Collage where
3
3
4+import List
5+import Native.Utils (toFloat)
4import Either
6import Either
5−import Graphics.Geometry
6import Native.Matrix2D as Matrix
7import Native.Matrix2D as Matrix
7import Native.Graphics.Collage as N
8import Native.Graphics.Collage as N
8import Graphics.Element
9import Graphics.Element
@@ -96,3 +97,39 @@ moveX x f = { f | x <- f.x + x }
96moveY y f = { f | y <- f.y + y }
97moveY y f = { f | y <- f.y + y }
97
98
98collage : Int -> Int -> [Form] -> Element
99collage : 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]
libraries/Graphics/Geometry.elmdeleted−35
@@ -1,35 +0,0 @@
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 :)
4−
5−module Graphics.Geometry where
6−
7−import List
8−import Native.Utils (toFloat)
9−
10−type Path = [(Float,Float)]
11−
12−path ps = ps
13−segment p1 p2 = [p1,p2]
14−
15−type Shape = [(Float,Float)]
16−
17−polygon points = points
18−
19−rect w h = [ (0-w/2,0-h/2), (0-w/2,h/2), (w/2,h/2), (w/2,0-h/2) ]
20−
21−oval w h =
22− let n = 50
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))
27− in map f [0..n-1]
28−
29−circle r = oval (2*r) (2*r)
30−
31−ngon n r =
32− let m = toFloat n
33− t = 2 * Math.PI / m
34− f i = ( r * Math.cos (t*i), r * Math.sin (t*i) )
35− in map f [0..n-1]