Created
August 8, 2012 18:14
-
-
Save raster/3297214 to your computer and use it in GitHub Desktop.
Processing sketch that draws circles
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
/* | |
* 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