xxxxxxxxxx
47
// 9/2/2020 Tale
// IterationExercise
// modified from the Starter Code for "Embedded Iteration + Randomness" provided by 60-212 course
var boolDoRefresh;
function setup() {
createCanvas(400, 400);
boolDoRefresh = true;
}
let mydoggo;
let alsomydgo;
function preload(){
mydoggo = loadImage('alsomydoggo.JPG');
alsomydgo = loadImage('mydoggo.png');
}
function draw() {
if (boolDoRefresh) {
background("#FFEB8A");
var margin = 10;
var wid = 68;
var hei = 68;
for (var x = 0; x < 5; x ++){
for (var y = 0; y < 5; y ++){
var which2draw = Math.round(random(0,7));
if(which2draw==0||which2draw==2){
image(alsomydgo,margin*(x+1) + wid*x,margin*(y+1) + hei*y,wid,hei);
stroke(random(0,255),random(0,255),random(0,255));
strokeWeight(7);
noFill();
ellipse(margin*(x+1)+ wid/2 + wid*x,margin*(y+1) + hei/2 + hei*y,wid,hei);
} else {
image(mydoggo,margin*(x+1) + wid*x,margin*(y+1) + hei*y,wid,hei);
}
}
}
boolDoRefresh = false;
}
}
function mousePressed() {
boolDoRefresh = true;
}