Created
November 11, 2014 04:10
-
-
Save evancz/6df7c788ffa5e555fdd9 to your computer and use it in GitHub Desktop.
Trying out different ways to avoid toFloat conversions, based on this discussion (https://groups.google.com/forum/#!topic/elm-discuss/YPA2ww2P9PU)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Window | |
import Color | |
floatify : (Int,Int) -> (Float,Float) | |
floatify (x,y) = | |
(toFloat x, toFloat y) | |
scene (w,h) = | |
flow down | |
[ container (floor w) (floor (h / 2)) middle (asText "blue") | |
|> color Color.blue | |
, container (floor w) (ceiling (h / 2)) middle (asText "red") | |
|> color Color.red | |
] | |
main = lift scene (lift floatify Window.dimensions) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Window | |
import Color | |
scene (w,h) = | |
let halfHeight = h // 2 | |
flow down | |
[ container w halfHeight middle (asText "blue") | |
|> color Color.blue | |
, container w (h - halfHeight) middle (asText "red") | |
|> color Color.red | |
] | |
main = lift scene Window.dimensions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Window | |
import Color | |
scene (w,h) = | |
flow down | |
[ container w (floor (toFloat h / 2)) middle (asText "blue") | |
|> color Color.blue | |
, container w (ceiling (toFloat h / 2)) middle (asText "red") | |
|> color Color.red | |
] | |
main = lift scene Window.dimensions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Window | |
import Color | |
scene (w,h) = flow down | |
[ container w (toFloat h/toFloat 2 |> floor) middle (asText "blue") |> color Color.blue | |
, container w (toFloat h/toFloat 2 |> ceiling) middle (asText "red") |> color Color.red | |
] | |
main = lift scene Window.dimensions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment