xxxxxxxxxx
56
//http://paulbourke.net/fractals/peterdejong/attract.kc
let cols;
let PTS;
let ip;
let sc;
let tx, ty;
let res;
function setup() {
PTS = 12000000;
ip = 1 / TWO_PI;
sc = 100;
res = 800;
createCanvas(res, res);
tx = (width - res) / 2;
ty = (height - res) / 2;
cols = [];
for (let i = 0; i < 1024; i++) {
cols[i] = [];
}
do {
let a = random() * TWO_PI - PI;
let b = random() * TWO_PI - PI;
let x = 0;
let y = 0;
let c = random() * TWO_PI - PI;
let d = random() * TWO_PI - PI;
if (abs(a) < 1) continue;
if (abs(b) < 1) continue;
if (abs(c) < 1) continue;
if (abs(d) < 1) continue;
let good = 100;
for (let i = 0; i < 100; i++) {
let nx = sin(a * y) - cos(b * x);
let ny = sin(c * x) - cos(d * y);
let v = (x - nx) ** 2 + (y - ny) ** 2;
x = nx;
y = ny;
if (v < exp(-7)) good--;
}
if (good > 0) break;
} while (1);
background(0);
}
function draw() {}