xxxxxxxxxx
44
function setup() {
createCanvas(400, 400);
}
function draw() {
background(255);
stroke(0);
DrawGrid(400, 40);
diag(0,0, 400, 400);
}
function diag(X1, Y1, X2, Y2) {
strokeWeight(1);
for (var i = 0; i <= X2; i = i + 40) {
stroke(200, 100, 200);
line(X1+i, Y1, X2, Y2-i);
line(X1, Y1+i, X2-i, Y2);
stroke(200, 200, 100);
line(X2-i, Y1, X1, Y2-i);
}
}
function DrawGrid(MAX,SPACING) {
// parameters MAX and SPACING allow us to pass values into the function
for (var g = 0; g < MAX; g = g + SPACING) {
//strokeWeight(.5);
if (g % 80 == 0) {
strokeWeight(1);
} else {
strokeWeight(.5);
}
line(g, 0, g, MAX);
line(0, g, MAX, g);
}
}