As seen on Ruud's feed: twitter.com/ruuddotorg/status/1444090166151237632
Log in to post a comment.
// LL 2021 // As seen on Ruud's feed: https://twitter.com/ruuddotorg/status/1444090166151237632 const mult = 3; // min=2 max=100 step=1 const mod = 197; // min=1 max=1000 step=1 const slow = 0; // min=0 max=1 step=1 (No,Yes) const turtle = new Turtle(); turtle.up(); steps = 500, astep = Math.PI / (steps-1); function walk(i) { if (i == 0) { current_x = 1, iterations = 1, visited = { x: 1 }; max = x = current_x, nx = (mult * x) % mod; while (!visited[nx] && iterations++ < 10000) { visited[x = nx] = 1; nx = (mult * x) % mod; scale = 190 / (max = Math.max(max, Math.max(x, nx))); } } if ((i % steps) == 0) { next_x = (mult * (old_x = current_x)) % mod; radius = Math.abs(next_x - current_x) / 2; center_x = (next_x + current_x) / 2; current_x = next_x; j=0; } a = j++ * astep; if (current_x > old_x) a = Math.PI - a; x = -95 + (center_x + Math.cos(a) * radius) * scale; y = Math.sin(a) * radius * scale * ((i/steps|0)&1 ? 1 : -1); turtle.goto(x, y); turtle.down(); if (slow) { start = Date.now(); while (Date.now()-start < 1); } return (i/steps+1) < iterations; }