on master help sign in
Switch back to using `number` instead of `Float` whenever it is appropriate
552fe26Evan Czaplicki
libraries/Graphics/Collage.elm+15−15
@@ -128,27 +128,27 @@ groupTransform matrix fs = form (FGroup matrix fs)
128-- Rotate a form by a given angle. Rotate takes standard Elm angles (radians)
128-- Rotate a form by a given angle. Rotate takes standard Elm angles (radians)
129-- and turns things counterclockwise. So to turn `form` 30° to the left
129-- and turns things counterclockwise. So to turn `form` 30° to the left
130-- you would say, `(rotate (degrees 30) form)`.
130-- you would say, `(rotate (degrees 30) form)`.
131−rotate : Float -> Form -> Form
131+rotate : number -> Form -> Form
132rotate t f = { f | theta <- f.theta + t }
132rotate t f = { f | theta <- f.theta + t }
133
133
134-- Scale a form by a given factor. Scaling by 2 doubles the size.
134-- Scale a form by a given factor. Scaling by 2 doubles the size.
135−scale : Float -> Form -> Form
135+scale : number -> Form -> Form
136scale s f = { f | scale <- f.scale * s }
136scale s f = { f | scale <- f.scale * s }
137
137
138-- Move a form by the given amount. This is a relative translation so
138-- Move a form by the given amount. This is a relative translation so
139-- `(move (10,10) form)` would move `form` ten pixels up and ten pixels to the
139-- `(move (10,10) form)` would move `form` ten pixels up and ten pixels to the
140-- right.
140-- right.
141−move : (Float,Float) -> Form -> Form
141+move : (number,number) -> Form -> Form
142move (x,y) f = { f | x <- f.x + x, y <- f.y + y }
142move (x,y) f = { f | x <- f.x + x, y <- f.y + y }
143
143
144-- Move a shape in the x direction. This is relative so `(moveX 10 form)` moves
144-- Move a shape in the x direction. This is relative so `(moveX 10 form)` moves
145-- `form` 10 pixels to the right.
145-- `form` 10 pixels to the right.
146−moveX : Float -> Form -> Form
146+moveX : number -> Form -> Form
147moveX x f = { f | x <- f.x + x }
147moveX x f = { f | x <- f.x + x }
148
148
149-- Move a shape in the y direction. This is relative so `(moveY 10 form)` moves
149-- Move a shape in the y direction. This is relative so `(moveY 10 form)` moves
150-- `form` upwards by 10 pixels.
150-- `form` upwards by 10 pixels.
151−moveY : Float -> Form -> Form
151+moveY : number -> Form -> Form
152moveY y f = { f | y <- f.y + y }
152moveY y f = { f | y <- f.y + y }
153
153
154-- Set the alpha of a `Form`. The default is 1, and 0 is totally transparent.
154-- Set the alpha of a `Form`. The default is 1, and 0 is totally transparent.
@@ -161,36 +161,36 @@ collage : Int -> Int -> [Form] -> Element
161collage = Native.Graphics.Collage.collage
161collage = Native.Graphics.Collage.collage
162
162
163
163
164−type Path = [(Float,Float)]
164+type Path = [(number,number)]
165
165
166-- Create a path that follows a sequence of points.
166-- Create a path that follows a sequence of points.
167−path : [(Float,Float)] -> Path
167+path : [(number,number)] -> Path
168path ps = ps
168path ps = ps
169
169
170-- Create a path along a given line segment.
170-- Create a path along a given line segment.
171−segment : (Float,Float) -> (Float,Float) -> Path
171+segment : (number,number) -> (number,number) -> Path
172segment p1 p2 = [p1,p2]
172segment p1 p2 = [p1,p2]
173
173
174−type Shape = [(Float,Float)]
174+type Shape = [(number,number)]
175
175
176-- Create an arbitrary polygon by specifying its corners in order.
176-- Create an arbitrary polygon by specifying its corners in order.
177-- `polygon` will automatically close all shapes, so the given list
177-- `polygon` will automatically close all shapes, so the given list
178-- of points does not need to start and end with the same position.
178-- of points does not need to start and end with the same position.
179−polygon : [(Float,Float)] -> Shape
179+polygon : [(number,number)] -> Shape
180polygon points = points
180polygon points = points
181
181
182-- A rectangle with a given width and height.
182-- A rectangle with a given width and height.
183−rect : Float -> Float -> Shape
183+rect : number -> number -> Shape
184rect w h = let hw = w/2
184rect w h = let hw = w/2
185 hh = h/2
185 hh = h/2
186 in [ (0-hw,0-hh), (0-hw,hh), (hw,hh), (hw,0-hh) ]
186 in [ (0-hw,0-hh), (0-hw,hh), (hw,hh), (hw,0-hh) ]
187
187
188-- A square with a given edge length.
188-- A square with a given edge length.
189−square : Float -> Shape
189+square : number -> Shape
190square n = rect n n
190square n = rect n n
191
191
192-- An oval with a given width and height.
192-- An oval with a given width and height.
193−oval : Float -> Float -> Shape
193+oval : number -> number -> Shape
194oval w h =
194oval w h =
195 let n = 50
195 let n = 50
196 t = 2 * pi / n
196 t = 2 * pi / n
@@ -200,7 +200,7 @@ oval w h =
200 in List.map f [0..n-1]
200 in List.map f [0..n-1]
201
201
202-- A circle with a given radius.
202-- A circle with a given radius.
203−circle : Float -> Shape
203+circle : number -> Shape
204circle r = oval (2*r) (2*r)
204circle r = oval (2*r) (2*r)
205
205
206-- A regular polygon with N sides. The first argument specifies the number
206-- A regular polygon with N sides. The first argument specifies the number
@@ -208,7 +208,7 @@ circle r = oval (2*r) (2*r)
208-- 30 you would say:
208-- 30 you would say:
209--
209--
210-- ngon 5 30
210-- ngon 5 30
211−ngon : Int -> Float -> Shape
211+ngon : Int -> number -> Shape
212ngon n r =
212ngon n r =
213 let m = toFloat n
213 let m = toFloat n
214 t = 2 * pi / m
214 t = 2 * pi / m