NextFractal

Mandelbrot set with binary decomposition

In this example you will learn how to create a Mandelbrot set with a binary decomposition.

fractal {
	// Set region margins to left=-3.0, bottom=-1.5, right=0.0, top=1.5
	// Declare state vector as [x,n] where x and n are built-in variables
	orbit [<-3.0,-1.5>,<0.0,1.5>] [x,n] {
		// Iterate for n from 0 to 200 stopping when mod2(x) > 40
		loop [0, 200] (mod2(x) > 40) {
			// Declare orbit equation where x is a state variable and w is current point of region
			x = x * x + w;
		}
	}
	// Set background color to alpha=1, red=0, green=0, blue=0
	color [(1,0,0,0)] {
		// Initialize local variables a and c
		init {
			a = atan2(re(x),im(x));
			c = 0;
			if (a > 0) {
				c = 1;
			}
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1.0] {
			// Set color components to alpha=1, red=c, green=c, blue=c
			c
		}
	}
}

Execute the script above in NextFractal and you will get the image below:

Create your own fractals

Download NextFractal and start creating your own fractal images. NextFractal is free software, available for Mac, Windows and Linux. The latest release of NextFractal and the source code are available on GitHub.

DOWNLOAD