Skip to content

LeosonH/mandelbrot-viz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 

Repository files navigation

Mandelbrot Set Visualization

Rendering the Mandelbrot Set in JavaScript

JS source: docs/appscripts/mandelbrot.js

View the visualization here!

NOT compatible with Firefox/Internet Explorer.


The Mandelbrot Set is the set of complex numbers for which sequences as defined by the following recurrence relation are not divergent (do not tend to infinity):

The script uses an escape algorithm that iterates each point on the complex plane through the recurrence relation until a certain maximum norm is reached, or a maximum number of iterations is reached. The iteration number is then recorded and use to scale the color of each of the points on the canvas.

function EscapeAlgorithm(pointX, pointY) {
    // Escape Algorithm
    var current = 0;
    var x = 0;
    var y = 0;
    /*
    While current iteration number is less than preset limit and norm is
    less than its preset limit, repeat algorithm as defined by the mandelbrot
    set recurrence relation, and increment iteration number. Return the
    iteration number at the end. 
    */
    while ((current < MAX_ITERATIONS) && (x * x + y * y < MAX_NORM)) {
      const xNext = x * x - y * y;
      const yNext = 2 * x * y;
      x = xNext + pointX;
      y = yNext + pointY;
      current++;
    }

    return current;
}

More about the Mandelbrot Set:

Notes of thanks to:

About

Rendering the Mandelbrot Set in Javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published