Created
May 11, 2014 22:46
-
-
Save nasser/a3dcf0b5541a09af9f79 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
pos = x:20, y:20 | |
setup = -> | |
createCanvas w:800, h:800 | |
# square animation | |
timeline -> pos.x += 1 >= width - 50 | |
timeline -> pos.y += 1 >= height - 50 | |
timeline -> pos.x -= 1 <= 20 | |
timeline -> pos.y -= 1 <= 20 | |
# follow mouse for 20 seconds | |
followFor = 20 | |
timeline (dt) -> | |
pos.x = pos.x*0.9 + mouseX*0.1 | |
pos.y = pos.y*0.9 + mouseY*0.1 | |
followFor -= dt <= 0 | |
# move to center | |
timeline -> | |
pos.x = (pos.x + width/2) * 0.5 | |
pos.y = (pos.y + height/2) * 0.5 | |
pos.x == width/2 and pos.y == height/2 | |
draw = -> | |
background "white" | |
circle pos, size:20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment