xxxxxxxxxx
34
let offX = 0;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
stroke(0);
strokeWeight(2);
noFill();
beginShape();
for (let i = 0; i < width; i++) {
vertex(a(i).x, a(i).y);
}
endShape();
offX+= 0.00001;
}
function a(t) {
let n = Math.floor(t);
while (n !== 1) {
if (n % 2 === 0) {
n = n / 2;
} else {
n = 3 * n + 1;
}
}
let x = map(t, 0, width, 0, width);
let y = map(n, 1, 10, height, 0);
return createVector(x, y);
}