Skip to content

Instantly share code, notes, and snippets.

@raster
Created August 8, 2012 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raster/3297214 to your computer and use it in GitHub Desktop.
Save raster/3297214 to your computer and use it in GitHub Desktop.
Processing sketch that draws circles
/*
* DrawCircles
*
*/
import processing.opengl.*;
void setup() {
size(screen.width, screen.height, OPENGL);
frameRate(120);
stroke(255,255,255);
background(0);
}
float x = 50;
float y = 50;
int s = 50;
int c = 0;
int l = 10;
void draw() {
loop();
stroke(random(20,240),random(20,240),random(20,240));
strokeWeight(random(2,45));
point(x, y);
if (x > (screen.width-100)) {
x = s;
y = y + s;
}
else {
x = x + s;
}
if (y > (screen.height-100)) {
y = s;
if (c > l) {
saveFrame("drawing-####.png");
background(0);
c = 0;
}
c++;
}
}
void keyPressed() {
// check for 'S' or 's' and save an image
if ((int(key) == 83) || (int(key) == 115)) {
saveFrame("drawing-####.png");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment