Skip to content

Instantly share code, notes, and snippets.

@IsuraManchanayake
Last active December 23, 2016 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IsuraManchanayake/8c94101870e0c272fe2e47b5af4fc922 to your computer and use it in GitHub Desktop.
Save IsuraManchanayake/8c94101870e0c272fe2e47b5af4fc922 to your computer and use it in GitHub Desktop.
var maxIterations;
var maxVal;
var height;
var width;
function preload() {
maxIterations = 200;
maxVal = 50;
height = 1500;
width = 1500;
}
function setup() {
createCanvas(width, height);
background(255);
noLoop();
}
function draw() {
for(var x = 0; x < width; x++) {
for(var y = 0; y < height; y++) {
var ca = map(x, 0, width, -2, 0);
var cb = map(y, 0, height, -1, 1);
var a = ca;
var b = cb;
var iter = 0;
while(iter < maxIterations) {
var aa = a * a - b * b + ca;
b = 2 * a * b + cb
a = aa;
if(a * a + b * b > maxVal) {
break;
}
iter++;
}
if (iter < maxIterations ) {
var log_zn = log(x*x + y*y) / 2;
var nu = log( log_zn / log(2) ) / log(2);
iter = iter + 1 - nu;
}
var color1 = floor(iter);
var color2 = floor(iter) + 1;
var color = color1 + color2 * (iter % 1);
//colorMode(HSB);
//if(iter == maxIterations)
// stroke(0);
//else
stroke(map(color, 0, maxIterations, 0, 255));
//stroke(map(color, 0, maxIterations, 0, 255), 128, 128);
point(x, y);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment