Skip to content

Instantly share code, notes, and snippets.

@Saturn-V
Last active April 3, 2016 20:17
Show Gist options
  • Save Saturn-V/121adf61e5bda340a6ba3989ea621a59 to your computer and use it in GitHub Desktop.
Save Saturn-V/121adf61e5bda340a6ba3989ea621a59 to your computer and use it in GitHub Desktop.
var NUM_ROWS, DIA, RAD;
function setup() {
createCanvas(300, 300);
background('#f9a825');
NUM_ROWS = 8; //modify me if u wish
//determines radius and diameter based on NUM_ROWS
RAD = height / NUM_ROWS;
DIA = 2 * RAD;
}
function draw() {
var alt = true; //alternates x position
var currentRow = 0; //row number
//position the y coordinate
for (var y = height; y >= 0; y -= RAD) {
currentRow += 1;
alt = !alt; //alteration
var xPos = alt ? 0 : RAD; //determine x position
var r = 0, g = 0, b = 0;
r = (r + (currentRow == 4 ? 121 : 30 * currentRow));
console.log(r); //RED color value
g = (g + (13 * currentRow));
console.log(g); //GREEN color value
b = (b + (currentRow == 4 ? 45 : 11 * currentRow));
console.log(b); //BLUE color value
//set color of row based on above r g b
var rowColor = color(38 + r, 77 + g, 115 - b);
stroke(rowColor);
fill(rowColor);
for (var x = xPos; x <= width; x += DIA) {
ellipse(x, y, DIA, DIA);
}
}
}
@Saturn-V
Copy link
Author

Saturn-V commented Apr 3, 2016

screen shot 2016-04-03 at 1 06 07 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment