Squares

show code

size(201,201);
background(255,255,255);

//set x and y variables for later drawing
var y = 0;
var x = 0;

//loop to fill all of the canvas with 100 squares
for (i = 1; i < 101; i++) {

//randomnly assign RGB values and set as fill
var r = Math.random()*255;
var g = Math.random()*255;
var b = Math.random()*255;
fill(r,g,b);

//draw the rectangle
rect(x*20, y, 20, 20);

//when 10 rectangles are drawn I need to jump down one line and start over from the left
if (i%10 == 0) {
y = y + 20;
x = 0
} else {
x ++;
};

};

Developing English through Art-oriented activities. Coordinator: Tesi Bogdan. Project 2015-1-RO01-KA219-015106_9. Webmaster: Dr. Francisco PĂ©rez