xxxxxxxxxx
//Welcome to Creative Coding!
//Change numbers to figure out what the variables do.
//Declare color variables
let colo1;
let colo2;
let colo3;
let colo4;
let colo5;
//Create a list to hold the colors
let colors = [];
//This function runs when the program first starts
function setup() {
//Canvas size and background color
createCanvas(800, 800);
background(0);
//Set the value to each color variable
colo1 = color(102,102,255);
colo2 = color(214,56,38);
colo3 = color(0,102,102);
colo4 = color(13,128,156);
colo5 = color(21,42,59);
//Store the colors in the list
colors = [colo1, colo2, colo3, colo4, colo5];
}
function draw() {
//Ensures the function only runs one time
noLoop();
//Controls the amount of individual tiles
var incr = 200;
//Double for-loop covers coordinates of entire canvas
for(i = 0; i < 800; i += incr){
for(j = 0; j < 800; j += incr){
//Randomizes the list of colors
colors = shuffle(colors);
//no outline for shapes
noStroke();
//picks the first color from the list
fill(colors[0]);
//creates a square at given spot
rect(i,j, incr, incr);
//picks the second color from the list
fill(colors[1]);
switch(round(random(1, 2))) {
case 1: triangle(i, j, i + incr, j, i + incr, j + incr); break;
case 2: triangle(i + incr, j + incr, i + incr, j, i, j + incr); break;
}
}
}
}