xxxxxxxxxx
//Width and height of grid. Press spacebar to change grid size
let space = 50; //width
//let spacee = 20; //height
//Global values for background color. Press b to change background color
let r =255;
let g =255;
let b=255;
//Global values for color of arcs. Press c to change color of arcs
let rr = 0;
let gg = 0;
let bb = 0;
function setup() {
createCanvas(650, 750);
//background(255, 204, 0);
}
function draw() {
print("press b, c or space bar");
background(r,g,b);
fill(rr,gg,bb);
noStroke();
//rectMode(CENTER);
//space = 50; this was declared as a global value
let rad = space/2;
//let radd = spacee/2; half of height if grid if i decide to use the variable spacee
//This is the creation of grids with squares in them
for(x=0; x<width; x+=space){
for(y=0; y<height; y+=space){
// GRIDLINES
stroke(0);
line(x,y, x+space, y);
line(x,y, x, y+space);
noStroke();
//fun fact, the arcs draw from their centers and the starting degree. so if width is 50, x is 25. sumn like that.
c= random(0,4);
if(c<1){
arc(x+rad, y+rad, space,space, radians(180), radians(360));//top arc
}
else if(c<2){
arc(x+rad, y+rad, space,space, 0, radians(180)); //bottom arc
}
else if(c<3){
arc(x+rad, y+rad, space,space, radians(90), radians(270)); //left arc
}
else if(c<4){
arc(x+rad,y+rad, space,space, radians(270), radians(90)); //right arc
}
}
}
noLoop();
}
function keyPressed(){
//Change the background color
if(key=='b'){
r = random(0,255);
g = random(0,255);
b = random(0,255);
draw();
}
//Change the size of the grid and arcs simulataneously
else if(key == ' '){
space = random(5, 70);
draw();
}
//change the color of the arcs
else if(key == 'c'){
rr = random(0,255);
gg = random(0,255);
bb = random(0,255);
draw();
}
}