on master help sign in
Correct the `square` function.
commitdd9217b02f36f7b910a969100e9a6d091e3475d8 authorevancz <info@elm-lang.org> dateFri 24 May 2013, 09:50 (13 years ago) parent41e2371
1 file changed+4−2
libraries/Graphics/Collage.elm+4−2
libraries/Graphics/Collage.elm+4−2
@@ -172,11 +172,13 @@ polygon points = points
172172
173173-- A rectangle with a given width and height.
174174rect : Number a -> Number a -> Shape
175−rect w h = [ (0-w/2,0-h/2), (0-w/2,h/2), (w/2,h/2), (w/2,0-h/2) ]
175+rect w h = let hw = w/2
176+ hh = h/2
177+ in [ (0-hw,0-hh), (0-hw,hh), (hw,hh), (hw,0-hh) ]
176178
177179-- A square with a given edge length.
178180square : Number a -> Shape
179−square n = rect w h
181+square n = rect n n
180182
181183-- An oval with a given width and height.
182184oval : Number a -> Number a -> Shape