on master help sign in
Add the `size` function and reorder the arguments to `croppedImage`
commitea0b6c3fda19d168329492d6e59ad2a958949306 authorevancz <info@elm-lang.org> dateSat 25 May 2013, 15:08 (13 years ago) parentbbf20b7
1 file changed+8−4
libraries/Graphics/Element.elm+8−4
libraries/Graphics/Element.elm+8−4
@@ -1,6 +1,6 @@
11
22module Graphics.Element (widthOf, heightOf, sizeOf,
3− width, height, opacity, color, tag, link,
3+ width, height, size, opacity, color, tag, link,
44 image, fittedImage, croppedImage, tiledImage,
55 flow, up, down, left, right, inward, outward,
66 above, below, beside, layers,
@@ -59,6 +59,10 @@ height nh e = let p = e.props
5959 _ -> p
6060 in { element=e.element, props={p| height <- nh} }
6161
62+-- Create an `Element` with a new width and height.
63+size : Int -> Int -> Element -> Element
64+size w h e = height h (width w e)
65+
6266-- Create an `Element` with a given opacity. Opacity is a number between 0 and 1
6367-- where 0 means totally clear.
6468opacity : Float -> Element -> Element
@@ -108,9 +112,9 @@ fittedImage w h src = newElement w h (Image Fitted w h (JS.fromString src))
108112-- at the given top left coordinate. If you have a 140-by-140 image,
109113-- the following will cut a 100-by-100 square out of the middle of it.
110114--
111−-- croppedImage 100 100 (20,20) "yogi.jpg"
112−croppedImage : Int -> Int -> (Int,Int) -> String -> Element
113−croppedImage w h pos src =
115+-- croppedImage (20,20) 100 100 "yogi.jpg"
116+croppedImage : (Int,Int) -> Int -> Int -> String -> Element
117+croppedImage pos w h src =
114118 newElement w h (Image (Cropped pos) w h (JS.fromString src))
115119
116120tiledImage : Int -> Int -> String -> Element