xxxxxxxxxx
55
const w = 700;
const h = 700;
const lw = 100;
let coef = [
[0, 0],
[0, 0],
[1, 1],
[0, 0],
];
function setup() {
createCanvas(w, h);
}
function draw() {
background(220);
let coords = [];
for (let i = 0; i <= 5; i++) {
let l = [
w / 2 + lw * coef[0][0], h / 2 + lw * coef[1][0],
w / 2 + lw * coef[2][0], h / 2 + lw * coef[3][0],
];
coords.push(l);
for (let j = 0; j < coef.length; j++) {
if (coef[j][1] == 4) {
if (coef[j][0] < 0){coef[j][0]*=-1}
coef[j][0] += 1;
}
if (coef[j][1] == 3) {
coef[j][0] *= -1;
}
coef[j][1]+=1
}
// Update coef.c, coef.a, or other coefficients here based on your logic
}
for (let i = 0; i < coords.length; i++) {
let x = coords[i][0];
let y = coords[i][1];
let x1 = coords[i][2];
let y1 = coords[i][3];
line(x, y, x1, y1);
}
}