Plotting Fractals in WebAssembly
|1: Plotting Fractals||Top||3: Basic WAT Implementation|
2: Initial Implementation
In its simplest form, the algorithm to plot either the Mandelbrot or Julia Sets is just a highly repetitive calculation known as an “escape-time” algorithm. That is, it performs a feedback loop that continues until its value either escapes to infinity, or some arbitrary time limit is reached.
- The fractal image will be displayed using the 2d context of an HTML
- We require a function that can transform the
(x, y)location of a pixel in the
canvaselement to the corresponding
(x, y)location on the complex plane. To start with, we will simply assume that such a function is available and not care about its implementation
- The escape-time algorithm must be called for every pixel in the image. This algorithm returns a number ranging between 1 and
- To plot the fractal image, we need a function that transforms the number returned by the escape-time algorithm into a colour. Again, we assume that such a function is available and do not care about its implementation.