the video you linked is
p5.js
the code you can download is
// Daniel Shiffman
// http://codingtra.in
// http://patreon.com/codingtrain
// Code for: https://youtu.be/6z7GQewK-Ks
var minval = -0.5;
var maxval = 0.5;
var minSlider;
var maxSlider;
var frDiv;
function setup() {
createCanvas(200, 200);
pixelDensity(1);
minSlider = createSlider(-2.5, 0, -2.5, 0.01);
maxSlider = createSlider(0, 2.5, 2.5, 0.01);
frDiv = createDiv('');
}
function draw() {
var maxiterations = 100;
loadPixels();
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
var a = map(x, 0, width, minSlider.value(), maxSlider.value());
var b = map(y, 0, height, minSlider.value(), maxSlider.value());
var ca = a;
var cb = b;
var n = 0;
while (n < maxiterations) {
var aa = a * a - b * b;
var bb = 2 * a * b;
a = aa + ca;
b = bb + cb;
if (a * a + b * b > 16) {
break;
}
n++;
}
var bright = map(n, 0, maxiterations, 0, 1);
bright = map(sqrt(bright), 0, 1, 0, 255);
if (n == maxiterations) {
bright = 0;
}
var pix = (x + y * width) * 4;
pixels[pix + 0] = bright;
pixels[pix + 1] = bright;
pixels[pix + 2] = bright;
pixels[pix + 3] = 255;
}
}
updatePixels();
frDiv.html(floor(frameRate()));
}
you can not compare it with the JAVA ( CC_021_Mandelbrot.pde ) code
// Daniel Shiffman
// http://codingtra.in
// http://patreon.com/codingtrain
// Code for: https://youtu.be/6z7GQewK-Ks
void setup() {
size(640, 480);
colorMode(RGB, 1);
}
void draw() {
background(255);
// Establish a range of values on the complex plane
// A different range will allow us to "zoom" in or out on the fractal
// It all starts with the width, try higher or lower values
float w = 5;
float h = (w * height) / width;
// Start at negative half the width and height
float xmin = -w/2;
float ymin = -h/2;
// Make sure we can write to the pixels[] array.
// Only need to do this once since we don't do any other drawing.
loadPixels();
// Maximum number of iterations for each point on the complex plane
int maxiterations = 100;
// x goes from xmin to xmax
float xmax = xmin + w;
// y goes from ymin to ymax
float ymax = ymin + h;
// Calculate amount we increment x,y for each pixel
float dx = (xmax - xmin) / (width);
float dy = (ymax - ymin) / (height);
// Start y
float y = ymin;
for (int j = 0; j < height; j++) {
// Start x
float x = xmin;
for (int i = 0; i < width; i++) {
// Now we test, as we iterate z = z^2 + cm does z tend towards infinity?
float a = x;
float b = y;
int n = 0;
while (n < maxiterations) {
float aa = a * a;
float bb = b * b;
float twoab = 2.0 * a * b;
a = aa - bb + x;
b = twoab + y;
// Infinty in our finite world is simple, let's just consider it 16
if (a*a + b*b > 16.0) {
break; // Bail
}
n++;
}
// We color each pixel based on how long it takes to get to infinity
// If we never got there, let's pick the color black
if (n == maxiterations) {
pixels[i+j*width] = color(0);
} else {
// Gosh, we could make fancy colors here if we wanted
pixels[i+j*width] = color(sqrt(float(n) / maxiterations));
}
x += dx;
}
y += dy;
}
updatePixels();
println(frameRate);
}
are you sure you know what you want learn first?