on master help sign in
Merge pull request #312 from tomberek/patch-1

Updated the functions in "Transforming Forms" to use Float

commit71fb0a36630b1532d0062626bbf74050637f72ab authorEvan Czaplicki <info@elm-lang.org> dateTue 29 Oct 2013, 06:46 (13 years ago) parent7174d9a1d0ce8e
1 file changed+15−15
libraries/Graphics/Collage.elm+15−15
libraries/Graphics/Collage.elm+15−15
@@ -162,37 +162,37 @@ transformation.
162162groupTransform : Transform2D -> [Form] -> Form
163163groupTransform matrix fs = form (FGroup matrix fs)
164164
165−{-| Rotate a form by a given angle. Rotate takes standard Elm angles (radians)
166−and turns things counterclockwise. So to turn `form` 30&deg; 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−
177165{-| Move a form by the given amount. This is a relative translation so
178166`(move (10,10) form)` would move `form` ten pixels up and ten pixels to the
179167right.
180168-}
181−move : (number,number) -> Form -> Form
169+move : (Float,Float) -> Form -> Form
182170move (x,y) f = { f | x <- f.x + x, y <- f.y + y }
183171
184172{-| Move a shape in the x direction. This is relative so `(moveX 10 form)` moves
185173`form` 10 pixels to the right.
186174-}
187−moveX : number -> Form -> Form
175+moveX : Float -> Form -> Form
188176moveX x f = { f | x <- f.x + x }
189177
190178{-| Move a shape in the y direction. This is relative so `(moveY 10 form)` moves
191179`form` upwards by 10 pixels.
192180-}
193−moveY : number -> Form -> Form
181+moveY : Float -> Form -> Form
194182moveY y f = { f | y <- f.y + y }
195183
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+
196196{-| Set the alpha of a `Form`. The default is 1, and 0 is totally transparent. -}
197197alpha : Float -> Form -> Form
198198alpha a f = { f | alpha <- a }