Created
September 21, 2014 20:22
-
-
Save astrieanna/27c299a390a1273e1cc7 to your computer and use it in GitHub Desktop.
modified version of http://elm-lang.org/edit/examples/Elements/Lines.elm (the red square follows the mouse)
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 Mouse | |
# Separating main and squares was key to making lift work | |
# I don't know how to convert Signal (Int,Int) to Signal (Float,Float) | |
# so I separated x and y into different arguments | |
main = lift2 squares (toFloat <~ Mouse.x) | |
(toFloat <~ Mouse.y) | |
squares : Float -> Float -> Element | |
squares x y = | |
collage 500 500 | |
[ move (0,0) blueSquare | |
, move (x - 250,250 - y) redSquare | |
] | |
blueSquare : Form | |
blueSquare = traced (dashed blue) square | |
redSquare : Form | |
redSquare = traced (solid red) square | |
square : Path | |
square = path [ (50,50), (50,-50), (-50,-50), (-50,50), (50,50) ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment