Created
September 14, 2014 14:33
-
-
Save gosub/6dc782c8e5847f964f00 to your computer and use it in GitHub Desktop.
This file contains 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 Mouse | |
main = render <~ Window.dimensions ~ allMoves | |
mousePos = | |
let nomalize = \(w,h) (x,y) -> (toFloat x - toFloat w / 2, toFloat h / 2 - toFloat y) | |
in nomalize <~ Window.dimensions ~ Mouse.position | |
mouseDownAndPos = lift2 (,) Mouse.isDown mousePos | |
allMoves = foldp inFirstList [[]] mouseDownAndPos | |
inFirstList (down, (x,y)) (l::ls) = | |
if down | |
then ((x, y)::l)::ls | |
else (if l == [] | |
then l::ls | |
else ([]::l::ls)) | |
toPath moves = path moves |> traced (solid red) | |
render (w,h) moves = | |
collage w h (map toPath moves) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment