Let's create a MandelbrotGenerator
object in a new file named mandelbrotGenerator.js
. This object will implement the algorithm that generates the Mandelbrot. The constructor takes the canvas width and height, and the bounds of the Mandelbrot:
function MandelbrotGenerator(canvasWidth, canvasHeight, left, top,right, bottom) {
Next we define the variables that the algorithm uses:
var scalarX = (right - left) / canvasWidth, scalarY = (bottom - top) / canvasHeight, maxIterations = 1000, abort = false, inSetColor = { r: 0x00, g: 0x00, b: 0x00 }, colors = [ /* array of color objects */ ];
The scalarX
and scalarY
variables are used to convert the Mandelbrot coordinates to canvas coordinates. They are computed ...
No credit card required