Created
March 19, 2011 11:51
-
-
Save mbarkhau/877425 to your computer and use it in GitHub Desktop.
processing example script
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
# Example code adapted from http://processingjs.org/learning | |
delay = 10 | |
X = width / 2 | |
Y = height / 2 | |
# Setup the Processing Canvas | |
setup = -> | |
strokeWeight( 10 ) | |
# Set fill-color to blue | |
fill(0, 100, 200) | |
# Set stroke-color white | |
stroke(255) | |
# Main draw loop | |
draw = -> | |
# overwrite previous content | |
background( 100 ) | |
deltaX = @mouseX-X | |
deltaY = @mouseY-Y | |
delta = sqrt((deltaX*deltaX) + (deltaY*deltaY)) | |
# Track circle to new destination | |
X += deltaX / delay | |
Y += deltaY / delay | |
radius = 30 + (delta / 4) + sin( @frameCount / 4 ) * 10 | |
# Draw circle | |
ellipse( X, Y, radius, radius ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment