xxxxxxxxxx
// this is a comment
// control-shift J appears to open the developer console
// setup runs once when you hit play!
function setup() {
createCanvas(windowWidth, windowHeight); // this is saying how big our canvas is
background(255); // this is our background color
rectMode(CENTER); // rectangles will draw on center
}
// draw runs every frame over and over and over and over and over
function draw() {
var color0 = "black"; // edge color
var color1 = "red";
var color2 = "yellow";
var color3 = "blue";
var gridsize = 50; // how wide is the grid in pixels
// random makes random numbers: one argument is a range, two args are a min and a max
stroke(color0);
strokeWeight(random(2, 10)); // this will make a thicker line
var whichcolor = floor(random(3)); // floor() hacks off the decimal point
//console.log(whichcolor);
if(whichcolor==0) fill(color1);
if(whichcolor==1) fill(color2);
if(whichcolor==2) fill(color3);
var x = random(width);
var y = random(height);
x = ceil(x/gridsize)*gridsize;
y = ceil(y/gridsize)*gridsize;
var w = ceil(random(2))*gridsize;
var h = ceil(random(2))*gridsize;
rect(x, y, w, h); // draw a rectangle - arguments are x, y, width, height
}