Created
December 3, 2012 00:49
-
-
Save yyolk/4191905 to your computer and use it in GitHub Desktop.
Sketch 2
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
// Sketch2 | |
// CONTROLS: | |
// Click on the canvas to pause/unpause | |
// r = saves the current frame | |
// any other key while paused = step forward one frame | |
// This runs through draw to create a canvas filled with little shape. | |
// I swear I see things if I stare at this long enough. | |
float shapeSize; | |
PShape oblong; | |
boolean pause; | |
void setup() | |
{ | |
size(500, 500); | |
background(0); | |
frameRate(15); | |
oblong = loadShape("wave.svg"); | |
oblong.disableStyle(); | |
noStroke(); | |
smooth(); | |
} | |
void draw() | |
{ | |
// cycle through the vertical | |
for (float x = 0; x < height; x+=shapeSize){ | |
// then the horizontal | |
for ( float y = 0; y < width; y+=shapeSize ){ | |
// set the size of the shape | |
shapeSize = random(1,25); | |
// randomly select the color to fill the shape | |
switch(floor(random(3))){ | |
case 0: | |
fill(random(255),random(255),random(255)); | |
break; | |
case 1: | |
fill(0); | |
break; | |
case 2: | |
fill(255); | |
break; | |
} | |
// draw the shape | |
shape(oblong, x, y, shapeSize, shapeSize); | |
} | |
} | |
} | |
void keyPressed(){ | |
if(key=='r'){ | |
saveFrame(); | |
} | |
else{ | |
redraw(); | |
} | |
} | |
void mouseClicked(){ | |
if(pause){ | |
loop(); | |
} | |
else { | |
noLoop(); | |
} | |
pause = !pause; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://fundamentals.yolk.cc/post/3738678415/sketch2