Created
September 2, 2010 15:43
-
-
Save mataspetrikas/562451 to your computer and use it in GitHub Desktop.
Processing: Infinite Draught
This file contains hidden or 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
| // Global variables | |
| int X, Y; | |
| int nX, nY; | |
| int delay = 10; | |
| // Setup the Processing Canvas | |
| void setup() { | |
| size( 800, 600 ); | |
| smooth(); | |
| strokeWeight(1); | |
| X = width / 2; | |
| Y = height / 2; | |
| nX = X; | |
| nY = Y; | |
| } | |
| // Main draw loop | |
| void draw() { | |
| // Track circle to new destination | |
| X+=(nX-X)/delay; | |
| Y+=(nY-Y)/delay; | |
| // Set stroke-color white | |
| stroke(0, 65); | |
| if(frameCount % 5 == 0) { | |
| int distance = floor(random(40,70)); | |
| int tX = constrain(floor(nX + random(-distance, distance)), 0, width); | |
| int tY = constrain(floor(nY + random(-distance, distance)), 0, height); | |
| line(nX, nY, tX, tY); | |
| println(10 * sin( frameCount)); | |
| nX = tX; | |
| nY = tY; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment