on master help sign in
Updated the functions in "Transforming Forms" to use Float
1d0ce8etomberek
libraries/Graphics/Collage.elm+15−15
@@ -162,37 +162,37 @@ transformation.
162groupTransform : Transform2D -> [Form] -> Form
162groupTransform : Transform2D -> [Form] -> Form
163groupTransform matrix fs = form (FGroup matrix fs)
163groupTransform matrix fs = form (FGroup matrix fs)
164
164
165−{-| Rotate a form by a given angle. Rotate takes standard Elm angles (radians)
166−and turns things counterclockwise. So to turn `form` 30° to the left
167−you would say, `(rotate (degrees 30) form)`.
168−-}
169−rotate : number -> Form -> Form
170−rotate t f = { f | theta <- f.theta + t }
171−
172−{-| Scale a form by a given factor. Scaling by 2 doubles the size.
173−-}
174−scale : number -> Form -> Form
175−scale s f = { f | scale <- f.scale * s }
176−
177{-| Move a form by the given amount. This is a relative translation so
165{-| Move a form by the given amount. This is a relative translation so
178`(move (10,10) form)` would move `form` ten pixels up and ten pixels to the
166`(move (10,10) form)` would move `form` ten pixels up and ten pixels to the
179right.
167right.
180-}
168-}
181−move : (number,number) -> Form -> Form
169+move : (Float,Float) -> Form -> Form
182move (x,y) f = { f | x <- f.x + x, y <- f.y + y }
170move (x,y) f = { f | x <- f.x + x, y <- f.y + y }
183
171
184{-| Move a shape in the x direction. This is relative so `(moveX 10 form)` moves
172{-| Move a shape in the x direction. This is relative so `(moveX 10 form)` moves
185`form` 10 pixels to the right.
173`form` 10 pixels to the right.
186-}
174-}
187−moveX : number -> Form -> Form
175+moveX : Float -> Form -> Form
188moveX x f = { f | x <- f.x + x }
176moveX x f = { f | x <- f.x + x }
189
177
190{-| Move a shape in the y direction. This is relative so `(moveY 10 form)` moves
178{-| Move a shape in the y direction. This is relative so `(moveY 10 form)` moves
191`form` upwards by 10 pixels.
179`form` upwards by 10 pixels.
192-}
180-}
193−moveY : number -> Form -> Form
181+moveY : Float -> Form -> Form
194moveY y f = { f | y <- f.y + y }
182moveY y f = { f | y <- f.y + y }
195
183
184+{-| Scale a form by a given factor. Scaling by 2 doubles the size.
185+-}
186+scale : Float -> Form -> Form
187+scale s f = { f | scale <- f.scale * s }
188+
189+{-| Rotate a form by a given angle. Rotate takes standard Elm angles (radians)
190+and turns things counterclockwise. So to turn `form` 30&deg; to the left
191+you would say, `(rotate (degrees 30) form)`.
192+-}
193+rotate : Float -> Form -> Form
194+rotate t f = { f | theta <- f.theta + t }
195+
196{-| Set the alpha of a `Form`. The default is 1, and 0 is totally transparent. -}
196{-| Set the alpha of a `Form`. The default is 1, and 0 is totally transparent. -}
197alpha : Float -> Form -> Form
197alpha : Float -> Form -> Form
198alpha a f = { f | alpha <- a }
198alpha a f = { f | alpha <- a }