xxxxxxxxxx
44
let n = 0, a = [], gtA = 1, mxaL = 250;
function setup() {
createCanvas(600, 600);
}
function draw() {
background(0);
next(n);
let aL = a.length;
let prevX = 0, prevY = height;
for(let i = 0; i < aL; i++) {
fill(255); stroke(255); strokeWeight(0.6);
let newX = i*width/aL, newY = (height - a[i]*height/gtA);
if(newY > height) {
fill(255, 0, 0); stroke(255, 0, 0);
}else if(prevY > height) {
fill(255, 255, 0); stroke(255, 255, 0);
}
line(prevX, mod(prevY, height+1), newX, mod(newY, height+1));
prevX = newX, prevY = newY;
}
n++;
}
function seq(n) {
return (3**(a[0] ? (a[a.length - 1]) : 1) % 99) % 7;
}
function mod(x,y) {
let ret = x % y;
while(ret < 0) ret += y;
return ret;
}
function next(n) {
let an = seq(n);
a.push(an);
if(a.length > mxaL) a = a.slice(1);
if(an > gtA) gtA = an;
}