Skip to content

Instantly share code, notes, and snippets.

@mataspetrikas
Created September 2, 2010 15:43
Show Gist options
  • Select an option

  • Save mataspetrikas/562451 to your computer and use it in GitHub Desktop.

Select an option

Save mataspetrikas/562451 to your computer and use it in GitHub Desktop.
Processing: Infinite Draught
// 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