xxxxxxxxxx
function setup() {
const w = 800;
const h = 800;
createCanvas(w, h);
strokeWeight(1);
}
function draw() {
background(255);
const inc = 10;
const w = 800;
const h = 800;
// vertical lines from top to bottom, whole canvas
for(let i=0; i<=w; i=i+inc){
line(i,0, i,w);
}
// horizontal lines from side to side, 3 quarters of canvas
// draw top right quadrant first
for(let i=0; i<=(w/2); i=i+inc){
line(w/2,i, w,i);
}
// draw horizontal lines for quads 3 and 4
for(let i=(h/2); i<=h; i=i+inc){
line(0,i, w,i);
}
//now diagonals in quads 3 and 4
//quad 3 first half lines getting bigger
x=0;
for(let y=(w/2); y<w; y=y+inc){
line(0,y+inc, x+inc, w/2);
x=x+inc;}
// quad 3 middle section lines all same length going to x = 400
for(let x=inc; x<=(w/2); x=x+inc){ //offset first line by inc so i dont repeat
line(x,w, x+(w/2), (w/2));
}
//finish quad 4 lines getting smaller
for(let y=(w/2); y<w; y=y+inc){
line(y+inc,w, w, y+inc);
}
//ok last bit here quad 4 only diagonals in other direction
//starting at center lines get smaller
y=0;
for(let x=(w/2); x<w; x=x+inc){
line(x,(w/2), w, w-y);
y=y+inc;}
//now really last bit quad for lines getting smaller dont draw first one
y=0;
for(let x=(w/2); x<w; x=x+inc){
line((w/2),x+inc, w-inc-y,w);
y=y+inc;}
}