Created
December 23, 2014 13:29
-
-
Save joshy/dd86752f60ec6c9e0297 to your computer and use it in GitHub Desktop.
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 Graphics.Element (..) | |
import Signal (Signal, map, map2, sampleOn) | |
import Mouse | |
import Text (asText) | |
import Window | |
main : Signal Element | |
main = map asText mousePos | |
mouseClickPos : Signal (Int, Int) | |
mouseClickPos = sampleOn Mouse.clicks Mouse.position | |
mousePos : Signal Point | |
mousePos = map2 convert mouseClickPos Window.dimensions | |
convert : (Int, Int) -> (Int, Int) -> Point | |
convert (x,y) (w,h) = | |
{x = (toFloat x - (toFloat w/2)), y = ((toFloat h/2) - toFloat y) } | |
type alias Point = {x:Float, y:Float} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment