on master help sign in
Add the `size` function and reorder the arguments to `croppedImage`
ea0b6c3evancz
libraries/Graphics/Element.elm+8−4
@@ -1,6 +1,6 @@
1
1
2module Graphics.Element (widthOf, heightOf, sizeOf,
2module Graphics.Element (widthOf, heightOf, sizeOf,
3− width, height, opacity, color, tag, link,
3+ width, height, size, opacity, color, tag, link,
4 image, fittedImage, croppedImage, tiledImage,
4 image, fittedImage, croppedImage, tiledImage,
5 flow, up, down, left, right, inward, outward,
5 flow, up, down, left, right, inward, outward,
6 above, below, beside, layers,
6 above, below, beside, layers,
@@ -59,6 +59,10 @@ height nh e = let p = e.props
59 _ -> p
59 _ -> p
60 in { element=e.element, props={p| height <- nh} }
60 in { element=e.element, props={p| height <- nh} }
61
61
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+
62-- Create an `Element` with a given opacity. Opacity is a number between 0 and 1
66-- Create an `Element` with a given opacity. Opacity is a number between 0 and 1
63-- where 0 means totally clear.
67-- where 0 means totally clear.
64opacity : Float -> Element -> Element
68opacity : Float -> Element -> Element
@@ -108,9 +112,9 @@ fittedImage w h src = newElement w h (Image Fitted w h (JS.fromString src))
108-- at the given top left coordinate. If you have a 140-by-140 image,
112-- at the given top left coordinate. If you have a 140-by-140 image,
109-- the following will cut a 100-by-100 square out of the middle of it.
113-- the following will cut a 100-by-100 square out of the middle of it.
110--
114--
111−-- croppedImage 100 100 (20,20) "yogi.jpg"
115+-- croppedImage (20,20) 100 100 "yogi.jpg"
112−croppedImage : Int -> Int -> (Int,Int) -> String -> Element
116+croppedImage : (Int,Int) -> Int -> Int -> String -> Element
113−croppedImage w h pos src =
117+croppedImage pos w h src =
114 newElement w h (Image (Cropped pos) w h (JS.fromString src))
118 newElement w h (Image (Cropped pos) w h (JS.fromString src))
115
119
116tiledImage : Int -> Int -> String -> Element
120tiledImage : Int -> Int -> String -> Element