Skip to content

Instantly share code, notes, and snippets.

@joshy
Created August 19, 2014 11:25
Show Gist options
  • Save joshy/22aeb4f6588f4ce29df5 to your computer and use it in GitHub Desktop.
Save joshy/22aeb4f6588f4ce29df5 to your computer and use it in GitHub Desktop.
Simple example of drawing a point and then make that point "moveable"
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