xxxxxxxxxx
59
const w = 700;
const h = 700;
const lw = 20;
let coef = {
a: [0, 0],
b: [0, 0],
c: [1, 1],
d: [0, 0],
};
function setup() {
createCanvas(w, h);
}
function isPrime(n) {
prime = true;
for (let d = 2; d <= Math.floor(n ** 0.5) + 1; d++) {
const r = n % d;
if (r == 0) {
prime = !prime;
break;
}
}
if (n == 2) {
prime = !prime;
}
return prime;
}
function draw() {
background(220);
let coords = [];
for (let i = 0; i<= 10; i++) {
l = [[w / 2 + lw * a, h / 2 + lw * b],
[w / 2 + lw * c, h / 2 + lw * d]];
coords.push(l)
for (let i = 0; i <= 3; i++) {
if (coef.a[1] == 4){coef.a[0]+=1}
if (coef.a[1] == 2){coef.a[0]*=-1}
}
}
for (let i = 0; i<l.length; i++){
x = l[i][0][0]
y = l[i][0][1]
x1 = l[i][1][0]
y1 = l[i][1][1]
line(x, y, x1, y1)
}
}