let row = 8;
let col = 8;
let pressed = false;
function setup() {
createCanvas(600, 600);
rectMode(CENTER);
noStroke();
noLoop();
background(255, 204, 0);
}
function draw() {
if (pressed == false){
makeShapes();
}
}
function mousePressed(){
pressed = true;
background(255, 204, 0);
makeShapes();
}
function makeShapes(){
for (var i = 1; i < row; i++){
for (var j = 1; j < col; j++){
let probability = int(random(0,12));
if (probability == 0){
fill(0,0,255);
ellipse(100 + 50*i, 100 + 50*j, 30);
}
else {
fill(255,0,0);
rect(100 + 50*i, 100 + 50*j, 30, 30);
}
}
}
} |
let row = 8;
let col = 8;
let pressed = false;
function setup() {
createCanvas(600, 600);
rectMode(CENTER);
noStroke();
noLoop();
background(255, 204, 0);
}
function draw() {
if (pressed == false){
makeShapes();
}
}
function mousePressed(){
pressed = true;
background(255, 204, 0);
makeShapes();
}
function makeShapes(){
for (var i = 1; i < row; i++){
for (var j = 1; j < col; j++){
let probability = int(random(0,12));
if (probability == 0){
fill(0,0,255);
ellipse(100 + 50*i, 100 + 50*j, 30);
}
else {
fill(255,0,0);
rect(100 + 50*i, 100 + 50*j, 30, 30);
}
}
}
}