Exercise: conditionals

Starting from  a 9×9 pattern of green circles


var rows = 9;
var cols = 9;
var circleDiameter = 40;
var distanceX = 60;
var distanceY = 60;

function setup() {
createCanvas(600, 600);
noStroke();
}

function draw() {
background(0);

for (var r = 0; r < rows; r++) {
for (var c = 0; c < cols; c++) {
fill(0, 200, 0);
ellipse(c * distanceX+distanceX, r * distanceY+distanceY, circleDiameter, circleDiameter);
}
}

}

Reproduce the following outputs by changing only the if condition:

Screen Shot 2015-10-21 at 6.10.55 PM

Screen Shot 2015-10-21 at 6.11.44 PM

Screen Shot 2015-10-21 at 6.13.13 PM

Screen Shot 2015-10-21 at 6.13.41 PM

Screen Shot 2015-10-21 at 6.14.02 PM

Screen Shot 2015-10-21 at 6.15.41 PM