Examples - nextbreakpoint/nextfractal GitHub Wiki

Here are some examples of scripts for generating variant of the Mandelbrot set using various techniques for colouring the image.

Basic image with two colours

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) > 4
		loop [0, 200] (mod2(x) > 4) {
			// 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=1, green=1, blue=1
	color [(1,1,1,1)] {
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1.0] {
			// Set color components to alpha=1, red=0, green=0, blue=0
			1,0,0,0
		}
	}
}

Image with simple gradient

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) > 4
		loop [0, 200] (mod2(x) > 4) {
			// 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)] {
		// Create palette with 200 colors and name gradient
		palette gradient {
			// Create 20 interpolated colors from FFFF0000 to FFFFFFFF
			[#FFFF0000 > #FFFFFFFF, 20];
			// Create 180 interpolated colors from FFFFFFFF to FF000000
			[#FFFFFFFF > #FF000000, 180];
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1.0] {
			// Set color to element n - 1 of gradient (gradient has 200 colors starting from index 0)
			gradient[n - 1]
		}
	}
}

Image with 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
		}
	}
}

Combine gradient with non linear function

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)] {
		// Create palette with 200 colors and name gradient
		palette gradient {
			// Create 100 interpolated colors from FFFFFFFF to FF000000
			[#FFFFFFFF > #FF000000, 100];
			// Create 100 interpolated colors from FF000000 to FFFFFFFF
			[#FF000000 > #FFFFFFFF, 100];
		}
		// Initialize variables p and m
		init {
			// Create variable p limited to interval [-1,+1]
			p = sin(mod(x) * 0.22 / pi);
			// Create variable m limited to interval [0,200]
			m = 200 * ((1 + p) / 2);
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1.0] {
			// Set color to element m - 1 (gradient has 200 colors starting from index 0)
			gradient[m - 1]
		}
	}
}

Derive colour from modulus of state variable

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 variable c
		init {
			c = mod2(x) / 1000;
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Compute color components and set alpha component = 1
			(1 + sin(c * 3 / pi)) / 2
		}
	}
}

Derive colour from phase of state variable

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 variable c
		init {
			c = ;
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Compute color components and set alpha component = 1
			(1 + sin(c * 5 / pi)) / 2
		}
	}
}

Use opacity to compose rules

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 variables c1 and c2
		init {
			c1 = mod2(x) / 1000;
			c2 = ;
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1.0] {
			// Compute color components and set alpha component = 1
			(1 + cos(c1 * 3 / pi)) / 2
		}
		// Apply rule when n > 0 and set opacity to 0.5
		rule (n > 0) [0.5] {
			// Compute color components and set alpha component = 1
			(1 + sin(c2 * 5 / pi)) / 2
		}
	}
}  

Assign value to colour component

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 variables c1 and c2
		init {
			c1 = mod2(x) / 1000;
			c2 = ;
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Compute alpha component
			1,
			// Compute red component
			(1 + cos(c1 * 3 / pi)) / 2,
			// Compute green component
			(1 + sin(c1 * 5 / pi)) / 2,
			// Compute blue component
			(1 + sin((c2 / c1) * 2 / pi)) / 2
		}
	}
}  

Assign value to alpha component

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 variables c1 and c2
		init {
			c1 = mod2(x) / 1000;
			c2 = ;
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Compute alpha component
			(1 + sin(c1 / c2 * 10 / pi)) / 2,
			// Compute red component
			(1 + sin(c2 * 1 / pi)) / 2,
			// Compute green component
			(1 + sin(c2 * 1 / pi)) / 2,
			// Compute blue component
			(1 + sin(c2 * 1 / pi)) / 2
		}
	}
}

Use expression to activate rule

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 variables c1 and c2
		init {
			c1 = mod2(x) * 500;
			c2 = ;
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Compute alpha component
			1,
			// Compute red component
			(1 + sin(c2 * 20 / pi)) / 2,
			// Compute green component
			(1 + sin(c2 * 20 / pi)) / 2,
			// Compute blue component
			(1 + sin(c2 * 20 / pi)) / 2
		}
		// Apply rule when n = 0 and set opacity to 1.0
		rule (n = 0) [1] {
			// Compute alpha component
			1,
			// Compute red component
			(1 + sin(c1 * 1 / pi)) / 2,
			// Compute green component
			(1 + sin(c1 * 1 / pi)) / 2,
			// Compute blue component
			(1 + sin(c1 * 1 / pi)) / 2
		}
	}
}  

Use state variables in rule expression

fractal {
	// Set region margins to left=-3.0, bottom=-1.5, right=0.0, top=1.5
	// Declare state vector as [x,n,p] where x and n are built-in variables, and p is a custom variable
	orbit [<-3.0,-1.5>,<0.0,1.5>] [x,n,p] {
		// Initialize variable p
		begin {
			p = w;
		}
		// 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 variables c1 and c2
		init {
			c1 = mod2(x) / 1000;
			c2 = ;
		}
		// Apply rule when n > 0 and re(p) >= 0 and im(p) >= 0 and set opacity to 1.0
		rule (n > 0 & re(p) >= 0 & im(p) >= 0) [1] {
			// Compute alpha component
			1,
			// Compute red component
			(1 + sin(c2 / pi)) / 2,
			// Compute green component
			(1 + sin(c2 / pi)) / 2,
			// Compute blue component
			(1 + sin(c1 / pi)) / 2
		}
		// Apply rule when n > 0 and re(p) >= 0 and im(p) < 0 and set opacity to 1.0
		rule (n > 0 & re(p) >= 0 & im(p) < 0) [1] {
			// Compute alpha component
			1,
			// Compute red component
			(1 + sin(c1 / pi)) / 2,
			// Compute green component
			(1 + sin(c2 / pi)) / 2,
			// Compute blue component
			(1 + sin(c1 / pi)) / 2
		}
		// Apply rule when n > 0 and re(p) < 0 and im(p) >= 0 and set opacity to 1.0
		rule (n > 0 & re(p) < 0 & im(p) >= 0) [1] {
			// Compute alpha component
			1,
			// Compute red component
			(1 + sin(c2 / pi)) / 2,
			// Compute green component
			(1 + sin(c1 / pi)) / 2,
			// Compute blue component
			(1 + sin(c2 / pi)) / 2
		}
		// Apply rule when n > 0 and re(p) < 0 and im(p) < 0 and set opacity to 1.0
		rule (n > 0 & re(p) < 0 & im(p) < 0) [1] {
			// Compute alpha component
			1,
			// Compute red component
			(1 + sin(c2 / pi)) / 2,
			// Compute green component
			(1 + sin(c1 / pi)) / 2,
			// Compute blue component
			(1 + sin(c1 / pi)) / 2
		}
	}
}

Use state variables in color expression

fractal {
	// Set region margins to left=-3.0, bottom=-1.5, right=0.0, top=1.5
	// Declare state vector as [x,n,p,q] where x and n are built-in variables, and p and q are custom variables
	orbit [<-3.0,-1.5>,<0.0,1.5>] [x,n,p,q] {
		// Initialize variables p and q
		begin {
			p = <0,0>;
			q = 0;
		}
		// Iterate for n from 0 to 200 stopping when re(x) > 1000000
		loop [0, 200] (re(x) > 1000000) {
			// Declare orbit equation where x is a state variable and w is current point of region
			x = x * x + w;
			m = |x|;
			if (m > re(q)) {
				p = x;
				q = m;
			}
			// Additional stop condition
			if (m > 2) {
				stop;
			}
		}
	}
	// Set background color to alpha=1, red=0, green=0, blue=0
	color [(1,0,0,0)] {
		// Initialize variables c1 and c2
		init {
			c1 = |p|;
			c2 =
;
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Compute alpha component
			1,
			// Compute red component
			(1 + sin(c1 / pi)) / 2,
			// Compute green component
			(1 + cos(c2 / pi)) / 2,
			// Compute blue component
			(1 + sin(c1 / pi)) / 2
		}
	}
}

Use simple orbit trap

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] {
		// Declare rectangular orbit trap with center in (0,0) and name rectangle
		trap rectangle [<0,0>] {
			MOVETO(<0,0>);
			LINETO(<0,1>);
			LINETO(<1,1>);
			LINETO(<1,0>);
			LINETO(<0,0>);
		}
		// Iterate for n from 0 to 200 stopping when mod2(x) > 4 or x falls inside trap rectangle
		loop [0, 200] (mod2(x) > 4 | rectangle ? x) {
			// 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)] {
		// Create palette with 200 colors and name gradient
		palette gradient {
			[#FFFF0000 > #FFFFFFFF, 10];
			[#FFFFFFFF > #FFFF0000, 190];
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Set color to element n - 1 of gradient (gradient has 200 colors starting from index 0)
			gradient[n - 1]
		}
	}
}

Use multiple orbit traps

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] {
		// Declare circular orbit trap with center in (0,0) and name circle0
		trap circle0 [<0,0>] {
			MOVETO(<1,0>);
			ARCTO(<1,1>,<0,1>);
			ARCTO(<-1,1>,<-1,0>);
			ARCTO(<-1,-1>,<0,-1>);
			ARCTO(<1,-1>,<1,0>);
		}
		// Declare circular orbit trap with center in (0,0) and name circle1
		trap circle1 [<0,0>] {
			MOVETO(<1.1,0>);
			ARCTO(<1.1,1.1>,<0,1.1>);
			ARCTO(<-1.1,1.1>,<-1.1,0>);
			ARCTO(<-1.1,-1.1>,<0,-1.1>);
			ARCTO(<1.1,-1.1>,<1.1,0>);
		}
		// Iterate for n from 0 to 200 stopping when mod2(x) > 4 or x falls outside trap circle0 but inside trap circle1
		loop [0, 200] (mod2(x) > 4 | (circle0 ~? x & circle1 ? x)) {
			// 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)] {
		// Create palette with 200 colors and name gradient
		palette gradient {
			[#FFFF0000 > #FFFFFFFF, 10];
			[#FFFFFFFF > #FFFF0000, 190];
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Set color to element n - 1 of gradient (gradient has 200 colors starting from index 0)
			gradient[n - 1]
		}
	}
}

Mandelbrot set of high power of z

fractal {
	// Set region margins and declare state vector as [x,n] where x and n are built-in variables
	orbit [<-1.5,-1.5>,<1.5,1.5>] [x,n] {
		// Iterate for n from 0 to 200 stopping when mod2(x) > 4
		loop [0, 200] (mod2(x) > 4) {
			x = x ^ 5 + w;
		}
	}
	// Set background color to alpha=1, red=1, green=1, blue=1
	color [(1,0,0,0)] {
		// Create palette with 200 colors and name gradient
		palette gradient {
			[#FFFF0000 > #FFFFFFFF, 10];
			[#FFFFFFFF > #FFFFFFFF, 190];
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Set color to element n - 1 of gradient (gradient has 200 colors starting from index 0)
			gradient[n - 1]
		}
	}
}    

Mandelbrot set of rational power of z

fractal {
	// Set region margins and 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) > 4
		loop [0, 200] (mod2(x) > 4) {
			x = x ^ 2.5 + w;
		}
	}
	// Set background color to alpha=1, red=1, green=1, blue=1
	color [(1,0,0,0)] {
		// Create palette with 200 colors and name gradient
		palette gradient {
			[#FFFF0000 > #FFFFFFFF, 10];
			[#FFFFFFFF > #FFFFFFFF, 190];
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Set color to element n - 1 of gradient (gradient has 200 colors starting from index 0)
			gradient[n - 1]
		}
	}
}

Mandelbrot set of trigonometric function sin(z)

fractal {
	// Set region margins and declare state vector as [x,n] where x and n are built-in variables
	orbit [<-3.0,-3.0>,<3.0,3.0>] [x,n] {
		begin {
			// Julia is an internal variable
			if (~julia) {
				// Set variable x to initial state pi / 2
				x = ;
			}
		}
		// Iterate for n from 0 to 200 stopping when abs(im(x)) > 100
		loop [0, 200] (abs(im(x)) > 100) {
			// Precalculate values
			xr = re(x);
			xi = im(x);
			wr = re(w);
			wi = im(w);
			ta = cos(xr);
			tb = sin(xr);
			tc = exp(+xi);
			td = exp(-xi);
			te = 0.5 * tb * (tc + td);
			tf = 0.5 * ta * (tc - td);
			zr = wr * te - wi * tf;
			zi = wi * te + wr * tf;
			// Set x to complex number zr + zi i
			x = ;
		}
	}
	// Set background color to alpha=1, red=1, green=1, blue=1
	color [(1,0,0,0)] {
		// Create palette with 200 colors and name gradient
		palette gradient {
			[#FFFF0000 > #FFFFFFFF, 10];
			[#FFFFFFFF > #FFFFFFFF, 190];
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Set color to element n - 1 of gradient (gradient has 200 colors starting from index 0)
			gradient[n - 1]
		}
	}
}

Mandelbrot set of trigonometric function cos(z)

fractal {
	// Set region margins and declare state vector as [x,n] where x and n are built-in variables
	orbit [<-3.0,-3.0>,<3.0,3.0>] [x,n] {
		// Iterate for n from 0 to 200 stopping when abs(im(x)) > 100
		loop [0, 200] (abs(im(x)) > 100) {
			// Precalculate values
			xr = re(x);
			xi = im(x);
			wr = re(w);
			wi = im(w);
			ta = cos(xr);
			tb = sin(xr);
			tc = exp(+xi);
			td = exp(-xi);
			te = 0.5 * ta * (tc + td);
			tf = 0.5 * tb * (tc - td);
			zr = wr * te + wi * tf;
			zi = wi * te - wr * tf;
			// Set x to complex number zr + zi i
			x = ;
		}
	}
	// Set background color to alpha=1, red=1, green=1, blue=1
	color [(1,0,0,0)] {
		// Create palette with 200 colors and name gradient
		palette gradient {
			[#FFFF0000 > #FFFFFFFF, 10];
			[#FFFFFFFF > #FFFFFFFF, 190];
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Set color to element n - 1 of gradient (gradient has 200 colors starting from index 0)
			gradient[n - 1]
		}
	}
}

Mandelbrot set of trigonometric function exp(z)

fractal {
	// Set region margins and declare state vector as [x,n] where x and n are built-in variables
	orbit [<-5.0,-5.0>,<5.0,5.0>] [x,n] {
		// Iterate for n from 0 to 200 stopping when re(x) > 1000
		loop [0, 200] (re(x) > 1000) {
			// Precalculate values
			xr = re(x);
			xi = im(x);
			wr = re(w);
			wi = im(w);
			tc = exp(xr);
			ta = cos(xi) * tc;
			tb = sin(xi) * tc;
			zr = wr * ta - wi * tb;
			zi = wi * ta + wr * tb;
			// Set x to complex number zr + zi i
			x = ;
		}
	}
	// Set background color to alpha=1, red=1, green=1, blue=1
	color [(1,0,0,0)] {
		// Create palette with 200 colors and name gradient
		palette gradient {
			[#FFFF0000 > #FFFFFFFF, 10];
			[#FFFFFFFF > #FFFFFFFF, 190];
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Set color to element n - 1 of gradient (gradient has 200 colors starting from index 0)
			gradient[n - 1]
		}
	}
}

Newton-Raphson equation

fractal {
	// Set region margins and declare state vector as [x,n] where x and n are built-in variables
	orbit [<-1.5,-1.5>,<1.5,1.5>] [x,n] {
		begin {
			s = 0;
			if (~julia) {
				x = w;
				w = 1;
			}
		}
		loop [0, 200] (s = 1) {
			ta = x * x;
			tb = x * ta;
			tc = tb - w;
			if (mod2(tc) < 0.0000001) {
				x = x - w;
				stop;
			}
			tc = 2 * tb + w;
			td = 3 * ta;
			if (mod2(td) < 0.000000000000000000000001) {
				td = <0.000000000001, 0>;
			}
			x = tc / td;
		}
	}
	// Set background color to alpha=1, red=1, green=1, blue=1
	color [(1,0,0,0)] {
		// Create palette with 200 colors and name gradient
		palette gradient {
			[#FFFF0000 > #FFFFFFFF, 15];
			[#FFFFFFFF > #FFFFFFFF, 185];
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Set color to element n - 1 of gradient (gradient has 200 colors starting from index 0)
			gradient[n - 1]
		}
	}
}

Mandelbrot set of Magnetism equation I

fractal {
	// Set region margins and declare state vector as [x,n] where x and n are built-in variables
	orbit [2.5 - 2.5i,+7.5 + 2.5i] [x,n] {
		loop [0, 200] (re(x) > 1000 | im(x) > 1000 | mod2(x) > 40) {
			zn = x * x + w - 1;
			zd = 2 * x + w - 2;
			if (mod2(zd) < 0.000000000000000001) {
				zd = <0.000000001,0>;
			}
			z = zn / zd;
			x = z * z;
			if (mod2(x - 1) < 0.00000000000001) {
				stop;
			}
		}
	}
	// Set background color to alpha=1, red=1, green=1, blue=1
	color [(1,0,0,0)] {
		// Create palette with 200 colors and name gradient
		palette gradient {
			[#FFFF0000 > #FFFFFFFF, 15];
			[#FFFFFFFF > #FFFFFFFF, 185];
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Set color to element n - 1 of gradient (gradient has 200 colors starting from index 0)
			gradient[n - 1]
		}
	}
}

Mandelbrot set of Magnetism equation II

fractal {
	// Set region margins and declare state vector as [x,n] where x and n are built-in variables
	orbit [2.0 - 1.5i,+5.0 + 1.5i] [x,n] {
		loop [0, 200] (re(x) > 1000 | im(x) > 1000 | mod2(x) > 40) {
			ta = x * x;
			tb = x * ta;
			tc = w - 1;
			td = w - 2;
			zn = x * ta + 3 * x * tc + tc * td;
			zd = 3 * ta + 3 * x * td + w * w - 3 * w + 3;
			if (mod2(ta) < 0.000000000000000001) {
				ta = <0.000000001,0>;
			}
			z = zn / zd;
			x = z * z;
			if (mod2(x - 1) < 0.00000000000001) {
				stop;
			}
		}
	}
	// Set background color to alpha=1, red=1, green=1, blue=1
	color [(1,0,0,0)] {
		// Create palette with 200 colors and name gradient
		palette gradient {
			[#FFFF0000 > #FFFFFFFF, 15];
			[#FFFFFFFF > #FFFFFFFF, 185];
		}
		// Apply rule when n > 0 and set opacity to 1.0
		rule (n > 0) [1] {
			// Set color to element n - 1 of gradient (gradient has 200 colors starting from index 0)
			gradient[n - 1]
		}
	}
}

⚠️ **GitHub.com Fallback** ⚠️