Created
August 19, 2014 11:25
-
-
Save joshy/22aeb4f6588f4ce29df5 to your computer and use it in GitHub Desktop.
Simple example of drawing a point and then make that point "moveable"
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 Mouse | |
import Window | |
main : Signal Element | |
main = lift2 scene Window.dimensions lastClickLocation | |
input : Signal (Int, Int) | |
input = sampleOn Mouse.clicks Mouse.position | |
lastClickLocation = lift (take 1) clickLocations | |
clickLocations : Signal [(Int,Int)] | |
clickLocations = foldp (::) [] input | |
scene : (Int,Int) -> [(Int,Int)] -> Element | |
scene (w,h) locs = | |
let drawCircle (x,y) = | |
circle 5 |> filled (rgba 0 76 255 1) | |
|> move (toFloat x - toFloat w / 2, toFloat h / 2 - toFloat y) | |
in layers [ collage w h (map drawCircle locs) | |
, plainText "Click to stamp a circle." | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment