sketch
//Brandon Yi
//Section A
//btyi@andrew.cmu.edu
//Project-05-A
function setup() {
createCanvas(600, 600);
background(0);
rectMode(CENTER);
}
function draw() {
//initializing variables
var d=width/10;
var x=d/2
var y=d/2
//iterating it over the background size
for (var row = 0; row < width/d; row++) {
y=d/2;
for (var col = 0; col < height/d; col++) {
tile(x,y,d);
y+=d;
}
x+=d;
}
noLoop();
}
function tile(x,y,d) {
//translation requires a push and pop
push();
stroke(152,255,255);
strokeWeight(5);
translate(x,y)
fill(0);
ellipse(0,0,d);
ellipse(0,0,d-15);
for (var i = 0; i < d; i+=10) {
strokeWeight(2);
stroke(104,0,208);
noFill();
rect(0,0,i,i)
}
pop();
}
The trickiest part of this program was making a for loop inside the function. On top of that, it was difficult to also make the entire program relative to the background size.