Skip to content

Instantly share code, notes, and snippets.

@mbarkhau
Created March 19, 2011 11:51
Show Gist options
  • Save mbarkhau/877425 to your computer and use it in GitHub Desktop.
Save mbarkhau/877425 to your computer and use it in GitHub Desktop.
processing example script
# 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