xxxxxxxxxx
var lim = 2.5;
// Re is the real component and Im the imaginary.
var Re = (x, y) => x+x/(x*x + y*y);
var Im = (x, y) => y-y/(x*x + y*y);
function setup() {
createCanvas(500, 500);
colorMode(HSB, 360, 100, 100);
noLoop();
}
function draw() {
loadPixels();
for (let xp = 0; xp < width; xp++) {
for (let yp = 0; yp < height; yp++) {
var x, y;
x = map(xp, 0, width, -lim, lim);
y = map(yp, height, 0, -lim, lim);
var z = new p5.Vector(0,0);
var nextz = new p5.Vector();
nextz.x = Re(x, y);
nextz.y = Im(x, y);
z = new p5.Vector(z.x + nextz.x, z.y + nextz.y);
var h = map(atan2(-z.y, -z.x), -PI, PI, 0, 360);
var s = sqrt(abs( 3*sin( 2* PI * (log(sqrt( z.x*z.x + z.y*z.y ))/log(2) - floor( log(sqrt( z.x*z.x + z.y*z.y ))/log(2) )) )));
var s2 = map(s, 0, 1, 0, 100);
var b = sqrt(sqrt(abs( sin(2 * PI * z.y) * sin(2 * PI * z.x) )));
var b2 = 0.5 * ((1 - s) + b + sqrt((1 - s - b) * (1 - s - b) + 0.01));
var b3 = map(b2, 0, 1, 0, 100);
set(xp, yp, color(h, s2, b3));
}
}
updatePixels();
}