Created
February 21, 2012 19:48
-
-
Save slambert/1878451 to your computer and use it in GitHub Desktop.
This is a processing sketch that draws sets of circles and moves other sets across the screen. It uses a couple funtions.
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
| // this draws sets of circles in rows on the screen | |
| // Steve Lambert February 14, 2012 | |
| // variables | |
| int stage = 1; | |
| float cDim = 15; // dimensions of the circle | |
| float y = 0 - cDim; // y is the starting position of the row | |
| float xSpacing = cDim; // spacing between the circles | |
| float ySpacing = 10; // spacing below each row | |
| float x = 0; // x is position of the circle | |
| color onColor = color(255,255,0); | |
| color offColor = color(0,0,0); | |
| float ch1Reset = cDim * 0; // where channel 1 starts again | |
| float ch2Reset = cDim * 1; // '' | |
| float ch3Reset = cDim * 2; // '' | |
| float ch4Reset = cDim * 3; // '' | |
| void setup() { | |
| size(1280, 700); | |
| background(125); | |
| ellipseMode(CORNER); | |
| noStroke(); | |
| smooth(); | |
| } | |
| int w=0; | |
| void draw() { | |
| //if (stage == 1) { // if the stage is 1, do the beginning. | |
| background(175); | |
| drawBlack(); | |
| flash(w); | |
| delay(250); | |
| w += 1; | |
| if (w >3) { | |
| w=0; | |
| } | |
| // end | |
| } | |
| void flash(float chReset) { | |
| while (y <= height){ | |
| while (x <= width) { | |
| fill(onColor); | |
| ellipse(x,y,cDim,cDim); | |
| x = x + xSpacing*4; | |
| } // end x loop | |
| y = y + cDim + ySpacing; // this starts a new row | |
| x = cDim * chReset; // this resets the x postions - can use chXReset | |
| } // end y loop | |
| // stage = 2; | |
| x=0; | |
| y = 0 - cDim; | |
| // draw(); | |
| } | |
| // DRAWBLACK CIRCLES | |
| void drawBlack() { | |
| // draws all 4 off | |
| while (y <= height){ | |
| while (x <= width) { | |
| fill(offColor); | |
| ellipse(x,y,cDim,cDim); | |
| x = x + xSpacing; | |
| } // end x loop | |
| y = y + cDim + ySpacing; // this starts a new row | |
| x = 0; // this resets the x postions | |
| } // end y loop | |
| x=0; | |
| y=0-cDim; | |
| } // end drawBlack |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment