comment { Copyright © 1999-2018 by Mark Townsend. Coloring algorithms for Ultra Fractal 2.0 and above Last update 3 October 2018 ; This work is licensed under a Creative Commons ; Attribution-NonCommercial-ShareAlike 4.0 International License. ; http://creativecommons.org/licenses/by-nc-sa/4.0/ } mt-newton-basins { ; Mark Townsend, 21 Mar 1999 ; ; I presume that each root has a unique angle ; and offset into the gradient accordingly. This ; won't work in all cases (it fails, for instance, ; when one of the roots is zero). ; init: s = 1e10 oldz = 0 int iter = 0 int count = 0 float sum = 0 float offset = 0 float rnd = @r * real(#random) loop: if @mode == 2 sum = sum + log(1 / @epsilon * |#z - oldz|) oldz = #z elseif @mode == 3 if |#z| < |s| s = #z endif elseif @mode == 4 if |#z| < |s| s = #z iter = count endif count = count + 1 endif final: offset = atan2(#z) if offset < 0 offset = offset + 2 * #pi endif offset = 1 / (2 * #pi) * offset if @mode == 0 #index = offset elseif @mode == 1 #index = offset + @d * 0.01 * #numiter + rnd elseif @mode == 2 #index = offset + @d * 0.001 * sum + rnd elseif @mode == 3 #index = offset + @d * 0.1 * cabs(s) + rnd elseif @mode == 4 #index = offset + @d * 0.01 * iter + rnd elseif @mode == 5 #index = offset + @d * 0.1 * cabs(#z - #pixel) + rnd endif default: title = "Newton Basins" param mode caption = "Coloring" enum = "Basins" "Iteration" "Smooth" "Bof60" "Bof61" "Distance" default = 1 endparam param d caption = "Density" default = 1.0 hint = "Use this rather than Color Density to \ maintain the separation of the basins." endparam param epsilon caption = "Epsilon" default = 1e-6 hint = "If you are using the smooth coloring mode \ try setting this to the bailout value of \ your fractal. Some tweaking may be required." endparam param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } mt-magnet-basins { ; Mark Townsend, 21 Mar 1999 ; ; This coloring method is designed to highlight ; the basins of attractions for Magnet type ; fractals. There are "superstable" attractors ; at 1 and infinity, so I test for those and ; offset into the gradient accordingly. ; Everything else uses a third offset. ; init: s = 1e10 oldz = 0 int iter = 0 int count = 0 float sum = 0 float c_sum = 0 float d_sum = 0 float offset = 0 float rnd = @r * real(#random) loop: if @mode == 2 c_sum = c_sum + log(1 / @epsilon * |#z - oldz|) d_sum = d_sum + log(@bailout * 1 / |#z - oldz|) oldz = #z elseif @mode == 3 if |#z| < |s| s = #z endif elseif @mode == 4 if |#z| < |s| s = #z iter = count endif count = count + 1 endif final: if |#z| > @bailout offset = 0 sum = d_sum elseif |#z - 1| < @epsilon offset = 1/3 sum = c_sum else offset = 2/3 sum = c_sum endif if @mode == 0 ; Basins #index = offset + rnd elseif @mode == 1 ; Iteration #index = offset + @d * 0.01 * #numiter + rnd elseif @mode == 2 ; Smooth #index = offset + @d * 0.001 * sum + rnd elseif @mode == 3 ; Bof60 #index = offset + @d * 0.1 * cabs(s) + rnd elseif @mode == 4 ; Bof61 #index = offset + @d * 0.01 * iter + rnd endif default: title = "Magnet Basins" param mode caption = "Coloring" enum = "Basins" "Iteration" "Smooth" "Bof60" "Bof61" default = 1 endparam param d caption = "Density" default = 1.0 hint = "Use this rather than Color Density to \ maintain the separation of the basins." endparam param bailout caption = "Bailout value" default = 1000.0 hint = "This is the bailout value for divergent orbits. \ It's used to determine the gradient offset and \ also for the smooth coloring algorithm." endparam param epsilon caption = "Epsilon" default = 1e-6 hint = "This is the bailout value for convergent orbits. \ It's used to determine the gradient offset and \ also for the smooth coloring algorithm." endparam param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } mt-newton-decomp { ; Mark Townsend, 5 Apr 1999 ; ; I'll confess that I don't fully understand ; the equations for binary decomposition given ; in "The Beauty of Fractals", but I've come up ; with this. It works reasonably well for all ; basins on most Newton like formulas but ; seems to fail with roots on the negative real ; axis (and maybe in other cases that I'm not ; aware of). ; init: complex z_values[#maxiter + 1] z_values[0] = #z int i = 0 oldz = #z float a = 0 float sum = 0 float iter = 0 float offset = 0 float zangle = 0 float rnd = @r * real(#random) loop: i = i + 1 ; if necessary z_values[i] = #z if @color == 2 sum = sum + log(1 / @epsilon * |#z - oldz|) oldz = #z endif final: zangle = atan2(#z) a = zangle if a < 0 a = a + 2 * #pi endif a = 1 / (2 * #pi) * a if zangle < atan2(z_values[#numiter - 1]) offset = 0 else offset = 0.5 endif if @color == 1 iter = @density * 0.01 * #numiter elseif @color == 2 iter = @density * 0.001 * sum endif if @mode == 0 #index = a + 0.25 * offset + iter + rnd elseif @mode == 1 #index = offset + iter + rnd endif default: title = "Newton Decomp" param mode caption = "Offset" enum = "Basin" "Binary" endparam param @color Caption = "Coloring" enum = "Normal" "Iteration" "Smooth" endparam param density caption = "Density" default = 1.0 hint = "Use this rather than Color Density to \ maintain the separation of the basins." endparam param epsilon caption = "Epsilon" default = 1e-6 hint = "If you are using the smooth coloring mode \ try setting this to the bailout value of \ your fractal." endparam param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } mt-pseudo-lyapunov { ; Mark Townsend, 25 Feb 1999 ; ; This coloring method is based on the ; equations used to calculate the Lyapunov ; exponent in Clifford A. Pickover's book ; "Chaos in Wonderland". ; init: a = 0 b = 0 oldz = 0 float dlz = 0 float df = 0 float dl2 = 0 float sum = 0 float offset = 0 float rnd = @r * real(#random) loop: if @v1 == 0 a = #z elseif @v1 == 1 a = real(#z) elseif @v1 == 2 a = imag(#z) elseif @v1 == 3 a = atan2(#z) elseif @v1 == 4 a = oldz elseif @v1 == 5 a = real(oldz) elseif @v1 == 6 a = imag(oldz) elseif @v1 == 7 a = atan2(oldz) endif if @v2 == 0 b = #z elseif @v2 == 1 b = real(#z) elseif @v2 == 2 b = imag(#z) elseif @v2 == 3 b = atan2(#z) elseif @v2 == 4 b = oldz elseif @v2 == 5 b = real(oldz) elseif @v2 == 6 b = imag(oldz) elseif @v2 == 7 b = atan2(oldz) endif dlz = |fn1(a) - fn2(b)| dl2 = dlz^2 df = 1000000000000.0 * dl2 sum = sum + log(df) oldz = #z final: if @basins offset = atan2(#z) if offset < 0 offset = offset + 2 * #pi endif offset = 1 / (2 * #pi) * offset #index = @d * sum / #numiter + offset + rnd else #index = @d * sum / #numiter + rnd endif default: title = "Pseudo Lyapunov" param v1 caption = "First variable" enum = "z" "Re(z)" "Im(z)" "Arg(z)" "Previous z" "Previous Re(z)" \ "Previous Im(z)" "Previous Arg(z)" default = 0 endparam param v2 caption = "Second variable" enum = "z" "Re(z)" "Im(z)" "Arg(z)" "Previous z" "Previous Re(z)" \ "Previous Im(z)" "Previous Arg(z)" default = 4 endparam param d caption = "Density" default = 0.0721347 endparam param basins caption = "Basins" default = false hint = "If this is enabled an offset into the gradient \ is added based on the angle of the final position of z." endparam func fn1 caption = "First Function" default = ident() endfunc func fn2 caption = "Second Function" default = ident() endfunc param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } mt-log-smoothing { ; Mark Townsend, 1 Apr 1999 ; ; A general smooth coloring method that works ; reasonably well with many fractals. Setting ; "Bailout" and "Epsilon" to the divergent and ; convergent bailout values of your fractal ; seems to work well in most cases. ; init: complex oldz = 0 complex z_values[#maxiter + 1] z_values[0] = #z int i = 0; float c_sum = 0 float d_sum = 0 float rnd = @r * real(#random) loop: i = i + 1 z_values[i] = #z c_sum = c_sum + log(1 / @epsilon * |#z - oldz|) d_sum = d_sum + log(@bailout * 1 / |#z - oldz|) oldz = #z final: if |#z - z_values[#numiter-1]| < 0.5 #index = 0.001 * c_sum + rnd else if @offset #index = 0.5 + 0.001 * d_sum + rnd else #index = 0.001 * d_sum + rnd endif endif default: title = "Log Smoothing" param bailout caption = "Bailout" default = 1000.0 hint = "A good value to try is the divergent \ bailout value of your fractal." endparam param epsilon caption = "Epsilon" default = 1e-6 hint = "A good value to try is the convergent \ bailout value of your fractal." endparam param offset caption = "Offset divergent" default = false hint = "If this is enabled an offset into the \ gradient will be added to divergent \ orbits." endparam param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } mt-pseudo-basins { ; Mark Townsend, 10 Apr 1999 ; ; I thought my "Pseudo Magnet" formula was ; nice enough to have its own coloring ; method. This is the same as "Newton ; Basins" except that it takes into account ; the divergent orbits of that formula. ; init: complex z_values[#maxiter + 1] z_values[0] = #z int i = 0 s = 1e10 oldz = 0 int iter = 0 int count = 0 float sum = 0 float c_sum = 0 float d_sum = 0 float offset = 0 float rnd = @r * real(#random) loop: i = i + 1 ; if necessary z_values[i] = #z if @mode == 2 c_sum = c_sum + log(1 / @epsilon * |#z - oldz|) d_sum = d_sum + log(@bailout * 1/|#z - oldz|) oldz = #z elseif @mode == 3 if |#z| < |s| s = #z endif elseif @mode == 4 if |#z| < |s| s = #z iter = count endif count = count + 1 endif final: if |#z-z_values[#numiter - 1]| < 0.5 sum = c_sum offset = atan2(#z) if offset < 0 offset = offset + 2 * #pi endif offset = 1 / (2 * #pi) * offset else offset = 0 sum = d_sum endif if @mode == 0 #index = offset elseif @mode == 1 #index = offset + @d * 0.01 * #numiter + rnd elseif @mode == 2 #index = offset + @d * 0.001 * sum + rnd elseif @mode == 3 #index = offset + @d * 0.1 * cabs(s) + rnd elseif @mode == 4 #index = offset + @d * 0.01 * iter + rnd elseif @mode == 5 #index = offset + @d * 0.1 * cabs(#z - #pixel) + rnd endif default: title = "Pseudo Basins" param mode caption = "Coloring" enum = "Basins" "Iteration" "Smooth" "Bof60" "Bof61" "Distance" default = 1 endparam param d caption = "Density" default = 1.0 hint = "Use this rather than Color Density to \ maintain the separation of the basins." endparam param bailout caption = "Bailout" default = 1000.0 hint = "If you are using the smooth coloring mode \ try setting this to the divergent bailout \ value of your fractal." endparam param epsilon caption = "Epsilon" default = 1e-6 hint = "If you are using the smooth coloring mode \ try setting this to the convergent bailout \ value of your fractal." endparam param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } mt-cluster { ; Mark Townsend, 13 Apr 1999 ; ; A quick attempt at a globular cluster. ; final: float p = 1 / (1 + cabs(#z)^2)^@n #index = p / 2 + real(#random) / 10 default: title = "Cluster" param n default = 2.5 endparam } AngleTrap { ; Mark Townsend, 20 Apr 1999 init: zn = 0 float diff = 0 int iter = 0 int count = 0 float ofst = 0 bool done = false bool stalk = false float m = pi / @m float rnd = @r * real(#random) loop: count = count + 1 if !done && (count - 1) >= @delay if abs(atan2(#z)) % m < @w if @bailout done = true endif diff = sqrt(abs(abs(atan2(#z)) % m - @w)) zn = #z iter = count stalk = true endif endif final: if stalk if @offset == 0 ; none ofst = 0 elseif @offset == 1 ; alternate ofst = 1 / (@bands - (iter % @bands)) elseif @offset == 2 ; stripes ofst = 1 / (@bands - (round((abs(atan2(zn))) * 10) % (1/@w))) endif if @color == 0 #index = ofst + @d * 0.01 * iter + rnd elseif @color == 1 #index = ofst + @d * 0.1 * cabs(zn) + rnd elseif @color == 2 float a = atan2(zn) if a < 0 a = a + 2 * #pi endif #index = ofst + @d * (1 / (2 * #pi) * a) + rnd elseif @color == 3 #index = ofst + @d * diff + rnd endif else #solid = true endif default: title = "Angle Trap" param @color caption = "Coloring" enum = "Iteration" "Magnitude" "Angle" "Distance" endparam param offset caption = "Offset" enum = "None" "Alternate" "Stripes" endparam param w caption = "Width" default = 0.1 endparam param m caption = "Modulus" default = 1.0 min = 1.0 endparam param bands caption = "Bands" default = 2 min = 2 endparam param d caption = "Density" default = 1.0 endparam param delay caption = "Iterations to skip" default = 0 endparam param bailout caption = "Bailout" default = true endparam param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } BailoutSimulator { ; Mark Townsend, 17 Apr 1999 ; ; Simulates different bailout tests. ; init: zn = 0 int iter = 0 int count = 0 bool done = false float rnd = @r * real(#random) loop: count = count + 1 if !done if @test == 0 ; mod if |#z| > @bailout zn = #z iter = count done = true endif elseif @test == 1 ; real if sqr(real(#z)) > @bailout zn = #z iter = count done = true endif elseif @test == 2 ; imag if sqr(imag(#z)) > @bailout zn = #z iter = count done = true endif elseif @test == 3 ; or if sqr(real(#z)) > @bailout || sqr(imag(#z)) > @bailout zn = #z iter = count done = true endif elseif @test == 4 ; and if sqr(real(#z)) > @bailout && sqr(imag(#z)) > @bailout zn = #z iter = count done = true endif elseif @test == 5 ; manh if sqr(abs(real(#z)) + abs(imag(#z))) > @bailout zn = #z iter = count done = true endif elseif @test == 6 ; manr if sqr(real(#z) + imag(#z)) > @bailout zn = #z iter = count done = true endif endif endif final: if @mode != 0 && !@diviter iter = 1 endif if @mode == 0 ; iter #index = 0.01 * iter + rnd elseif @mode == 1 ; mag #index = cabs(zn) / iter + rnd elseif @mode == 2 ; angle float angle = atan2(zn) if angle < 0 angle = angle + 2 * #pi endif #index = 1 / (2 * #pi) * angle / iter + rnd endif default: title = "Bailout Simulator" param test caption = "Bailout test" enum = "mod" "real" "imag" "or" "and" "manh" "manr" default = 0 endparam param bailout caption = "Bailout value" default = 4.0 endparam param mode caption = "Coloring" enum = "Iteration" "Magnitude" "Angle" endparam param diviter caption = "Iterations" default = false endparam param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } mt-cont-pot { ; Mark Townsend, 5 Apr 1999 ; ; From the Fractint manual ; final: #index = log(cabs(#z)) / 2^#numiter + @r * real(#random) default: title = "Continuous Potential" param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } mt-dist-est { ; Mark Townsend, 5 Apr 1999 ; ; Distance estimator coloring for the ; Mandelbrot set from the Mu-ency web site. ; Try the cube root transfer function. ; init: dz = 0 float rnd = @r * real(#random) loop: dz = 2 * #z * dz + 1 final: float cz = cabs(#z) #index = log(cz*cz) * cz / cabs(dz) + rnd default: title = "Distance Estimator" param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } mt-origin { ; Mark Townsned, 23 Apr 1999 ; ; Coloring by the closest approach to the origin. ; The equation for the "Log" coloring mode ; comes from Stefan Schroeder's "Log Iter ; Smoothing" coloring method (it's not the ; effect that I was looking for but it works well). ; init: s = 1e20 int iter = 0 int count = 0 float offset = 0 float rnd = @r * real(#random) loop: if |#z| < |s| s = #z iter = count endif count = count + 1 final: if @alt if iter % 2 == 0 offset = 0.5 endif endif float c = cabs(s) if c > @radius #solid = true else if @color == 0 #index = offset + 0.01 * iter + rnd elseif @color == 1 #index = offset + c + rnd elseif @color == 2 float a = atan2(s) if a < 0 a = a + 2 * #pi endif a = 1 / (2 * #pi) * a #index = offset + a + rnd elseif @color == 3 #index = offset + abs(cabs(s) - @radius) + rnd elseif @color == 4 #index = offset + (iter - (log(|s|)/log(@radius) - 1))/100 + rnd elseif @color == 5 #index = offset + real(s) + rnd elseif @color == 6 #index = offset + imag(s) + rnd endif endif default: title = "Species of Origin" param @color caption = "Coloring" enum = "Iteration" "Magnitude" "Angle" "Distance" "Log" "Real" "Imaginary" endparam param radius caption = "Radius" hint = "If the orbit crosses this point it is mapped \ to the background color." default = 2.0 endparam param alt caption = "Alternate" hint = "If this is enabled alternate iterations are \ mapped to different halves of the gradient." default = false endparam param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } mt-crossings { ; Mark Townsend, 24 Apr 1999 ; ; Coloring by the number of times the orbit ; crosses the imaginary axis (I think). ; init: oldz = zn = 0 int hits = 0 int iter = 0 int count = 0 bool done = false float sum = 0 float rnd = @r * real(#random) loop: if !done || !@first if real(#z) < 0 && real(oldz) > 0 sum = sum + log(@epsilon * real(#z)) hits = hits + 1 zn = #z iter = count done = true elseif real(#z) > 0 && real(oldz) < 0 sum = sum + log(@epsilon * real(#z)) hits = hits + 1 zn = #z iter = count done = true endif endif oldz = #z count = count + 1 final: if hits < @threshold #solid = true else if @color == 0 #index = 0.01 * iter + rnd elseif @color == 1 #index = 0.05 * cabs(zn) + rnd elseif @color == 2 float a = atan2(zn) if a < 0 a = a + 2 * #pi endif a = 1 / (2 * #pi) * a #index = a + rnd elseif @color == 3 #index = 0.01 * sum + rnd elseif @color == 4 #index = 0.01 * real(zn) + rnd elseif @color == 5 #index = 0.01 * imag(zn) + rnd endif endif default: title = "Imaginary Crossings" param @color caption = "Coloring" default = 3 enum = "Iteration" "Magnitude" "Angle" "Log" "Real" "Imaginary" endparam param threshold caption = "Threshold" hint = "Orbits that cross the axis less than this \ many times are set to the background color." default = 1 min = 0 endparam param epsilon caption = "Log density" hint = "This is used in the 'Log' coloring mode." default = 10.0 endparam param first caption = "First crossing" hint = "If this is enabled only the first axis \ crossing is monitored." default = false endparam param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } mt-epsilon-cross { ; Mark Townsend, 25 Apr 1999 ; ; Epsilon Cross, but the lines can move. ; init: zn = 0 int iter = 0 int count = 0 float rline = real(@start) float iline = imag(@start) float rinc = real(@inc) float iinc = imag(@inc) float offset = 0 bool done = false int stalk = 0 float rnd = @r * real(#random) loop: if count != 0 if !done || !@first if abs(real(#z)-rline) < @w zn = #z done = true stalk = 1 iter = count elseif abs(imag(#z)-iline) < @w zn = #z done = true stalk = 2 iter = count endif endif endif count = count + 1 iline = iline + iinc rline = rline + rinc final: if @ofst == 0 offset = 0 elseif @ofst == 1 if stalk == 2 offset = 0.5 endif else if iter % 2 == 0 offset = 0.5 endif endif if stalk == 0 #solid = true else if @color == 0 #index = offset + 0.01 * iter + rnd elseif @color == 1 #index = offset + cabs(zn) + rnd elseif @color == 2 float a = atan2(zn) if a < 0 a = a + 2 * #pi endif a = 1 / (2 * #pi) * a #index = offset + a + rnd elseif @color == 3 if stalk == 1 float c = abs(real(zn)) else float c = abs(imag(zn)) endif #index = offset + c + rnd elseif @color == 4 #index = offset + abs(real(zn)) + rnd elseif @color == 5 #index = offset + abs(imag(zn)) + rnd endif endif default: title = "Epsilon Crossing" param @color caption = "Coloring" enum = "Iteration" "Magnitude" "Angle" "Axis" "Real" "Imag" endparam param ofst caption = "Offset" enum = "None" "Axis" "Iteration" endparam param w caption = "Width" hint = "This controls the width of the stalks." default = 0.1 endparam param start caption = "Start" default = (0,0) endparam param inc caption = "Increment" default = (0.01, 0.01) endparam param first caption = "Bailout" hint = "If this is enabled only the first iteration to \ approach the axes is monitored." default = true endparam param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } CarlsonBubbles1 {; Mark Townsend, 28 April 1999 ; ; ****** NOTE ******* ; Instead of using this coloring method use ; the 3D Bubbles mode of the Paul Carlson's ; Orbit Traps method in pwc.ucl. ; ******************* ; ; Modified directly from Paul W. Carlson's ; MandelBubs1 fomula. I've added the option ; to use a solid background for easy opacity. ; init: float i = 0 float temp = 0 float min_w = 1.0e20 float index_factor = 249.0/@max_min_w loop: temp = cabs(#z) if (temp < min_w) min_w = temp endif final: if (min_w < @max_min_w) i = index_factor * min_w else if @solid #solid = true else i = 253.0 endif endif #index = ((i + 1) % 256) / 256 default: title = "Carlson Bubbles" param max_min_w caption = "Bubble radius" default = 0.188 endparam param solid caption = "Solid background" default = false endparam } Carlson3Way { ; Mark Townsend, 28 April 1999 ; ; ****** NOTE ******* ; Instead of using this coloring method use ; the 3-Way mode of the Paul Carlson's Orbit ; Traps method in pwc.ucl. ; ******************* ; ; Modifed directly from Paul Carlson's ; Mandel_3Way formula. ; init: bool done = false float r = @rad2 float skipiters = @skip int iters = 0 float range_num = 0 float prev_modw2 = 1.0e20 float clr = 253 float index = 0 loop: if !done if ((prev_modw2 < r) && (|#z| > r) && iters > skipiters) done = true index = 124.0 * (r - prev_modw2) / r clr = index + range_num * 125.0 endif endif prev_modw2 = |#z| range_num = range_num + 1 if (range_num > 1.5) range_num = 0 endif iters = iters + 1 final: #index = (clr + 1) % 256 / 256 default: title = "Carlson 3-Way" param rad2 caption = "Radius squared" default = 4.0 hint = "Radius squared." endparam param skip caption = "Iterations to skip" default = 21 hint = "Iterations to skip." endparam } TangentCircles { ; Mark Townsend, 29 Apr 1999 ; ; ****** NOTE ******* ; Instead of using this coloring method use ; the Tangent Balls mode of the Paul Carlson's ; Orbit Traps method in pwc.ucl. ; ******************* ; ; Paul W. Carlson's Tangent Circles oribit trap ; method. ; init: int iter = 0 float x = 0 float y = 0 float Xabs = 0 float Yabs = 0 float Dsgd0 = 0 float Dsgd1 = 0 float Dsgd2 = 0 float Circle = 0 float ZtoPsqd = 0 float Rc = @r float Phi = #pi * 0.125 float Rm = Rc / sin(Phi) float RcSqd = Rc^2 float Py = Rm * sin(2 * Phi) float Px = Rm * cos(2 * Phi) bool Trapped = false loop: iter = iter + 1 x = real(#z) y = imag(#z) if abs((cabs(#z) - Rm)) < Rc && iter > @skip && !Trapped Xabs = abs(x) Yabs = abs(y) Dsgd0 = Xabs^2 + (Yabs - Rm)^2 Dsgd1 = (Xabs - Px)^2 + (Yabs - Py)^2 Dsgd2 = (Xabs - Rm)^2 + Yabs^2 if Dsgd0 < RcSqd Trapped = true ZtoPsqd= Dsgd0 if y > 0 Circle = 0 else Circle = 4 endif elseif Dsgd1 < RcSqd Trapped = true ZtoPsqd= Dsgd1 if Y > 0&& x > 0 Circle = 1 elseif y < 0 && x > 0 Circle = 3 elseif y < 0 && x < 0 Circle = 5 else Circle = 7 endif elseif Dsgd2 < RcSqd trapped = true ZtoPsqd = Dsgd2 if x > 0 Circle = 2 else Circle = 6 endif endif endif final: if !trapped #solid = true else Circle = (Circle + @off) % 8 float Ratio = sqrt(ZtoPsqd/Rcsqd) float ColorIndex = 29 * Ratio + Circle * 30 #index = (ColorIndex + 1) % 256 /256 endif default: title = "Carlson Tangent Circles" param r caption = "Circle radius" default = 0.2 endparam param skip caption = "Iters to skip" default = 1 hint = "Iterations to skip." endparam param off caption = "Hue cycle" default = 0 min = 0 max = 7 hint = "This rotates the coloring order of the balls." endparam } mt-magnet-decomp { ; Mark Townsend, 8 Apr 1999 ; ; This formula is designed for the Magnets and ; other fractals with both convergent and ; divergent orbits. Convergent orbits are ; decomposed using the method from my ; "Newton Decomp" coloring formula, and ; divergent orbits use the same method as the ; standard "Binary Decomposition 2". The ; basins can be offset to different halves of ; the gradient. ; init: complex z_values[#maxiter + 1] z_values[0] = #z int i = 0 ; if necessary oldz = 0 float a = 0 float sum = 0 float c_sum = 0 float d_sum = 0 float iter = 0 float offset = 0 float rnd = @r * real(#random) loop: i = i + 1 ; if necessary z_values[i] = #z if @color == 2 c_sum = c_sum + log(1 / @epsilon * |#z - oldz|) d_sum = d_sum + log(@bailout * 1 / |#z - oldz|) oldz = #z endif final: if |#z-z_values[#numiter-1]| < 0.5 ; convergent sum = c_sum if atan2(#z) < atan2(z_values[#numiter - 1]) offset = 0 else offset = 0.5 endif else sum = d_sum a = 0.5 if atan2(#z) < 0 offset = 0 else offset = 0.5 endif endif if @color == 1 iter = @density * 0.01 * #numiter elseif @color == 2 iter = @density * 0.001 * sum endif if @mode == 0 #index = a + 0.25 * offset + iter + rnd elseif @mode == 1 #index = offset + iter + rnd endif default: title = "Magnet Decomp" param mode caption = "Offset" enum = "Basin" "Binary" endparam param @color Caption = "Coloring" enum = "Normal" "Iteration" "Smooth" endparam param density caption = "Density" default = 1.0 hint = "Use this rather than Color Density to \ maintain the separation of the basins." endparam param bailout caption = "Bailout" default = 1000.0 hint = "If you are using the smooth coloring mode \ try setting this to the divergent bailout \ value of your fractal." endparam param epsilon caption = "Epsilon" default = 1e-6 hint = "If you are using the smooth coloring mode \ try setting this to the convergent bailout \ value of your fractal." endparam param r caption = "Randomness" hint = "This adds a random texture to the coloring." default = 0.0 endparam } mt-martin-coloring { ; Mark Townsend, 9 May 1999 ; ; This is the Martin formula pressed into service ; as a coloring method, as suggested by Janet ; Preslar. ; init: float a = @a float xx = 0 int iter = 0 p = 0 loop: iter = iter + 1 ; Capture z if @znum == iter p = @fn1(#z) endif final: ; Use that z as the starting point float x = real(p) * 1/@scale float y = imag(p) * 1/@scale ; Iterate the Martin formula iter = 0 while iter < @max_iterations xx = x x = y - sin(x) y = a - xx iter = iter + 1 endwhile p_2 = @fn2(x + flip(y)) if cabs(p) > @threshold #index = cabs(p_2) else #solid = true endif default: title = "Martin Coloring" param a caption = "Parameter (a)" default = 3.14159 endparam param znum caption = "Catch iteration" default = 10 endparam param max_iterations caption = "Maximum iterations" default = 10 endparam param @scale caption = "Scale" default = 1.0 endparam param threshold caption = "Threshold" default = -1.0 min = -1.0 endparam func fn1 caption = "Pre function" default = ident() endfunc func fn2 caption = "Post function" default = ident() endfunc } mt-two-functions { ; Mark Townsend, 1 Jun 1999 final: float a = atan2(#z) if a < 0 a = a + 2 * #pi endif a = 1 / (2 * #pi) * a #index = real(fn1(a)) * real(fn2((#z))) default: title = "Two Functions" func fn1 caption = "First Function" default = ident() endfunc func fn2 caption = "Second Function" default = ident() endfunc } mt-traps-unplugged { ; Mark Townsend, May 1999 ; ; This is my parallel version of the "Paul Carlson's ; Orbit Traps" coloring method. It has the same orbit ; trap modes as that formula, but only a single color ; range, and some twists. All of the orbit traps were ; devised by Paul Carlson. ; init: ; Iteration counter int iter = 0 ; Real and imaginary components of z and their absolute values float x = 0 float y = 0 float Xabs = 0 float Yabs = 0 ; Temporary variable - any mode can use it as it chooses float temp = 0 ; Temporary variable for keeping track of something. float keep = 1e20 ; Flag that the orbit has been trapped bool trapped = false float color_index = 0 complex trap_z = 0 ; Tangent Balls & Flexballs ; float ratio = 0 float Dsqd0 = 0 float Dsqd1 = 0 float Dsqd2 = 0 float ZtoPsqd = 0 float Rc = @r float Phi = #pi / 8 float Rm = Rc / sin(Phi) float RcSqd = Rc^2 float Py = Rm * sin(2 * Phi) float Px = Rm * cos(2 * Phi) ; Fix up for FlexBalls if @trap_type == 2 Rm = @ring_radius float Ro = Rm + @r Py = 0.382683432365 * @r Px = 0.923879532511 * @r Dsqd0 = Ro * Ro + @r * @r - (Ro + Ro) * Px endif ; For Harlequin multiplier = @ring_radius ; For Squares if @trap_type == 7 ; Just pick a couple of spare variables Px = 0.5 + @r Py = 0.5 - @r endif if @no_of_iters == 0 int max_iter = #maxiter - @skip else int max_iter = @skip + @no_of_iters endif loop: ; Many modes use these... w = fn2(#z) x = real(w) y = imag(w) Xabs = abs(x) Yabs = abs(y) if @trap_type == 0 ; *** 3D Bubbles *** temp = sqrt(|w|) if (temp < keep) keep = temp ; We don't skip any iterations for bubbles IF (keep < @r) trapped = true trap_z = @fn1(w) color_index = temp endif endif elseif @trap_type == 1 ; *** 3D Stalks *** if Xabs <= Yabs temp = Xabs else temp = Yabs endif if (!trapped || !@trapping) && (iter >= @skip && iter < max_iter) && temp < @r trapped = true trap_z = @fn1(w) color_index = temp endif elseif @trap_type == 2 ; *** Flexballs *** if (!trapped || !@trapping) && (iter >= @skip && iter < max_iter) && abs((cabs(w) - Rm)) < @r trapped = true trap_z = @fn1(w) if Xabs >= Yabs ZtoPsqd = (Xabs - Px)^2 + (Yabs - Py)^2 else ZtoPsqd = (Xabs - Py)^2 + (Yabs - Px)^2 endif color_index = sqrt(ZtoPsqd / Dsqd0) endif elseif @trap_type == 3 ; *** Tangent Balls *** if (!trapped || !@trapping) && (iter >= @skip && iter < max_iter) && abs((cabs(w) - Rm)) < Rc Dsqd0 = Xabs^2 + (Yabs - Rm)^2 Dsqd1 = (Xabs - Px)^2 + (Yabs - Py)^2 Dsqd2 = (Xabs - Rm)^2 + Yabs^2 if Dsqd0 < RcSqd trapped = true ZtoPsqd= Dsqd0 elseif Dsqd1 < RcSqd trapped = true ZtoPsqd= Dsqd1 elseif Dsqd2 < RcSqd trapped = true ZtoPsqd = Dsqd2 endif if trapped color_index = sqrt(ZtoPsqd/Rcsqd) trap_z = @fn1(w) endif endif elseif @trap_type == 4 ; *** 3-Way *** if (!trapped || !@trapping) && ((keep < @r) && (|w| > @r)) && (iter >= @skip && iter < max_iter) trapped = true trap_z = @fn1(w) color_index = (@r - keep) / @r endif keep = |w| elseif @trap_type == 5 ; *** Rings *** temp = abs(|w|-.25) if (!trapped || !@trapping) && temp < @r && (iter >= @skip && iter < max_iter) trapped = true trap_z = @fn1(w) color_index = temp endif elseif @trap_type == 6 ; *** Harlequin *** complex a = multiplier * atan(y / x) a = a * a + @c a = fn3(1 - a) / a temp = abs(|w| - |a|) if (!trapped || !@trapping) && (temp < @r && (iter >= @skip && iter < max_iter)) trapped = true trap_z = @fn1(w) color_index = temp endif elseif @trap_type == 7 ; *** Squares *** if ((Xabs < Px) && (Xabs > Py) && (Yabs < Px) && (Yabs > Py)) float awr5 = abs(Xabs - 0.5) float awi5 = abs(Yabs - 0.5) if (awr5 <= awi5) temp = awr5 else temp = awi5 endif if (!trapped || !@trapping) && (temp < @r && (iter >= @skip && iter < max_iter)) trapped = true trap_z = @fn1(w) color_index = temp endif endif endif iter = iter + 1 final: if trapped if @coloring == 0 ; Normal coloring #index = color_index + @randomness * real(#random) elseif @coloring == 1 ; Martin coloring ; Use trapped z as the starting point x = real(trap_z) * 1/@scale y = imag(trap_z) * 1/@scale ; Iterate the Martin formula float xx = 0 iter = 0 while iter < @max_iterations xx = x x = y - sin(x) y = @a - xx iter = iter + 1 endwhile trap_z = x + flip(y) #index = cabs(trap_z) + @randomness * real(#random) endif else #solid = true endif default: title = "Traps Unplugged" param trap_type caption = "Trap type" hint = "This the type of orbit trap to use." ; No kidding! enum = "3D Bubbles" "3D Stalks" "FlexBalls" "Tangent Balls" \ "3-Way" "Rings" "Harlequin" "Squares" default = 1 endparam param coloring caption = "Color mode" enum = "Normal" "Martin" endparam param r caption = "Element size" hint = "This has a different use for each mode and usually \ effects the size of the elements." default = 0.1 endparam param ring_radius caption = "Other parameter" hint = "This is the radius of the ring for FlexBalls and the angle \ multiplier for Harlequin." default = 0.12 min = 0 endparam param c caption = "Julia coordinates" hint = "Julia coordinates for the Harlequin trap mode." default = (0.15, 1.26875) endparam param skip caption = "Iterations to skip" hint = "This is the number of iterations to skip before watching \ the orbit. It's not used for Bubbles." default = 1 min = 0 endparam param no_of_iters caption = "No. of iterations" hint = "This is the number of iterations to monitor the orbit." default = 0 min = 0 endparam param a caption = "Martin parameter" hint = "This changes the shape of the swirls." default = 3.14159 endparam param max_iterations caption = "Martin iterations" hint = "This is maximum iterations for the Martin formula." default = 10 min = 1 endparam param scale caption = "Martin scale" default = 1.0 endparam param trapping caption = "First capture" default = true endparam param randomness caption = "Randomness" hint = "This adds a random texture the the coloring." default = 0.0 endparam func fn1 caption = "Martin function" default = ident() endfunc func fn2 caption = "Trap function" default = ident() endfunc func fn3 caption = "Harlequin function" default = exp() endfunc } mt-popcorn-trap { ; Mark Townsend, 10 Jun 1999 ; ; Clifford Pickover's Popcorn formula as an orbit trap. ; init: trap_z = 0 trap_p = 0 float x = 0 float y = 0 float xx = 0 int iter = 0 float dist = 0 int pop_iter = 0 int max_iter = 0 int trap_iter = 0 float distance = 0 float min_dist = 1e30 if @no_of_iters == 0 max_iter = #maxiter - @skip else max_iter = @skip + @no_of_iters endif loop: p = fn1(#z + @start) x = real(p) * 1/@scale y = imag(p) * 1/@scale ; Iterate the Popcorn formula pop_iter = 0 while pop_iter < @max_iterations xx = x x = x - @a * sin(y + tan(3 * y)) y = y - @a * sin(xx + tan(3 * xx)) pop_iter = pop_iter + 1 endwhile p = x + flip(y) f_p = @fn3(p) if @trap_mode == 0 ; Closest dist = abs(|#z| - |f_p|) if (iter >= @skip && iter < max_iter) \ && dist < min_dist min_dist = dist distance = dist trap_iter = iter trap_z = #z trap_p = f_p endif elseif @trap_mode == 1 ; Smallest trap dist = cabs(f_p) if (iter >= @skip && iter < max_iter) \ && dist < min_dist min_dist = dist distance = abs(|#z| - |f_p|) trap_iter = iter trap_z = #z trap_p = f_p endif endif iter = iter + 1 final: if @color_mode == 0 #index = distance + @randomness * real(#random) elseif @color_mode == 1 #index = 0.01 * trap_iter + @randomness * real(#random) elseif @color_mode == 2 #index = cabs(trap_z) + @randomness * real(#random) elseif @color_mode == 3 #index = abs(real(trap_z)) + @randomness * real(#random) elseif @color_mode == 4 #index = abs(imag(trap_z)) + @randomness * real(#random) elseif @color_mode == 5 float angle = atan2(trap_z) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle #index = angle + @randomness * real(#random) elseif @color_mode == 6 trap_p = @fn2(trap_p) ; Use that z as the starting point float x = real(trap_p) * 1/@mscale float y = imag(trap_p) * 1/@mscale ; Iterate the Martin formula iter = 0 while iter < @m_iterations float xx = x x = y - sin(x) y = @a2 - xx iter = iter + 1 endwhile trap_p = x + flip(y) #index = cabs(trap_p) + @randomness * real(#random) elseif @color_mode == 7 #index = cabs(trap_p) + @randomness * real(#random) elseif @color_mode == 8 #index = abs(real(trap_p)) + @randomness * real(#random) elseif @color_mode == 9 #index = abs(imag(trap_p)) + @randomness * real(#random) elseif @color_mode == 10 float angle = atan2(trap_p) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle #index = angle + @randomness * real(#random) endif default: title = "Popcorn Orbit Trap" param trap_mode caption = "Trap mode" enum = "Closest" "Smallest trap" endparam param color_mode caption = "Coloring mode" enum = "Distance" "Iteration" "Magnitude" "Real" "Imag" \ "Angle" "Martin" "Trap magnitude" "Trap real" \ "Trap imag" "Trap angle" endparam param start caption = "Starting offset" default = (0,0) endparam param skip caption = "Iterations to skip" hint = "This is the number of iterations to skip before watching \ the orbit." default = 0 min = 0 endparam param no_of_iters caption = "No. of iterations" hint = "This is the number of iterations to monitor the orbit." default = 0 min = 0 endparam param a caption = "Popcorn parameter" default = 0.05 endparam param max_iterations caption = "Popcorn iterations" hint = "This is the number of iterations for the Popcorn formula." default = 10 endparam param @scale caption = "Popcorn scale" default = 1.0 endparam param a2 caption = "Martin parameter" default = 3.14159 endparam param m_iterations caption = "Martin iterations" hint = "This is the number of iterations for the Martin formula." default = 10 endparam param @mscale caption = "Martin scale" default = 1.0 endparam param randomness caption = "Randomness" hint = "This adds a random texture the the coloring." default = 0.0 endparam func fn1 caption = "Popcorn function" default = ident() endfunc func fn2 caption = "Martin function" default = ident() endfunc func fn3 caption = "Another function" default = ident() endfunc } mt-martin-trap { ; Mark Townsend, 5 Jun 1999 ; ; Using the Martin formula as an orbit trap. ; I was inspired by the work of Paul Carlson, ; and I got some ideas from Damien M. Jones' ; Orbit Traps coloring method. ; init: trap_z = 0 trap_p = 0 float x = 0 float y = 0 float xx = 0 int iter = 0 float dist = 0 float distance = 0 int mart_iter = 0 int max_iter = 0 int trap_iter = 0 bool trapped = false float min_dist = 1e30 if @no_of_iters == 0 max_iter = #maxiter - @skip else max_iter = @skip + @no_of_iters endif loop: p = @fn1(#z + @start) x = real(p) * 1/@scale y = imag(p) * 1/@scale ; Iterate the Martin formula mart_iter = 0 while mart_iter < @max_iterations xx = x x = y - sin(x) y = @a - xx mart_iter = mart_iter + 1 endwhile p = x + flip(y) f_p = @fn2(p) dist = abs(|#z| - |f_p|) if @trap_mode == 0 if (iter >= @skip && iter < max_iter) \ && dist < min_dist min_dist = dist distance = dist trap_iter = iter trap_z = #z trap_p = f_p endif elseif @trap_mode == 1 if (iter >= @skip && iter < max_iter) \ && !trapped && dist < @width trapped = true distance = dist trap_iter = iter trap_z = #z trap_p = f_p endif elseif @trap_mode == 2 if (iter >= @skip && iter < max_iter) \ && dist < @width trapped = true distance = dist trap_iter = iter trap_z = #z trap_p = f_p endif elseif @trap_mode == 3 dist = cabs(f_p) if (iter >= @skip && iter < max_iter) \ && dist < min_dist min_dist = dist distance = abs(|#z| - |f_p|) trap_iter = iter trap_z = #z trap_p = f_p endif endif iter = iter + 1 final: if (@trap_mode == 1 || @trap_mode == 2) && !trapped #solid = true else if @color_mode == 0 #index = distance + @randomness * real(#random) elseif @color_mode == 1 #index = 0.01 * trap_iter + @randomness * real(#random) elseif @color_mode == 2 #index = cabs(trap_z) + @randomness * real(#random) elseif @color_mode == 3 #index = abs(real(trap_z)) + @randomness * real(#random) elseif @color_mode == 4 #index = abs(imag(trap_z)) + @randomness * real(#random) elseif @color_mode == 5 float angle = atan2(trap_z) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle #index = angle + @randomness * real(#random) elseif @color_mode == 6 #index = cabs(trap_p) + @randomness * real(#random) elseif @color_mode == 7 #index = abs(real(trap_p)) + @randomness * real(#random) elseif @color_mode == 8 #index = abs(imag(trap_p)) + @randomness * real(#random) elseif @color_mode == 9 float angle = atan2(trap_p) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle #index = angle + @randomness * real(#random) endif endif default: title = "Martin Orbit Trap" param trap_mode caption = "Trap mode" enum = "Closest" "First" "Last" "Smallest trap" endparam param color_mode caption = "Coloring mode" enum = "Distance" "Iteration" "Magnitude" "Real" "Imag" \ "Angle" "Trap magnitude" "Trap real" "Trap imag" \ "Trap angle" endparam param width caption = "Trap width" default = 1.0 endparam param start caption = "Starting offset" default = (0,0) endparam param a caption = "Martin parameter" default = 3.14159 endparam param skip caption = "Iterations to skip" hint = "This is the number of iterations to skip before watching \ the orbit." default = 0 min = 0 endparam param no_of_iters caption = "No. of iterations" hint = "This is the number of iterations to monitor the orbit." default = 0 min = 0 endparam param max_iterations caption = "Martin iterations" hint = "This is the number of iterations for the Martin formula." default = 10 endparam param @scale caption = "Martin scale" default = 1.0 endparam param randomness caption = "Randomness" hint = "This adds a random texture the the coloring." default = 0.0 endparam func fn1 caption = "Function" default = ident() endfunc func fn2 caption = "Another function" default = ident() endfunc } mt-vine-trap { ; Mark Townsend, 27 Jun 1999 ; ; Clifford Pickover's Popcorn formula as an orbit trap. ; init: trap_z = 0 trap_p = 0 float x = 0 float y = 0 float xx = 0 int iter = 0 float dist = 0 int vine_iter = 0 int max_iter = 0 int trap_iter = 0 float distance = 0 float min_dist = 1e30 if @no_of_iters == 0 max_iter = #maxiter - @skip else max_iter = @skip + @no_of_iters endif loop: f_p = #z + @start x = real(f_p) * 1/@scale y = imag(f_p) * 1/@scale ; Iterate the Vine formula vine_iter = 0 while vine_iter < @max_iterations xx = x vine_iter = vine_iter + 1 if @flavor == 0 x = x - @h * sin(y + sin(@a * y )) y = y + @h * sin(xx + sin(@a * xx)) elseif @flavor == 1 x = x - @h * sin(y^@b + sin(@a * y)) y = y + @h * sin(xx^@b + sin(@a * xx)) elseif @flavor == 2 x = x - @h * sin(y + sin(@a * (y + sin(@a * y)))) y = y + @h * sin(xx + sin(@a * (xx + sin(@a * xx)))) else float newx = y float newy = x int i = 0 while i < @flavor i = i + 1 newx = y + sin(@a * newx) newy = x + sin(@a * newy) endwhile x = x - @h * sin(newx) y = y + @h * sin(newy) endif endwhile f_p = x + flip(y) if @trap_mode == 0 ; Closest dist = abs(|#z| - |f_p|) if (iter >= @skip && iter < max_iter) \ && dist < min_dist min_dist = dist distance = dist trap_iter = iter trap_z = #z trap_p = f_p endif elseif @trap_mode == 1 ; Smallest trap dist = cabs(f_p) if (iter >= @skip && iter < max_iter) \ && dist < min_dist min_dist = dist distance = abs(|#z| - |f_p|) trap_iter = iter trap_z = #z trap_p = f_p endif endif iter = iter + 1 final: if @color_mode == 0 #index = distance + @randomness * real(#random) elseif @color_mode == 1 #index = 0.01 * trap_iter + @randomness * real(#random) elseif @color_mode == 2 #index = cabs(trap_z) + @randomness * real(#random) elseif @color_mode == 3 #index = abs(real(trap_z)) + @randomness * real(#random) elseif @color_mode == 4 #index = abs(imag(trap_z)) + @randomness * real(#random) elseif @color_mode == 5 float angle = atan2(trap_z) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle #index = angle + @randomness * real(#random) elseif @color_mode == 6 trap_p = @fn2(trap_p) ; Use that z as the starting point float x = real(trap_p) * 1/@mscale float y = imag(trap_p) * 1/@mscale ; Iterate the Martin formula iter = 0 while iter < @m_iterations float xx = x x = y - sin(x) y = @a2 - xx iter = iter + 1 endwhile trap_p = x + flip(y) #index = cabs(trap_p) + @randomness * real(#random) elseif @color_mode == 7 #index = cabs(trap_p) + @randomness * real(#random) elseif @color_mode == 8 #index = abs(real(trap_p)) + @randomness * real(#random) elseif @color_mode == 9 #index = abs(imag(trap_p)) + @randomness * real(#random) elseif @color_mode == 10 float a = atan2(trap_p) if a < 0 a = a + 2 * #pi endif a = 1 / (2 * #pi) * a #index = a + @randomness * real(#random) elseif @color_mode == 11 float a = atan2(trap_z - trap_p) if a < 0 a = a + 2 * #pi endif a = 1 / (2 * #pi) * a #index = a + @randomness * real(#random) endif default: title = "Vine Orbit Trap" param trap_mode caption = "Trap mode" enum = "Closest" "Smallest trap" endparam param color_mode caption = "Coloring mode" enum = "Distance" "Iteration" "Magnitude" "Real" "Imag" \ "Angle" "Martin" "Trap magnitude" "Trap real" \ "Trap imag" "Trap angle" "Angle to trap" endparam param start caption = "Starting offset" default = (0,0) endparam param skip caption = "Iterations to skip" hint = "This is the number of iterations to skip before watching \ the orbit." default = 0 min = 0 endparam param no_of_iters caption = "No. of iterations" hint = "This is the number of iterations to monitor the orbit." default = 0 min = 0 endparam param flavor caption = "Vine flavor" default = 0 min = 0 endparam param a caption = "Vine alpha" default = 2.7 endparam param b caption = "Vine beta" default = 2.0 endparam param h caption = "Vine step size" default = 0.1 endparam param max_iterations caption = "Vine iterations" hint = "This is the number of iterations for the Vine formula." default = 10 endparam param @scale caption = "Vine scale" default = 1.0 endparam param a2 caption = "Martin parameter" default = 3.14159 endparam param m_iterations caption = "Martin iterations" hint = "This is the number of iterations for the Martin formula." default = 10 endparam param @mscale caption = "Martin scale" default = 1.0 endparam param randomness caption = "Randomness" hint = "This adds a random texture the the coloring." default = 0.0 endparam func fn2 caption = "Martin function" default = ident() endfunc } mt-curves { ; Mark Townsend, 4 July 1999 ; ; Orbit traps based on various curves. ; init: trap_z = 0 trap_p = 0 int iter = 0 float distance = 0 float o_distance = 0 int trap_iter = 0 bool trapped = false float min_dist = 1e30 float radius = 0 float theta = 0 if @no_of_iters == 0 int max_iter = #maxiter - @skip else int max_iter = @skip + @no_of_iters endif loop: iter = iter + 1 theta = atan2(#z) if @curve == 0 ; Cardioid radius = @a * (1 - cos(theta)) elseif @curve == 1 ; Rose radius = @a * cos(@n * theta) elseif @curve == 2 ; Rhodonea radius = @a * sin(@n * theta) elseif @curve == 3 ; Folium radius = -@n * cos(theta) + 4 * @a * cos(theta) * sin(theta)^2 elseif @curve == 4 ; Cayley's Sextic radius = 4 * @a * cos(theta / 3)^3 elseif @curve == 5 ; Butterfly radius = @a * exp(cos(theta))-2*cos(@n*theta)+ (sin(theta/12))^5 endif trap_point = radius * sin(theta) + flip(radius * cos(theta)) float radius_dist = abs(cabs(#z) - radius) float point_dist = cabs(#z - trap_point) if @trap_mode == 0 ; Closest if (iter >= @skip && iter < max_iter) \ && radius_dist < min_dist min_dist = radius_dist distance = radius_dist o_distance = point_dist trap_iter = iter trap_z = #z trap_p = trap_point endif elseif @trap_mode == 1 ; First near if (iter >= @skip && iter < max_iter) \ && !trapped && radius_dist < @width trapped = true distance = radius_dist o_distance = point_dist trap_iter = iter trap_z = #z trap_p = trap_point endif elseif @trap_mode == 2 ; Last near if (iter >= @skip && iter < max_iter) \ && radius_dist < @width trapped = true distance = radius_dist o_distance = point_dist trap_iter = iter trap_z = #z trap_p = trap_point endif elseif @trap_mode == 3 ; First within if (iter >= @skip && iter < max_iter) \ && !trapped && cabs(#z) < radius trapped = true distance = radius_dist o_distance = point_dist trap_iter = iter trap_z = #z trap_p = trap_point endif elseif @trap_mode == 4 ; Last within if (iter >= @skip && iter < max_iter) \ && cabs(#z) < radius trapped = true distance = radius_dist o_distance = point_dist trap_iter = iter trap_z = #z trap_p = trap_point endif elseif @trap_mode == 5 ; Closest point if (iter >= @skip && iter < max_iter) \ && point_dist < min_dist min_dist = point_dist distance = point_dist o_distance = radius_dist trap_iter = iter trap_z = #z trap_p = trap_point endif elseif @trap_mode == 6 ; First point if (iter >= @skip && iter < max_iter) \ && !trapped && point_dist < @width trapped = true distance = point_dist o_distance = radius_dist trap_iter = iter trap_z = #z trap_p = trap_point endif elseif @trap_mode == 7 ; Last point if (iter >= @skip && iter < max_iter) \ && point_dist < @width trapped = true distance = point_dist o_distance = radius_dist trap_iter = iter trap_z = #z trap_p = trap_point endif endif final: if (@trap_mode == 1 || @trap_mode == 2 || @trap_mode == 3 || \ @trap_mode == 4 || @trap_mode == 6 || @trap_mode == 7) && \ !trapped && @solid #solid = true else if @color_mode == 0 #index = distance + @randomness * real(#random) elseif @color_mode == 1 #index = o_distance + @randomness * real(#random) elseif @color_mode == 2 #index = 0.01 * trap_iter + @randomness * real(#random) elseif @color_mode == 3 #index = cabs(trap_z) + @randomness * real(#random) elseif @color_mode == 4 #index = abs(real(trap_z)) + @randomness * real(#random) elseif @color_mode == 5 #index = abs(imag(trap_z)) + @randomness * real(#random) elseif @color_mode == 6 float angle = atan2(trap_z) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle #index = angle + @randomness * real(#random) elseif @color_mode == 7 #index = cabs(trap_p) + @randomness * real(#random) elseif @color_mode == 8 float angle = atan2(trap_z - trap_p) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle #index = angle + @randomness * real(#random) endif endif default: title = "Curves" param curve caption = "Curve" enum = "Cardioid" "Rose" "Rhodonea" "Folium" "Sextic" "Butterfly" endparam param trap_mode caption = "Mode" enum = "Closest" "First near" "Last near" "First within" "Last within" \ "Closest point" "First point" "Last point" endparam param color_mode caption = "Coloring" enum = "Distance" "Distance #2" "Iteration" "Magnitude" "Real" "Imag" \ "Angle" "Trap magnitude" "Angle to trap" endparam param a caption = "Curve radius" default = 1.0 endparam param n caption = "Parameter" default = 4.0 hint = "This is not used for Cardioid or Sextic" endparam param width caption = "Width" default = 0.1 hint = "This controls the width of the elements. It's not \ used with all of the trap modes." endparam param skip caption = "Iterations to skip" hint = "This is the number of iterations to skip before watching \ the orbit." default = 0 min = 0 endparam param no_of_iters caption = "No. of iterations" hint = "This is the number of iterations to monitor the orbit." default = 0 min = 0 endparam param solid caption = "Solid background" default = true hint = "If this is checked orbits that aren't trapped \ are mapped solid. It has no effect in the 'Closest' \ trap modes." endparam param randomness caption = "Randomness" hint = "This adds a random texture the the coloring." default = 0.0 endparam } mt-beads { ; Mark Townsend, 13 July 1999 init: trapped_z = 0 int iter = 0 int trapped_iter = 0 float distance = 0 bool trapped = false if @no_of_iters == 0 int max_iter = #maxiter - @skip else int max_iter = @skip + @no_of_iters endif loop: if !trapped || !@trapping && iter >= @skip && iter < max_iter if (abs(real(#z)) < abs(cos(imag(#z)))) trapped = true trapped_iter = iter trapped_z = #z distance = real(abs((abs(real(#z)) - abs(cos(imag(#z)))))) elseif (abs(imag(#z)) < abs(sin(real(#z)))) trapped = true trapped_iter = iter trapped_z = #z distance = real(abs((abs(imag(#z)) - abs(sin(real(#z)))))) endif endif iter = iter + 1 final: if trapped if @color == 0 #index = distance elseif @color == 1 #index = cabs(trapped_z) elseif @color == 2 #index = abs(real(trapped_z)) elseif @color == 3 #index = abs(imag(trapped_z)) elseif @color == 4 float angle = atan2(trapped_z) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle #index = angle elseif @color == 5 #index = 0.01 * trapped_iter endif else #solid = true endif default: title = "Beads" param @color caption = "Color mode" enum = "Distance" "Magnitude" "Real" "Imag" "Angle" "Iteration" endparam param skip caption = "Iterations to skip" default = 0 endparam param no_of_iters caption = "No. of iterations" hint = "This is the number of iterations to monitor the orbit." default = 0 min = 0 endparam param trapping caption = "Bailout on first" default = false endparam } mt-beads&squiggles { ; Mark Townsend, 13 July 1999 init: float x = 0 float y = 0 float distance = 0 bool trapped = false trapped_z = 0 loop: x = abs((real(#z)) - cos(@a * imag(#z))) y = abs(imag(#z)) - abs(@a *sin(real(#z))) if x < @r || y < @r trapped = true if x > y distance = x trapped_z = #z else distance = y trapped_z = #z endif endif final: if trapped if @color == 0 #index = distance elseif @color == 1 #index = cabs(trapped_z) elseif @color == 2 #index = abs(real(trapped_z)) elseif @color == 3 #index = abs(imag(trapped_z)) elseif @color == 4 float angle = atan2(trapped_z) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle #index = angle endif else #solid = true endif default: title = "Beads And Squiggles" param @color caption = "Coloring" enum = "Distance" "Magnitude" "Real" "Imag" "Angle" endparam param r caption = "Width" default = 1.0 endparam param a caption = "Multiplier" default = 1.0 endparam } mt-minfunctions { ; Mark Townsend, 19 Jul 1999 init: trap_z = 0 trap_w = 0 float a = 0 float x = 0 float y = 0 int iter = 0 float dist = 0 int trap_iter = 0 bool trapped = false float min_dist = 1e20 loop: x = real(@fn1(#z)) y = imag(@fn2(#z)) w = x + flip(y) if @ref == 0 dist = cabs(w - #z) elseif @ref == 1 dist = cabs(w) elseif @ref == 2 dist = cabs(w - #pixel) endif if @mode == 0 ; Closest if dist < min_dist && iter >= @skip trapped = true min_dist = dist trap_w = w trap_z = #z trap_iter = iter endif elseif @mode == 1 ; First if !trapped && dist < @r && iter >= @skip trapped = true min_dist = dist trap_w = w trap_z = #z trap_iter = iter endif elseif @mode == 2 ; Last if dist < @r && iter >= @skip trapped = true min_dist = dist trap_w = w trap_z = #z trap_iter = iter endif endif iter = iter + 1 final: if trapped if @coloring == 0 ; Distance #index = min_dist elseif @coloring == 1 ; Magnitude #index = cabs(trap_z) elseif @coloring == 2 ; Iteration #index = 0.01 * trap_iter elseif @coloring == 3 ; Real #index = real(trap_z) elseif @coloring == 4 ; Imag #index = imag(trap_z) elseif @coloring == 5 if @angle == 0 ; Angle of orbit to trap a = atan2(trap_w - trap_z) elseif @angle == 1 ; Angle of orbit to origin a = atan2(trap_z) elseif @angle == 2 ; Angle of orbit to pixel a = atan2(trap_z - #pixel) elseif @angle == 3 ; Angle of trap to origin a = atan2(trap_w) elseif @angle == 4 ; Angle of trap to pixel a = atan2(trap_w - #pixel) endif if a < 0 a = a + 2 * #pi endif #index = 1 / (2 * #pi) * a endif else #solid = true endif default: title = "Minimum Functions" param mode caption = "Trap mode" enum = "Closest" "First" "Last" endparam param ref caption = "Trap reference" enum = "Orbit" "Origin" "Pixel" hint = "This controls what the trap position is \ measured against." endparam param coloring caption = "Trap coloring" enum = "Distance" "Magnitude" "Iteration" "Real" "Imag" "Angle" endparam param angle caption = "Angle mode" enum = "Orbit to trap" "Orbit to origin" "Orbit to pixel" \ "Trap to origin" "Trap to pixel" hint = "This determines which angle is calculated if you \ are using the 'Angle' coloring mode." endparam param r caption = "Element size" default = 0.1 hint = "This controls the size of the elements in \ the 'First' and 'Last' trap modes." endparam param skip caption = "Iterations to skip" default = 0 endparam func fn1 caption = "First function" default = ident() endfunc func fn2 caption = "Second function" default = cos() endfunc } mt-portions { ; Mark Townsend, 18 Jul 1999 init: int iter = 0 trapped_z = 0 float dist = 0 float distance = 0 bool trapped = false int trapped_iter = 0 float distance = 1e20 loop: dist = abs(real(@fn1(real(#z))) - real(@fn2(imag(#z)))) if @mode == 0 if iter >=@skip && dist < distance ; Closest distance = dist trapped = true trapped_z = #z trapped_iter = iter endif elseif @mode == 1 if !trapped && iter >= @skip && dist < @r ; First distance = dist trapped = true trapped_z = #z trapped_iter = iter endif elseif @mode == 2 if iter >= @skip && dist < @r ; Last distance = dist trapped = true trapped_z = #z trapped_iter = iter endif endif iter = iter + 1 final: if trapped if @coloring == 0 #index = distance elseif @coloring == 1 #index = cabs(trapped_z) elseif @coloring == 2 #index = 0.01 * trapped_iter elseif @coloring == 3 #index = real(trapped_z) elseif @coloring == 4 #index = imag(trapped_z) endif else #solid = true endif default: title = "Portions" param mode caption = "Trap mode" enum = "Closest" "First" "Last" endparam param coloring caption = "Coloring" enum = "Distance" "Magnitude" "Iteration" "Real" "Imag" endparam param r caption = "Element size" default = 0.1 hint = "This controls the width of the stalks in the \ 'First' and 'Last' trap modes." endparam param skip caption = "Iterations to skip" default = 0 endparam func fn1 caption = "Real function" default = ident() endfunc func fn2 caption = "Imaginary function" default = cos() endfunc } mt-point-axis { ; Mark Townsend, 18 Jul 1999 init: a_z = 0 b_z = 0 int iter = 0 int a_iter = 0 int b_iter = 0 float min_a = 1e20 float min_b = 1e20 loop: if @axis == 0 float a = real(abs(@fn1(imag(#z)))) else float a = real(abs(@fn1(real(#z)))) endif float b = cabs(@fn2(#z) - @p1) if a < min_a min_a = a a_z = #z a_iter = iter endif if b < min_b min_b = b b_z = #z b_iter = iter endif iter = iter + 1 final: if @coloring == 0 a = min_a b = min_b elseif @coloring == 1 a = cabs(a_z) b = cabs(b_z) elseif @coloring == 2 a = 0.01 * a_iter b = 0.01 * b_iter elseif @coloring == 3 a = real(a_z) b = real(b_z) elseif @coloring == 4 a = imag(a_z) b = imag(b_z) endif if @operation == 0 #index = a + b elseif @operation == 1 #index = abs(a - b) elseif @operation == 2 #index = a * b elseif @operation == 3 #index = a / b endif default: title = "Point and Axis" param coloring caption = "Coloring" enum = "Distance" "Magnitude" "Iteration" "Real" "Imag" endparam param operation caption = "Operation" enum = "Addition" "Subtraction" "Multiplication" "Division" endparam param p1 caption = "Point" default = (1,0) endparam param axis caption = "Axis" enum = "Real" "Imaginary" endparam func fn1 caption = "Axis function" default = ident() endfunc func fn2 caption = "Point function" default = ident() endfunc } mt-two-points { ; Mark Townsend, 18 Jul 1999 init: float mina = 1e20 float minb = 1e20 az = 0 bz = 0 int aiter = 0 int biter = 0 int iter = 0 loop: float a = cabs(@fn1(#z) - @p1) float b = cabs(@fn2(#z) - @p2) if a < mina mina = a az = #z aiter = iter endif if b < minb minb = b bz = #z biter = iter endif iter = iter + 1 final: if @coloring == 0 a = mina b = minb elseif @coloring == 1 a = cabs(az) b = cabs(bz) elseif @coloring == 2 a = 0.01 * aiter b = 0.01 * biter endif if @operation == 0 #index = a + b elseif @operation == 1 #index = abs(a - b) elseif @operation == 2 #index = a * b elseif @operation == 3 #index = a / b endif default: title = "Two Points" param coloring caption = "Coloring" enum = "Distance" "Magnitude" "Iteration" endparam param operation caption = "Operation" enum = "Addition" "Subtraction" "Multiplication" "Division" endparam param p1 caption = "First Point" default = (1,0) endparam param p2 caption = "Second Point" default = (0,0) endparam func fn1 caption = "First function" default = ident() endfunc func fn2 caption = "Second function" default = ident() endfunc } mt-trifunctional { ; Mark Townsend, 21 Aug 1999 ; ; Last update on 26 April 2000 ; init: int ra = 1322939 int rc = 7336919 int rm = 36282757 mod_z = 0 trap_z = 0 trap_p = 0 int iter = 0 float dist = 0 int trap_iter = 0 bool trapped = false float min_dist = 1e20 loop: mod_z = @fn3(@fn1(real(#z)) + flip(@fn2(imag(#z)))) if @flavor == 0 dist = cabs(mod_z) else dist = |#z - mod_z| endif if @mode == 0 || @mode == 3 if (dist < min_dist) && iter > (@skip - 1) trapped = true min_dist = dist trap_z = #z trap_p = mod_z trap_iter = iter endif elseif @mode == 1 if (dist < @r) && !trapped && iter > (@skip - 1) trapped = true min_dist = dist trap_z = #z trap_p = mod_z trap_iter = iter endif elseif @mode == 2 if dist < @r trapped = true min_dist = dist trap_z = #z trap_p = mod_z trap_iter = iter endif endif iter = iter + 1 final: if @mode == 3 if min_dist > @r trapped = false endif endif if trapped if @coloring == 0 #index = min_dist elseif @coloring == 1 #index = cabs(trap_z) elseif @coloring == 2 #index = 0.01 * trap_iter elseif @coloring == 3 #index = real(trap_z) elseif @coloring == 4 #index = imag(trap_z) elseif @coloring == 5 float a = atan2(trap_z) if a < 0 a = a + 2 * #pi endif a = 1 / (2 * #pi) * a #index = a elseif @coloring == 6 ; Modulated iteration #index = ((trap_iter) % @iter_mod) / @iter_mod elseif @coloring == 7 ; Random iteration #index = (((ra * (trap_iter + @rnd) + rc) % rm) % @iter_mod) / @iter_mod elseif @coloring == 8 ; Real #2 - corrected by using absolute value #index = abs(real(trap_z)) elseif @coloring == 9 ; Imaginary - ditto #index = abs(imag(trap_z)) elseif @coloring == 10 ; Angle to trap float b = atan2(trap_z - trap_p) if b < 0 b = b + 2 * #pi endif b = 1 / (2 * #pi) * b #index = b endif else #solid = true endif default: title = "Trifunctional" param mode caption = "Trap Mode" enum = "Closest" "First" "Last" "Masked" default = 0 endparam param flavor caption = "Trap Flavor" enum = "1" "2" endparam param coloring caption = "Coloring Mode" enum = "Distance" "Magnitude" "Iteration" "Real" "Imag" "Angle" \ "Modulated Iter" "Random Iter" "Real #2" "Imag #2" \ "Angle to Trap" default = 0 endparam param iter_mod caption = "No. of Colors" default = 8 hint = "The number of different colors used for the Modulated Iter \ and Random Iter coloring modes." endparam param r caption = "Element Size" hint = "This is the width of the elements in the First and Last \ Trap Modes, and the Threshold amount in the Masked mode." default = 0.1 endparam param skip caption = "Skip Iterations" hint = "This is the number of iterations to skip." default = 0 min = 0 endparam param rnd caption = "Random Seed" default = 0 hint = "This is the random seed for the Random Iter coloring mode." endparam func fn1 caption = "Real function" default = sin() endfunc func fn2 caption = "Imag function" default = log() endfunc func fn3 caption = "Overall function" default = sqrt() endfunc } mt-gnarly-traps { ; Mark Townsend, 27 Aug 1999 init: w = 0 trap_z = 0 trap_frm_z = 0 int iter = 0 int frm_iter = 0 int trap_frm_iter = 0 int trap_iter = 0 float x = 0 float y = 0 float xx = 0 float average = 0 float frm_dist = 0 float min_w = 1e20 float min_dist = 1e20 loop: w = @fn1(#z + @offset) x = real(w) * 1/@scale y = imag(w) * 1/@scale ; Iterate trap formula frm_iter = 0 average = 0 min_w = 1e20 while frm_iter < @max_iter xx = x if @formula == 0 ; Martin x = y - sin(x) y = @a - xx elseif @formula == 1 ; Popcorn x = x - @h * sin(y + tan(@a * y)) y = y - @h * sin(xx + tan(@a * xx)) elseif @formula == 2 ; Vine if @flavor == 0 x = x - @h * sin(y + sin(@a * y )) y = y + @h * sin(xx + sin(@a * xx)) elseif @flavor == 1 x = x - @h * sin(y^@b + sin(@a * y)) y = y + @h * sin(xx^@b + sin(@a * xx)) elseif @flavor == 2 x = x - @h * sin(y + sin(@a * (y + sin(@a * y)))) y = y + @h * sin(xx + sin(@a * (xx + sin(@a * xx)))) else float newx = y float newy = x int i = 0 while i < @flavor i = i + 1 newx = y + sin(@a * newx) newy = x + sin(@a * newy) endwhile x = x - @h * sin(newx) y = y + @h * sin(newy) endif elseif @formula == 3 ; Gnarl x = x - @h * real(@gn1(y + @gn2(@a * (y + @gn3(@b * y))))) y = y + @h * real(@gn1(xx + @gn2(@a * (xx + @gn3(@b * xx))))) endif w = @fn2(x + flip(y)) if @trap_mode == 0 || @trap_mode == 2 ; Closest & Average ; Choose the variable that we want to watch... if @frm_mode == 0 frm_dist = cabs(w) elseif @frm_mode == 1 frm_dist = cabs(w - #z) elseif @frm_mode == 2 frm_dist = cabs(w - #pixel) elseif @frm_mode == 3 frm_dist = cabs(w - @offset) endif endif if @trap_mode == 0 ; Closest if frm_dist < min_w min_w = frm_dist trap_frm_z = w trap_frm_iter = frm_iter endif elseif @trap_mode == 2 ; Average average = average + frm_dist endif frm_iter = frm_iter + 1 endwhile ; end of formula loop if @trap_mode == 3 ; Martin x = real(w) * 1/@mscale y = imag(w) * 1/@mscale ; Iterate the Martin formula i = 0 while i < @m_iterations xx = x x = y - sin(x) y = @m - xx i = i + 1 endwhile w = x + flip(y) endif if @trap_mode == 1 || @trap_mode == 3 ; Final & Martin ; Choose the variable that we want to watch... if @frm_mode == 0 min_w = cabs(w) elseif @frm_mode == 1 min_w = cabs(w - #z) elseif @frm_mode == 2 min_w = cabs(w - #pixel) elseif @frm_mode == 3 min_w = cabs(w - @offset) endif elseif @trap_mode == 2 ; Average min_w = average / @max_iter endif ; Look for the smallest value if min_w < min_dist min_dist = min_w if @trap_mode == 0 trap_z = trap_frm_z trap_iter = trap_frm_iter else trap_z = #z trap_iter = iter endif endif iter = iter + 1 final: if @coloring == 0 ; Distance #index = min_dist elseif @coloring == 1 ; Iteration #index = 0.01 * trap_iter elseif @coloring == 2 ; Magnitude #index = cabs(trap_z) elseif @coloring == 3 ; Real #index = real(trap_z) elseif @coloring == 4 ; Imag #index = imag(trap_z) elseif @coloring == 5 ; Angle float a = atan2(trap_z) if a < 0 a = a + 2 * #pi endif a = 1 / (2 * #pi) * a #index = a elseif @coloring == 6 ; Pixel distance #index = cabs(trap_z - #pixel) elseif @coloring == 7 ; Offset distance #index = cabs(trap_z - @offset) elseif @coloring == 8 ; Angle to pixel float a = atan2(trap_z - #pixel) if a < 0 a = a + 2 * #pi endif a = 1 / (2 * #pi) * a #index = a elseif @coloring == 9 ; Angle to offset float a = atan2(trap_z - @offset) if a < 0 a = a + 2 * #pi endif a = 1 / (2 * #pi) * a #index = a endif default: title = "Gnarly Orbit Traps" param formula caption = "Formula" enum = "Martin" "Popcorn" "Vine" "Gnarl" default = 1 endparam param @trap_mode caption = "Mode" enum = "Closest" "Final" "Average" "Martin" default = 1 endparam param @frm_mode caption = "Variable" enum = "Magnitude" "Distance" "Pixel distance" "Offset distance" endparam param coloring caption = "Coloring" enum = "Distance" "Iteration" "Magnitude" "Real" \ "Imag" "Angle" "Pixel distamce" "Offset distance" \ "Angle to pixel" "Angle to offset" endparam param offset caption = "Offset" hint = "This is added to the value of z before the trap \ formula is iterated." endparam param scale caption = "Scale" hint = "This affects the size of the shapes." default = 0.5 min = 1e-20 endparam param a caption = "Alpha" hint = "This parameter is used for all of the formulas." default = 3.0 endparam param b caption = "Beta" hint = "This parameter is used only for Vine flavor 1 and Gnarl." default = 2.0 endparam param h caption = "Step size" hint = "This parameter usually affects the 'harshness' of the \ shapes." default = 0.05 min = 1e-20 endparam param flavor caption = "Vine flavor" hint = "This is the 'flavor' for the Vine formula." default = 2 min = 0 endparam param max_iter caption = "Iterations" hint = "This is the number of times to iterate the trap formula." default = 10 min = 1 endparam param m caption = "Martin parameter" hint = "This is the parameter for the Martin moade." default = 3.14159 endparam param m_iterations caption = "Martin iterations" hint = "This is the number of iterations for the \ Martin mode." default = 10 min = 1 endparam param mscale caption = "Martin scale" hint = "This is the scale for the Martin mode." default = 0.1 min = 1e-20 endparam func fn1 caption = "First function" hint = "This function changes the overall shape of \ the trap." default = ident() endfunc func fn2 caption = "Second function" hint = "This function changes the overall shape of \ the trap." default = ident() endfunc func gn1 caption = "Gnarl function #1" hint = "This is the first function for the Gnarl \ formula only." default = sin() endfunc func gn2 caption = "Gnarl function #2" hint = "This is the second function for the Gnarl \ formula only." default = tan() endfunc func gn3 caption = "Gnarl function #3" hint = "This is the third function for the Gnarl \ formula only." default = cos() endfunc } mt-soft-gnarly { ; Mark Townsend, 15 Oct 1999 ; ; Last update - 5 Nov 1999 ; init: zz = 0 float post_scale = 0 if @link post_scale = @scale else post_scale = @p_scale endif if @flav < 2 p = @pn1(#pixel + @offset) float xx = 0 float x = real(p) / @scale float y = imag(p) / @scale if @formula != 4 int i = 0 while (i < @iters) xx = x if @formula == 0 ; Martin x = y - sin(x) y = @a - xx elseif @formula == 1 ; Popcorn x = x - @h * sin(y + tan(@a * y)) y = y - @h * sin(xx + tan(@a * xx)) elseif @formula == 2 ; Vine if @flavor == 0 x = x - @h * sin(y + sin(@a * y )) y = y + @h * sin(xx + sin(@a * xx)) elseif @flavor == 1 x = x - @h * sin(y^@b + sin(@a * y)) y = y + @h * sin(xx^@b + sin(@a * xx)) elseif @flavor == 2 x = x - @h * sin(y + sin(@a * (y + sin(@a * y)))) y = y + @h * sin(xx + sin(@a * (xx + sin(@a * xx)))) else float newx = y float newy = x int j = 0 while j < @flavor j = j + 1 newx = y + sin(@a * newx) newy = x + sin(@a * newy) endwhile x = x - @h * sin(newx) y = y + @h * sin(newy) endif elseif @formula == 3 ; Gnarl x = x - @h * real(@gn1(y + @gn2(@a * (y + @gn3(@b * y))))) y = y + @h * real(@gn1(xx + @gn2(@a * (xx + @gn3(@b * xx))))) endif i = i + 1 endwhile endif x = x * post_scale y = y * post_scale p = x + flip(y) else p = @offset endif z1 = 0 z2 = 0 z3 = 0 z4 = 0 z5 = 0 z6 = 0 z7 = 0 z8 = 0 float dist0 = 0 float dist1 = 0 float dist2 = 0 float dist3 = 0 float dist4 = 0 float dist5 = 0 float dist6 = 0 float dist7 = 0 float dist8 = 0 float min_dist0 = 1e20 float min_dist1 = 1e20 float min_dist2 = 1e20 float min_dist3 = 1e20 float min_dist4 = 1e20 float min_dist5 = 1e20 float min_dist6 = 1e20 float min_dist7 = 1e20 float min_dist8 = 1e20 loop: if @flav == 0 || @flav == 2 zz = @tn3(@tn1(real(#z)) + flip(@tn2(imag(#z)))) else zz = @tn3(real(@tn1(#z)) + flip(imag(@tn2(#z)))) endif z1 = zz + -@spread + flip(-@spread) z2 = zz + flip(-@spread) z3 = zz + @spread + flip(-@spread) z4 = zz + -@spread z5 = zz + @spread z6 = zz + -@spread + flip(@spread) z7 = zz + flip(@spread) z8 = zz + @spread + flip(@spread) dist0 = cabs(zz - p) dist1 = cabs(z1 - p) dist2 = cabs(z2 - p) dist3 = cabs(z3 - p) dist4 = cabs(z4 - p) dist5 = cabs(z5 - p) dist6 = cabs(z6 - p) dist7 = cabs(z7 - p) dist8 = cabs(z8 - p) if @center if dist0 < min_dist0 min_dist0 = dist0 endif endif if dist1 < min_dist1 min_dist1 = dist1 endif if dist2 < min_dist2 min_dist2 = dist2 endif if dist3 < min_dist3 min_dist3 = dist3 endif if dist4 < min_dist4 min_dist4 = dist4 endif if dist5 < min_dist5 min_dist5 = dist5 endif if dist6 < min_dist6 min_dist6 = dist6 endif if dist7 < min_dist7 min_dist7 = dist7 endif if dist8 < min_dist8 min_dist8 = dist8 endif final: int points = @points float sum = 0 if @points == 1 sum = min_dist1 elseif @points == 2 sum = min_dist1 + min_dist2 elseif @points == 3 sum = min_dist1 + min_dist2 + min_dist3 elseif @points == 4 sum = min_dist1 + min_dist2 + min_dist3 + min_dist4 elseif @points == 5 sum = min_dist1 + min_dist2 + min_dist3 + min_dist4 \ + min_dist5 elseif @points == 6 sum = min_dist1 + min_dist2 + min_dist3 + min_dist4 \ + min_dist5 + min_dist6 elseif @points == 7 sum = min_dist1 + min_dist2 + min_dist3 + min_dist4 \ + min_dist5 + min_dist6 + min_dist7 elseif @points == 8 sum = min_dist1 + min_dist2 + min_dist3 + min_dist4 \ + min_dist5 + min_dist6 + min_dist7 + min_dist8 endif if @center points = points + 1 sum = sum + min_dist0 endif #index = sum / points default: title = "Soft Gnarly" param formula caption = "Formula" enum = "Martin" "Popcorn" "Vine" "Gnarl" "None" default = 1 endparam param flav caption = "Flavor" enum = "0" "1" "2" "3" endparam param spread caption = "Spread" default = 1.0 endparam param points caption = "No. of test points" default = 8 min = 1 max = 8 endparam param center caption = "Include #z" default = false endparam param a caption = "Alpha" default = 3.0 endparam param b caption = "Beta" default = 2.0 endparam param iters caption = "Iterations" default = 20 endparam param flavor caption = "Vine flavor" default = 2 min = 0 endparam param h caption = "Step size" default = 0.01 endparam param offset caption = "Offset" default = (0,0) endparam param scale caption = "Scale" default = 1.0 endparam param p_scale caption = "Postscale" default = 1.0 endparam param link caption = "Link scales" default = false endparam func pn1 caption = "Trap function" default = ident() endfunc func tn1 caption = "Real function" default = ident() endfunc func tn2 caption = "Imag function" default = ident() endfunc func tn3 caption = "Overall function" default = ident() endfunc func gn1 caption = "Gnarl function #1" hint = "This is the first function for the Gnarl \ formula only." default = sin() endfunc func gn2 caption = "Gnarl function #2" hint = "This is the second function for the Gnarl \ formula only." default = tan() endfunc func gn3 caption = "Gnarl function #3" hint = "This is the third function for the Gnarl \ formula only." default = cos() endfunc } mt-sierpinski-trap { ; Mark Townsend, 15 Oct 1999 ; ; iteration trap inserted by red williams 17 November 1999 ; init: trap_z = 0 int iter = 0 int frm_iter = 0 int trap_iter = 0 float dist = 0 float min_dist = 1e30 int res = 0 int lowtrap = abs(round(real(@itrap) * #maxiter)) int hightrap = abs(round(imag(@itrap) * #maxiter)) if lowtrap > hightrap res = lowtrap lowtrap = hightrap hightrap = res endif loop: w = (#z + @start) / (@scale + flip(@scale)) ; Iterate the Sierpinski formula frm_iter = 0 while frm_iter < @max_iterations if (imag(w) > 0.5) w = @a * real(w) + flip(@a * imag(w) -1) elseif (real(w) > 0.5) w = @a * real(w) -1 + flip(@a * imag(w)) else w = @a * real(w) + flip(@a * imag(w)) endif frm_iter = frm_iter + 1 endwhile dist = cabs(@fn1(w)) if dist < min_dist min_dist = dist trap_z = #z trap_iter = iter endif iter = iter + 1 final: if @coloring == 0 #index = 0.001 * min_dist elseif @coloring == 1 #index = cabs(trap_z) elseif @coloring == 2 #index = 0.01 * trap_iter elseif @coloring == 3 #index = abs(real(trap_z)) elseif @coloring == 4 #index = abs(imag(trap_z)) elseif @coloring == 5 float a = atan2(trap_z) if a < 0 a = a + 2 * #pi endif a = 1 / (2 * #pi) * a #index = a endif if !((#numiter >= lowtrap) && (#numiter <= hightrap)) if @opt == 1 #solid = true endif elseif (#numiter >= lowtrap) && (#numiter <= hightrap) if @opt == 0 #solid = true endif endif default: title = "Sierpinski Trap" param coloring caption = "Coloring" enum = "Distance" "Magnitude" "Iteration" "Real" "Imag" "Angle" endparam param a caption = "Parameter" default = 2.0 endparam param max_iterations caption = "Iterations" default = 10 endparam param start caption = "Offset" default = (0,0) endparam param @scale caption = "Scale" default = 1.0 endparam param itrap caption = "Iter. trap limits" hint = "Between 0.0 and 1.0 (fraction of Maximum Iterations).\ Real part is lower boundary of trap and Imaginary \ part, the upper boundary. Pixels between these limits \ are colored according to Solid/Normal Choice." default = (0.0,1.0) endparam param opt caption = "Iter. trap mode" enum = "Solid" "Normal" default = 1 endparam func fn1 caption = "Function" default = ident() endfunc } mt-magnitude { ; Mark Townsend, 27 Jun 1999 ; Last modified 21 Nov 1999 init: w = 0 float min_z = 1e20 float dist = 0 float average = 0 loop: if @mode == 1 || @mode == 5 dist = cabs(#z) if dist < min_z w = #z min_z = dist endif elseif @mode == 6 average = average + cabs(#z) elseif @mode == 7 average = average + cabs(#z - #pixel) endif final: if @mode == 0 #index = cabs(#z) elseif @mode == 1 #index = cabs(w) elseif @mode == 2 #index = cabs(#z - #pixel) elseif @mode == 3 float angle = atan2(#z - #pixel) if angle < 0 angle = angle + 2 * #pi endif #index = 1 / (2 * #pi) * angle elseif @mode == 4 #index = abs(cabs(#z) - cabs(#pixel)) elseif @mode == 5 #index = abs(cabs(w) - cabs(#pixel)) elseif @mode == 6 #index = average / #numiter elseif @mode == 7 #index = average / #numiter endif default: title = "Magnitude" param mode caption = "Mode" enum = "Final magnitude" "Smallest magnitude" "Pixel distance" \ "Angle #1" "Final - pixel" "Smallest - pixel" \ "Average magnitude" "Average distance" endparam } mt-advanced-gnarl { ; Mark Townsend, December 1999 final: p = 0 bool test = true float m = 590872612825179551336102196593.0 float a = 1322939 float c = 7336919 float ar1 = trunc(real(@a_seed)) float ar2 = trunc(imag(@a_seed)) float br1 = trunc(real(@b_seed)) float br2 = trunc(imag(@b_seed)) float gr1 = trunc(real(@g_seed)) float gr2 = trunc(imag(@g_seed)) float seqr = @seqseed float acoef1 = real(@a1) float bcoef1 = real(@b1) float gcoef1 = real(@g1) float acoef2 = real(@a2) float bcoef2 = real(@b2) float gcoef2 = real(@g2) float ra1 = imag(@a1) float rb1 = imag(@b1) float rg1 = imag(@g1) float ra2 = imag(@a2) float rb2 = imag(@b2) float rg2 = imag(@g2) int iter = 0 float xx = 0 if @start == 0 w = #z else w = #pixel endif w = ((w - @offset) / @scale) * ((0,1) ^ (@rot / 90.0)) float x = real(w) float y = imag(w) while iter < @max_iter ; "Random" numbers. if imag(@a1) != 0 ar1 = (a * ar1 + c) % m acoef1 = real(@a1) + (ar1 / m) * ra1 endif if imag(@b1) != 0 br1 = (a * br1 + c) % m bcoef1 = real(@b1) + (br1 / m) * rb1 endif if imag(@g1) != 0 gr1 = (a * gr1 + c) % m gcoef1 = real(@g1) + (gr1 / m) * rg1 endif if imag(@a2) != 0 ar2 = (a * ar2 + c) % m acoef2 = real(@a2) + (ar2 / m) * ra2 endif if imag(@b2) != 0 br2 = (a * br2 + c) % m bcoef2 = real(@b2) + (br2 / m) * rb2 endif if imag(@g2) != 0 gr2 = (a * gr2 + c) % m gcoef2 = real(@g2) + (gr2 / m) * rg2 endif if @seq == 0 ; Iteration test = iter % real(@mv) < imag(@mv) elseif @seq == 1 ; Random seqr = (a * seqr + c) % m if seqr % 2 == 0 test = true else test = false endif elseif @seq == 2 ; First formula test = true elseif @seq == 3 ; Second formula test = false endif xx = x if test x = x - @h * real(@af1(acoef1 * y + \ @bf1(bcoef1 * (y + @gf1(gcoef1 * y))))) y = y + @h * real(@af1(acoef1 * xx +\ @bf1(bcoef1 * (xx + @gf1(gcoef1 * xx))))) else x = x - @h * real(@af2(acoef2 * y + \ @bf2(bcoef2 * (y + @gf2(gcoef2 * y))))) y = y + @h * real(@af2(acoef2 * xx + \ @bf2(bcoef2 * (xx + @gf2(gcoef2 * xx))))) endif p = x + flip(y) iter = iter + 1 endwhile #index = cabs(w - p) default: title = "Advanced Gnarl" helpfile = "mt.hlp" helptopic = "Advanced Gnarl Coloring" param seq caption = "Sequence" enum = "Modulation" "Random" "First Formula" \ "Second Formula" endparam param mv caption = "Modulation" default = (10,5) min = (1,0) endparam param max_iter caption = "Iterations" default = 10 endparam param start caption = "Initialization" enum = "Orbit" "Pixel" endparam param offset caption = "Offset" default = (0,0) endparam param scale caption = "Magnification" default = 1.0 endparam param rot caption = "Rotation" default = 0.0 endparam param a1 caption = "A 1" default = (1.0,0) endparam param b1 caption = "B 1" default = (3.0,0) endparam param g1 caption = "G 1" default = (2.0,0) endparam param a2 caption = "A 2" default = (1.0,0) endparam param b2 caption = "B 2" default = (3.0,0) endparam param g2 caption = "G 2" default = (2.0,0) endparam param h caption = "Step Size" default = 0.1 endparam param a_seed caption = "A Seed" default = (3539,9923) endparam param b_seed caption = "B Seed" default = (6373,8191) endparam param g_seed caption = "G Seed" default = (1277,4583) endparam param seqseed caption = "Sequence Seed" default = 2017 endparam func af1 caption = "A 1" default = sin() endfunc func bf1 caption = "B 1" default = sin() endfunc func gf1 caption = "G 1" default = sin() endfunc func af2 caption = "A 2" default = cos() endfunc func bf2 caption = "B 2" default = cos() endfunc func gf2 caption = "G 2" default = cos() endfunc } mt-harlequin { ; Mark Townsend, 22 Aug 1999 ; ; Based on the Paul Carlson orbit trap. ; ; Last update 13 January 2000 ; init: int ra = 1322939 int rc = 7336919 int rm = 36282757 float x = 0 float y = 0 trap_z = 0 trap_point = 0 int iter = 0 int trap_iter = 0 float temp = 0 float min_dist = 1e20 loop: x = real(#z) y = imag(#z) complex a = @m * real(atan(y / x)) if @variation == 0 a = a * a + @c a = fn1(1 - a) / a elseif @variation == 1 a = a * a + @c a = fn1(1 - a^2) elseif @variation == 2 a = @m * (fn1(a + @c)^2 + fn2(a + @c)^2) endif if @mode == 0 temp = abs(|#z| - |a|) else temp = cabs(#z - a) endif if temp < min_dist min_dist = temp trap_z = #z trap_iter = iter trap_point = a endif iter = iter + 1 final: if @coloring == 0 ; Distance #index = min_dist elseif @coloring == 1 ; Magnitude #index = cabs(trap_z) elseif @coloring == 2 ; Iteration #index = 0.01 * trap_iter elseif @coloring == 3 ; Real #index = real(trap_z) elseif @coloring == 4 ; Imaginary #index = imag(trap_z) elseif @coloring == 5 ; Angle float b = atan2(trap_z) if b < 0 b = b + 2 * #pi endif b = 1 / (2 * #pi) * b #index = b elseif @coloring == 6 ; Modulated iteration #index = ((trap_iter) % @iter_mod) / @iter_mod elseif @coloring == 7 ; Random iteration #index = (((ra * (trap_iter + @rnd) + rc) % rm) % @iter_mod) / @iter_mod elseif @coloring == 8 ; Real #2 - corrected by using absolute value #index = abs(real(trap_z)) elseif @coloring == 9 ; Imaginary - ditto #index = abs(imag(trap_z)) elseif @coloring == 10 ; Angle to trap float b = atan2(trap_z - trap_point) if b < 0 b = b + 2 * #pi endif b = 1 / (2 * #pi) * b #index = b endif default: title = "Harlequin" param variation caption = "Variation" enum = "1" "2" "3" default = 1 endparam param mode caption = "Flavor" enum = "1" "2" default = 1 endparam param m caption = "Angle Multiplier" default = 2.0 endparam param c caption = "Harlequin Seed" default = (0,0) endparam param coloring caption = "Coloring Mode" enum = "Distance" "Magnitude" "Iteration" "Real" "Imag" "Angle" \ "Modulated Iter" "Random Iter" "Real #2" "Imag #2" "Angle to Trap" endparam param iter_mod caption = "No. of Colors" default = 8 hint = "The number of different colors used for the Modulated Iter \ and Random Iter coloring modes." endparam param rnd caption = "Random Seed" default = 0 hint = "This is the random seed for the Random Iter coloring mode." endparam func fn1 caption = "First function" hint = "This function is used in all variations." default = exp() endfunc func fn2 caption = "Second function" hint = "This function is only used in variaton 3." default = exp() endfunc } mt-cardioid { ; Mark Townsend, 30 December 1999 ; Last update 16 February 2000 init: trap_z = 0 trap_p = 0 int iter = 0 float dist = 0 float theta = 0 float radius = 0 int trap_iter = 0 float min_dist = 1e30 int a = 1322939 int c = 7336919 int m = 36282757 if @no_of_iters == 0 int max_iter = #maxiter - @skip else int max_iter = @skip + @no_of_iters endif loop: theta = atan2(#z) radius = @a * (1 - cos(theta)) trap_point = radius * sin(theta) + flip(radius * cos(theta)) dist = cabs(#z - trap_point) if (iter > @skip && iter < max_iter) && dist < min_dist min_dist = dist trap_iter = iter trap_z = #z trap_p = trap_point endif iter = iter + 1 final: if @masked if min_dist > @thresh #solid = true endif endif if @color_mode == 0 ; Distance #index = min_dist elseif @color_mode == 1 ; Normal iteration #index = 0.01 * trap_iter elseif @color_mode == 2 ; Modulated iteration #index = ((trap_iter) % @iter_mod) / @iter_mod elseif @color_mode == 3 ; Random iteration ??? #index = (((a * (trap_iter+@rnd) + c) % m) % @iter_mod) / @iter_mod elseif @color_mode == 4 ; Magnitude #index = cabs(trap_z) elseif @color_mode == 5 ; Real #index = abs(real(trap_z)) elseif @color_mode == 6 ; Imag #index = abs(imag(trap_z)) elseif @color_mode == 7 ; Angle float arg = atan2(trap_z) if arg < 0 arg = arg + 2 * #pi endif #index = 1 / (2 * #pi) * arg elseif @color_mode == 8 ; Angle to Trap float arg = atan2(trap_z - trap_p) if arg < 0 arg = arg + 2 * #pi endif #index = 1 / (2 * #pi) * arg elseif @color_mode == 9 ; Trap Magnitude #index = cabs(trap_p) endif default: title = "Cardioid" param color_mode caption = "Color Mode" enum = "Distance" "Iteration" "Modulated Iter" "Random Iter" "Magnitude" "Real" "Imag" \ "Angle" "Angle to Trap" "Trap Magnitude" endparam param iter_mod caption = "No. of Colors" default = 8 endparam param a caption = "Trap Parameter" default = 1.0 endparam param skip caption = "Iterations to skip" hint = "This is the number of iterations to skip before watching \ the orbit." default = 0 ; Min at -1 because I stuffed up the comparaison to Iter... ; a value of zero skips an iteration. min = -1 endparam param no_of_iters caption = "No. of iterations" hint = "This is the number of iterations to monitor the orbit. \ If it is set to zero all iterations are monitored." default = 0 min = 0 endparam param rnd caption = "Random Seed" default = 0 endparam param masked caption = "Masked" default = false endparam param thresh caption = "Mask Threshold" default = 0.5 endparam } mt-sine { ; Mark Townsend, 24 Oct 1999 ; Last update 6 March 2000 init: trap_z = 0 trap_p = 0 float x = 0 float y = 0 int iter = 0 float dist = 0 int trap_iter = 0 bool trapped = false float min_dist = 1e20 if @trap_mode == 0 || @trap_mode == 3 trapped = true endif loop: if @coord == 0 x = @ha * real(@fn3(@ht * imag(@fn1(#z)))) y = @va * real(@fn3(@vt * real(@fn2(#z))) ) w = x + flip(y) else float r = cabs(@fn1(#z)) float theta = atan2(@fn2(#z)) if theta < 0 theta = theta + 2 * #pi endif float or = r r = r + @ha * sin(@ht * theta) theta = theta + @va * cos(@vt * or) x = r * cos(theta) y = r * sin(theta) w = x + flip(y) endif dist = cabs(#z - w) if iter >= @skip if (@trap_mode == 0) || (@trap_mode == 3) if dist < min_dist min_dist = dist trap_p = w trap_z = #z trap_iter = iter endif elseif @trap_mode == 1 if !trapped && dist <= @size trapped = true min_dist = dist trap_z = #z trap_p = w trap_iter = iter endif else if dist <= @size trapped = true min_dist = dist trap_z = #z trap_p = w trap_iter = iter endif endif endif iter = iter + 1 final: if !trapped || (@trap_mode == 3 && min_dist > @size) #solid = true else if @color == 0 #index = min_dist elseif @color == 1 #index = cabs(trap_z) elseif @color == 2 #index = 0.01 * trap_iter elseif @color == 3 #index = abs(real(trap_z)) elseif @color == 4 #index = abs(imag(trap_z)) elseif @color == 5 theta = atan2(trap_z) if theta < 0 theta = theta + 2 * #pi endif theta = 1 / (2 * #pi) * theta #index = theta elseif @color == 6 ; Modulated iteration #index = ((trap_iter) % 8) / 8 elseif @color == 7 ; Angle to Trap float arg = atan2(trap_z - trap_p) if arg < 0 arg = arg + 2 * #pi endif #index = 1 / (2 * #pi) * arg endif endif default: title = "Sine" param coord caption = "Coodinate Mode" enum = "Cartesian" "Polar" endparam param trap_mode caption = "Trap Mode" enum = "Closest" "First" "Last" "Masked" endparam param @color caption = "Coloring Mode" enum = "Distance" "Magnitude" "Iteration" "Real" "Imag" "Angle" \ "Modulated Iter" "Angle to Trap" endparam param skip caption = "Iterations to Skip" default = 0 endparam param size caption = "Element Size" default = 0.1 endparam param ht caption = "Frequency #1" default = 10.0 endparam param ha caption = "Amplitude #1" default = 0.5 endparam param vt caption = "Frequency #2" default = 10.0 endparam param va caption = "Amplitude #2" default = 0.5 endparam func fn1 caption = "First Function" default = ident() endfunc func fn2 caption = "Second Function" default = ident() endfunc func fn3 caption = "Extra Function" default = sin() hint = "This function is used only for the Cartesian mode." endfunc } mt-gen-popcorn-trap { ; Mark Townsend, 2 April 2000 ; ; A genrealised version Clifford Pickover's Popcorn ; formula used as an orbit trap. ; ; fBm texture added 6 April 2000 ; Texture and pattern enhancements added 23 April 2000 ; Masking enhancements added 14 May 2000 ; ; The code for the fBm texture comes from Damien M. Jones' ; Fractional Brownian Motion coloring method. ; init: int i = 0 pat_p = 0 trap_z = 0 trap_p = 0 float x = 0 float y = 0 float xx = 0 int iter = 0 float sum = 0 float dist = 0 float noise = 0 int trap_iter = 0 float texture = 0 bool masked = false float min_dist = 1e30 loop: p = (#z / @scale) - @offset ; Iterate the Popcorn formula i = 0 x = real(p) y = imag(p) while i < @max_iterations xx = x x = x - @h * real(@fn1(y + @fn2(@a * y))) y = y - @h * real(@fn3(xx + @fn4(@b * xx))) i = i + 1 endwhile p = (x + flip(y)) + @offset dist = cabs(#z - p) if (iter >= @skip) && dist < min_dist trap_z = #z trap_p = p min_dist = dist trap_iter = iter endif iter = iter + 1 final: if @mask_type == 0 if @mask != 0 if min_dist > @mask masked = true endif endif elseif @mask_type == 1 if @mask != 0 float mask_val = trap_iter if @mask_mod != 0 mask_val = trap_iter % @mask_mod endif if mask_val < @mask masked = true endif endif elseif @mask_type == 2 if (trap_iter >= @mask) && (trap_iter <= @mask_mod) masked = true endif endif if @inverse masked = !masked endif if masked #solid = true else if (@texture_type == 0) ;Random texture = @rnd * real(#random) else ; fBm if (@rnd != 0) complex r = (0,1) ^ (@angle / 90.0) complex r2 = (0,1) ^ (@anglestep / 90.0) if @initial == 0 pat_p = #pixel * r + @fbmOffset complex p = #pixel * @fbmscale * r + @fbmoffset elseif @initial == 1 pat_p = trap_z * r + @fbmOffset complex p = trap_z * @fbmscale * r + @fbmoffset elseif @initial == 2 pat_p = trap_p * r + @fbmOffset complex p = trap_p * @fbmscale * r + @fbmoffset endif float freq = 1.0 int i = @octaves while (i > 0) ; determine integer coordinate for corners of square ; surrounding p float bx0 = floor(real(p)) % 256 float by0 = floor(imag(p)) % 256 if (bx0 < 0) bx0 = bx0 + 256 endif if (by0 < 0) by0 = by0 + 256 endif float bx1 = (bx0 + 1) % 256 float by1 = (by0 + 1) % 256 float rx0 = real(p) - floor(real(p)) float ry0 = imag(p) - floor(imag(p)) float rx1 = rx0 - 1 float ry1 = ry0 - 1 float b00 = (bx0^@power % 65536 + by0)^@power % 65536 float b10 = (bx1^@power % 65536 + by0)^@power % 65536 float b01 = (bx0^@power % 65536 + by1)^@power % 65536 float b11 = (bx1^@power % 65536 + by1)^@power % 65536 float g_b00_0 = (b00)^@power*0.25 % 512 - 256 float g_b10_0 = (b10)^@power*0.25 % 512 - 256 float g_b01_0 = (b01)^@power*0.25 % 512 - 256 float g_b11_0 = (b11)^@power*0.25 % 512 - 256 float g_b00_1 = (b00+1)^@power*0.25 % 512 - 256 float g_b10_1 = (b10+1)^@power*0.25 % 512 - 256 float g_b01_1 = (b01+1)^@power*0.25 % 512 - 256 float g_b11_1 = (b11+1)^@power*0.25 % 512 - 256 float d = 0.0; d = 1 / sqrt(sqr(g_b00_0) + sqr(g_b00_1)) g_b00_0 = g_b00_0 * d g_b00_1 = g_b00_1 * d d = 1 / sqrt(sqr(g_b10_0) + sqr(g_b10_1)) g_b10_0 = g_b10_0 * d g_b10_1 = g_b10_1 * d d = 1 / sqrt(sqr(g_b01_0) + sqr(g_b01_1)) g_b01_0 = g_b01_0 * d g_b01_1 = g_b01_1 * d d = 1 / sqrt(sqr(g_b11_0) + sqr(g_b11_1)) g_b11_0 = g_b11_0 * d g_b11_1 = g_b11_1 * d float u1 = rx0 * g_b00_0 + ry0 * g_b00_1 float v1 = rx1 * g_b10_0 + ry0 * g_b10_1 float u2 = rx0 * g_b01_0 + ry1 * g_b01_1 float v2 = rx1 * g_b11_0 + ry1 * g_b11_1 float sx = sqr(rx0) * (3 - rx0*2) float sy = sqr(ry0) * (3 - ry0*2) float a = u1 + sx*(v1 - u1) float b = u2 + sx*(v2 - u2) if @fbmfunc == 0 ; Ident sum = sum + (a + sy * (b - a)) * freq elseif @fbmfunc == 1 ; Abs sum = sum + sqrt(2) * abs(a + sy * (b - a)) * freq elseif @fbmfunc == 2 ; Sqr sum = sum + 4 * sqr(a + sy * (b - a)) * freq elseif @fbmfunc == 3 ; Sqrt float noise = a + sy * (b - a) if noise < 0 noise = imag(sqrt(noise)) else noise = real(sqrt(noise)) endif sum = sum + noise * freq elseif @fbmfunc == 4 ; Ceil sum = sum + ceil(a + sy * (b - a)) * freq endif freq = freq * @step p = p * r2 / @step i = i - 1 endwhile endif if @pattern == 0 noise = sum elseif @pattern == 1 ; Marble noise = real(sin(@pfreq * real(pat_p) + (@turb * sum))) elseif @pattern == 2 ; Wood noise = cabs(@pfreq * pat_p) + (@turb * sum) elseif @pattern == 3 ; Cells float x = sin(@pfreq * real(pat_p)) float y = cos(@pfreq * imag(pat_p)) noise = cabs(x + flip(y)) + (@turb * sum) elseif @pattern == 4 p = round(pat_p * @pfreq) / @pfreq noise = 2 * cabs(@pfreq * pat_p - @pfreq * p) + (@turb * sum) endif if @texture_type == 1 ; Original fBm texture = @rnd * noise elseif @texture_type == 2 ; Corrected fBm texture = @rnd * ((noise + 1) * 0.5) endif endif if @color_mode == 0 ; Distance #index = min_dist + texture elseif @color_mode == 1 ; Iteration #index = 0.01 * trap_iter + texture elseif @color_mode == 2 ; Magnitude #index = cabs(trap_z) + texture elseif @color_mode == 3 ; Real #index = abs(real(trap_z)) + texture elseif @color_mode == 4 ; Imag #index = abs(imag(trap_z)) + texture elseif @color_mode == 5 ; Angle float angle = atan2(trap_z) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle #index = angle + (@rnd * real(#random)) elseif @color_mode == 6 ; Modulated iteration #index = ((trap_iter) % 8) / 8 + texture elseif @color_mode == 7 ; Angle to Trap float angle = atan2(trap_z - trap_p) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle #index = angle + texture endif endif default: title = "fBm Popcorn Trap" helpfile = "mt.hlp" helptopic = "fBm Popcorn Trap" param color_mode caption = "Coloring Mode" enum = "Distance" "Iteration" "Magnitude" "Real" "Imag" \ "Angle" "Modulated Iter" "Angle to Trap" endparam param a caption = "Re Alpha" default = 3.0 endparam param b caption = "Im Alpha" default = 3.0 endparam param h caption = "Step Size" default = 0.05 hint = "This is step size for the Popcorn formula." endparam param max_iterations caption = "Iterations" default = 3 min = 1 hint = "This is the number of iterations for the \ Popcorn formula." endparam param @scale caption = "Scale" default = 0.5 endparam param offset caption = "Offset" default = (0,0) endparam param skip caption = "Iterations to Skip" hint = "This is the number of iterations to skip before watching \ the orbit." default = 0 min = 0 endparam param mask_type caption = "Mask Type" enum = "Distance" "Iteration" "Range" endparam param mask caption = "Mask Threshold" default = 0.0 min = 0.0 hint = "With the Distance Mask Type orbits that don't come at least \ this close to the trap are made solid. A value of zero means \ that no pixels are made solid." endparam param mask_mod caption = "Mask Modulation" default = 0 hint = "With the Modulation Mask Type the iteration that the orbit \ was caught by the trap is modulated by this value, and if \ the Mask Threshold is smaller the pixel is made solid." endparam param inverse caption = "Mask Reversed" default = false endparam param texture_type caption = "Texture Type" enum = "Random" "fBm" "Corrected fBm" hint = "This is the type of texture to add to the coloring. The \ Texture Amount parameter must be non-zero for texture to be added." endparam param rnd caption = "Texture Amount" default = 0.0 hint = "This is the amount of texturing to add to the coloring." endparam param initial caption = "fBm Initialisation" enum = "Pixel" "Orbit" "Trap" hint = "Different ways of starting the fBm formula. With \ Orbit and Trap the texture will follow the orbit trap \ elements in some way." endparam param fbmfunc caption = "fBm Function" enum = "Ident" "Abs" "Sqr" "Sqrt" "Ceil" hint = "This is a function that is added to the fBm to chnage \ the way that it looks." endparam param fbmscale caption = "fBm Scale" default = 1.0 hint = "This is the overall scale of the noise." endparam param fbmoffset caption = "fBm Offset" default = (0,0) hint = "This is the offset of the pattern. You can use this to shift \ the pattern around on the complex plane." endparam param angle caption = "fBm Rotation" default = 0.0 hint = "This is the angle, in degrees, of the noise." endparam param step caption = "fBm Scale Step" default = 0.5 hint = "This is the step in scale between noise iterations." endparam param anglestep caption = "fBm Rotation Step" default = 37.0 hint = "This is the angle, in degrees, to rotate between noise \ iterations." endparam param octaves caption = "fBm Octaves" default = 7 min = 1 hint = "This is the number of iterations of the noise formula." endparam param power caption = "fBm Exponent" default = 2.0 hint = "This is the exponent used to scramble numbers." endparam param pattern caption = "fBm Pattern" enum = "None" "Marble" "Wood" "Cells" "Squares" hint = "This creates a repeating pattern to be disturbed by the fBm." endparam param pfreq caption = "fBm Frequency" default = 1.0 hint = "This controls the frequency of the Pattern." endparam param turb caption = "fBm Turbulence" default = 1.0 hint = "With a Pattern other than None this effects how \ the pattern will be by the fBm." endparam func fn1 caption = "Re Popcorn #1" default = sin() endfunc func fn2 caption = "Re Popcorn #2" default = tan() endfunc func fn3 caption = "Im Popcorn #1" default = sin() endfunc func fn4 caption = "Im Popcorn #2" default = tan() endfunc } mt-popcorn-plasma { ; Mark Townsend, 1 June 2000 init: int i = 0 float sum = 0 float amplitude = 1.0 complex p = #pixel * @scale + @offset while i < @octaves float bx0 = floor(real(p)) float bx1 = bx0 + 1 float rx0 = real(p) - floor(real(p)) float rx1 = rx0 - 1 float by0 = floor(imag(p)) float by1 = by0 + 1 float ry0 = imag(p) - floor(imag(p)) float ry1 = ry0 - 1 ; Positive offset to stop reflection if bx0 < 0 bx0 = bx0 + 8192 endif if bx1 < 0 bx1 = bx1 + 8192 endif if by0 < 0 by0 = by0 + 8192 endif if by1 < 0 by1 = by1 + 8192 endif float sx = rx0 * rx0 * (3 - 2 * rx0) float sy = ry0 * ry0 * (3 - 2 * ry0) float b00 = (bx0^2 * 2473 % 65536 + by0)^2 % 65536 float b01 = (bx0^2 * 2473 % 65536 + by1)^2 % 65536 float b10 = (bx1^2 * 2473 % 65536 + by0)^2 % 65536 float b11 = (bx1^2 * 2473 % 65536 + by1)^2 % 65536 float g_b00_0 = b00^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b01_0 = b01^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b10_0 = b10^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b11_0 = b11^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b00_1 = (b00 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b01_1 = (b01 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b10_1 = (b10 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b11_1 = (b11 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float s = sqrt(g_b00_0^2 + g_b00_1^2) g_b00_0 = g_b00_0 / s g_b00_1 = g_b00_1 / s s = sqrt(g_b01_0^2 + g_b01_1^2) g_b01_0 = g_b01_0 / s g_b01_1 = g_b01_1 / s s = sqrt(g_b10_0^2 + g_b10_1^2) g_b10_0 = g_b10_0 / s g_b10_1 = g_b10_1 / s s = sqrt(g_b11_0^2 + g_b11_1^2) g_b11_0 = g_b11_0 / s g_b11_1 = g_b11_1 / s float u1 = rx0 * g_b00_0 + ry0 * g_b00_1 float v1 = rx1 * g_b10_0 + ry0 * g_b10_1 float a = u1 + sx * (v1 - u1) float u2 = rx0 * g_b01_0 + ry1 * g_b01_1 float v2 = rx1 * g_b11_0 + ry1 * g_b11_1 float b = u2 + sx * (v2 - u2) sum = sum + real(@fn1(a + sy * (b - a))) * amplitude amplitude = amplitude * @persistence p = p / 0.5 i = i + 1 endwhile float min_dist = 1e20 complex w = 0 float dist = 0 int iter = 0 int trap_iter = 0 complex trap_z = 0 + 0i complex trap_p = 0 + 0i loop: w = #z / @g x = real(w) y = imag(w) xx = x x = x - @h * real(@gn1(y + @gn2(@a*sum * y))) y = y - @h * real(@gn3(xx + @gn4(@b*sum * xx))) w = x + flip(y) dist = cabs(#z - w) if dist < min_dist min_dist = dist trap_iter = iter trap_p = w trap_z = #z endif iter = iter + 1 final: bool masking = false if @mask_mode == 1 if min_dist < @threshold masking = true endif elseif @mask_mode == 2 if trap_iter % trunc(imag(@mask_mod)) < trunc(real(@mask_mod)) masking = true endif elseif @mask_mode == 3 if trap_iter >= trunc(real(@mask_range)) && trap_iter <= trunc(imag(@mask_range)) masking = true endif endif if @mask_mode != 0 if @reverse masking = !masking endif endif if masking #solid = true else if @color == 0 ; Distance #index = min_dist elseif @color == 1 ; Iteration #index = 0.1 * trap_iter elseif @color == 2 ; Magnitude #index = cabs(trap_z) elseif @color == 3 ; Real #index = abs(real(trap_z)) elseif @color == 4 ; Imag #index = abs(imag(trap_z)) elseif @color == 5 ; Trap #index = cabs(trap_p) elseif @color == 6 ; Angle float b = atan2(trap_z) if b < 0 b = b + 2 * #pi endif b = 1 / (2 * #pi) * b #index = b elseif @color == 7 ; Angle to trap float b = atan2(trap_z - trap_p) if b < 0 b = b + 2 * #pi endif b = 1 / (2 * #pi) * b #index = b elseif @color == 8 ; Modulated #index = ((trap_iter) % 8) / 8 endif endif default: title = "Popcorn Plasma" param @color caption = "Coloring Mode" enum = "Distance" "Iteration" "Magnitude" "Real" "Imaginary" \ "Trap" "Angle" "Angle to Trap" "Modulated" endparam param a caption = "Alpha" default = 5.0 endparam param b caption = "Beta" default = 4.0 endparam param h caption = "Gamma" default = 0.1 endparam param g caption = "Delta" default = 0.5 endparam param octaves caption = "Octaves" default = 7 min = 1 endparam param persistence caption = "Persistence" default = 0.5 endparam param scale caption = "Noise Scale" default = 1.0 endparam param offset caption = "Noise Offset" default = (0,0) endparam param @mask_mode caption = "Mask Mode" enum = "None" "Distance" "Modulated" "Range" endparam param threshold caption = "Mask Threshold" default = 0.5 endparam param mask_mod caption = "Mask Modulation" default = (1,2) endparam param mask_range caption = "Mask Range" default = (0,0) endparam param reverse caption = "Reverse Mask" default = false endparam func gn1 caption = "Alpha" default = cosh() endfunc func gn2 caption = "Beta" default = flip() endfunc func gn3 caption = "Gamma" default = sin() endfunc func gn4 caption = "Delta" default = sqr() endfunc func fn1 caption = "Noise Function" default = ident() endfunc } mt-disk-plasma { ; Mark Townsend, 1 June 2000 ; ; Based on an idea from Earl Hinrich ; init: float d = 0 complex w = 0 int iter = 0 int max_iter = 0 bool mask = false loop: iter = iter + 1 if cabs(#z - @doffset) < @r d = (@r - cabs(#z - @doffset)) / @r w = w + d * #z max_iter = iter endif final: if @solid if w == 0 mask = true endif endif if mask #solid = true else if @coloring == 0 #index = 0.1 * cabs(w) elseif @coloring == 1 #index = 0.1 * abs(real(w)) elseif @coloring == 2 #index = 0.1 * abs(imag(w)) elseif @coloring == 3 float b = atan2(w) if b < 0 b = b + 2 * #pi endif b = 1 / (2 * #pi) * b #index = b elseif @coloring == 4 #index = 0.1 * max_iter elseif @coloring == 5 int i = 0 float sum = 0 float amplitude = 1.0 complex p = w * @scale + @offset while i < @octaves float bx0 = floor(real(p)) float bx1 = bx0 + 1 float rx0 = real(p) - floor(real(p)) float rx1 = rx0 - 1 float by0 = floor(imag(p)) float by1 = by0 + 1 float ry0 = imag(p) - floor(imag(p)) float ry1 = ry0 - 1 ; Positive offset to stop reflection if bx0 < 0 bx0 = bx0 + 8192 endif if bx1 < 0 bx1 = bx1 + 8192 endif if by0 < 0 by0 = by0 + 8192 endif if by1 < 0 by1 = by1 + 8192 endif float sx = rx0 * rx0 * (3 - 2 * rx0) float sy = ry0 * ry0 * (3 - 2 * ry0) float b00 = (bx0^2 * 2473 % 65536 + by0)^2 % 65536 float b01 = (bx0^2 * 2473 % 65536 + by1)^2 % 65536 float b10 = (bx1^2 * 2473 % 65536 + by0)^2 % 65536 float b11 = (bx1^2 * 2473 % 65536 + by1)^2 % 65536 float g_b00_0 = b00^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b01_0 = b01^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b10_0 = b10^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b11_0 = b11^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b00_1 = (b00 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b01_1 = (b01 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b10_1 = (b10 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b11_1 = (b11 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float s = sqrt(g_b00_0^2 + g_b00_1^2) g_b00_0 = g_b00_0 / s g_b00_1 = g_b00_1 / s s = sqrt(g_b01_0^2 + g_b01_1^2) g_b01_0 = g_b01_0 / s g_b01_1 = g_b01_1 / s s = sqrt(g_b10_0^2 + g_b10_1^2) g_b10_0 = g_b10_0 / s g_b10_1 = g_b10_1 / s s = sqrt(g_b11_0^2 + g_b11_1^2) g_b11_0 = g_b11_0 / s g_b11_1 = g_b11_1 / s float u1 = rx0 * g_b00_0 + ry0 * g_b00_1 float v1 = rx1 * g_b10_0 + ry0 * g_b10_1 float a = u1 + sx * (v1 - u1) float u2 = rx0 * g_b01_0 + ry1 * g_b01_1 float v2 = rx1 * g_b11_0 + ry1 * g_b11_1 float b = u2 + sx * (v2 - u2) sum = sum + real(@fn1(a + sy * (b - a))) * amplitude amplitude = amplitude * @persistence p = p / 0.5 i = i + 1 endwhile #index = (sum + 1) * 0.5 endif endif default: title = "Disk Plasma" param coloring caption = "Coloring Mode" enum = "Magnitude" "Real" "Imaginary" "Angle" "Iteration" "Plasma" endparam param r caption = "Disk Radius" default = 2.0 min = 0 endparam param doffset caption = "Disk Offset" default = (0,0) endparam param octaves caption = "Octaves" default = 7 min = 1 endparam param persistence caption = "Persistence" default = 0.5 endparam param scale caption = "Noise Scale" default = 1.0 endparam param offset caption = "Noise Offset" default = (0,0) endparam param solid caption = "Solid Background" default = false endparam func fn1 caption = "Noise Function" default = ident() endfunc } Default param color caption = "Coloring Mode" enum = "Distance" "Iteration" "Magnitude" "Real" "Imaginary" \ "Trap" "Angle" "Angle to Trap" "Modulated Iter" endparam param flavor caption = "Flavor" enum = "Red" "Black" default = 1 endparam param c caption = "Seed" default = (0,0) endparam param m caption = "Mulitplier" default = 2.0 endparam param octaves caption = "Octaves" default = 2 min = 1 endparam param persistence caption = "Persistence" default = 0.5 endparam param scale caption = "Noise Scale" default = 1.0 endparam param offset caption = "Noise Offset" default = (0,0) endparam param threshold caption = "Mask Threshold" default = 0.0 hint = "Use a non-zero value to add masking. \ Positive values mask outside the elements and \ negative values mask inside the elements." endparam func hn1 caption = "Trap Function" default = atanh() endfunc func fn1 caption = "Noise Function" default = ident() endfunc default: title = "" } mt-joker { ; Mark Townsend, 31 May 2000 ; Masking added 20 October 2000 ; ; Coloring based on Paul Carlson's Harlequin ; orbit trap and fBm. ; init: int i = 0 float sum = 0 float amplitude = 1.0 complex p = #pixel * @scale + @offset while i < @octaves float bx0 = floor(real(p)) float bx1 = bx0 + 1 float rx0 = real(p) - floor(real(p)) float rx1 = rx0 - 1 float by0 = floor(imag(p)) float by1 = by0 + 1 float ry0 = imag(p) - floor(imag(p)) float ry1 = ry0 - 1 ; Positive offset to stop reflection if bx0 < 0 bx0 = bx0 + 8192 endif if bx1 < 0 bx1 = bx1 + 8192 endif if by0 < 0 by0 = by0 + 8192 endif if by1 < 0 by1 = by1 + 8192 endif float sx = rx0 * rx0 * (3 - 2 * rx0) float sy = ry0 * ry0 * (3 - 2 * ry0) float b00 = (bx0^2 * 2473 % 65536 + by0)^2 % 65536 float b01 = (bx0^2 * 2473 % 65536 + by1)^2 % 65536 float b10 = (bx1^2 * 2473 % 65536 + by0)^2 % 65536 float b11 = (bx1^2 * 2473 % 65536 + by1)^2 % 65536 float g_b00_0 = b00^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b01_0 = b01^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b10_0 = b10^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b11_0 = b11^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b00_1 = (b00 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b01_1 = (b01 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b10_1 = (b10 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b11_1 = (b11 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float s = sqrt(g_b00_0^2 + g_b00_1^2) g_b00_0 = g_b00_0 / s g_b00_1 = g_b00_1 / s s = sqrt(g_b01_0^2 + g_b01_1^2) g_b01_0 = g_b01_0 / s g_b01_1 = g_b01_1 / s s = sqrt(g_b10_0^2 + g_b10_1^2) g_b10_0 = g_b10_0 / s g_b10_1 = g_b10_1 / s s = sqrt(g_b11_0^2 + g_b11_1^2) g_b11_0 = g_b11_0 / s g_b11_1 = g_b11_1 / s float u1 = rx0 * g_b00_0 + ry0 * g_b00_1 float v1 = rx1 * g_b10_0 + ry0 * g_b10_1 float a = u1 + sx * (v1 - u1) float u2 = rx0 * g_b01_0 + ry1 * g_b01_1 float v2 = rx1 * g_b11_0 + ry1 * g_b11_1 float b = u2 + sx * (v2 - u2) sum = sum + real(@fn1(a + sy * (b - a))) * amplitude amplitude = amplitude * @persistence p = p / 0.5 i = i + 1 endwhile float min_dist = 1e20 complex p = 0 float dist = 0 int iter = 0 int trap_iter = 0 complex trap_z = 0 + 0i complex trap_p = 0 + 0i loop: float x = real(#z) float y = imag(#z) complex a2 = @m * sum * atan(y / x) if @flavor == 0 a2 = a2 * a2 + @c a2 = @hn1(1 - a2) / a2 elseif @flavor == 1 a2 = a2 * a2 + @c a2 = @hn1(1 - a2^2) endif dist = cabs(#z - a2) if dist < min_dist min_dist = dist trap_iter = iter trap_p = a2 trap_z = #z endif iter = iter + 1 final: if @threshold < 0 if min_dist < abs(@threshold) #solid = true endif elseif @threshold > 0 if min_dist > @threshold #solid = true endif endif if @color == 0 #index = min_dist elseif @color == 1 #index = 0.1 * trap_iter elseif @color == 2 #index = cabs(trap_z) elseif @color == 3 #index = abs(real(trap_z)) elseif @color == 4 #index = abs(imag(trap_z)) elseif @color == 5 #index = cabs(trap_p) elseif @color == 6 float b = atan2(trap_z) if b < 0 b = b + 2 * #pi endif b = 1 / (2 * #pi) * b #index = b elseif @color == 7 float b = atan2(trap_z - trap_p) if b < 0 b = b + 2 * #pi endif b = 1 / (2 * #pi) * b #index = b elseif @color == 8 #index = ((trap_iter) % 8) / 8 endif default: title = "Joker" param @color caption = "Coloring Mode" enum = "Distance" "Iteration" "Magnitude" "Real" "Imaginary" \ "Trap" "Angle" "Angle to Trap" "Modulated Iter" endparam param flavor caption = "Flavor" enum = "Red" "Black" default = 1 endparam param c caption = "Seed" default = (0,0) endparam param m caption = "Mulitplier" default = 2.0 endparam param octaves caption = "Octaves" default = 2 min = 1 endparam param persistence caption = "Persistence" default = 0.5 endparam param scale caption = "Noise Scale" default = 1.0 endparam param offset caption = "Noise Offset" default = (0,0) endparam param threshold caption = "Mask Threshold" default = 0.0 hint = "Use a non-zero value to add masking. \ Positive values mask outside the elements and \ negative values mask inside the elements." endparam func hn1 caption = "Trap Function" default = atanh() endfunc func fn1 caption = "Noise Function" default = ident() endfunc } mt-plasma { ; Mark Townsend, 1 June 2000 ; ; From source code by Intel, and Ken Perlin. ; Inspiration and guidance from the fBm ; formulas of Damien M. Jones. ; final: int i = 0 float sum = 0 float amplitude = 1.0 complex p = #z * @scale + @offset while i < @octaves float bx0 = floor(real(p)) float bx1 = bx0 + 1 float rx0 = real(p) - floor(real(p)) float rx1 = rx0 - 1 float by0 = floor(imag(p)) float by1 = by0 + 1 float ry0 = imag(p) - floor(imag(p)) float ry1 = ry0 - 1 ; Positive offset to stop reflection if bx0 < 0 bx0 = bx0 + 8192 endif if bx1 < 0 bx1 = bx1 + 8192 endif if by0 < 0 by0 = by0 + 8192 endif if by1 < 0 by1 = by1 + 8192 endif float sx = rx0 * rx0 * (3 - 2 * rx0) float sy = ry0 * ry0 * (3 - 2 * ry0) float b00 = (bx0^2 * 2473 % 65536 + by0)^2 % 65536 float b01 = (bx0^2 * 2473 % 65536 + by1)^2 % 65536 float b10 = (bx1^2 * 2473 % 65536 + by0)^2 % 65536 float b11 = (bx1^2 * 2473 % 65536 + by1)^2 % 65536 float g_b00_0 = b00^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b01_0 = b01^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b10_0 = b10^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b11_0 = b11^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b00_1 = (b00 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b01_1 = (b01 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b10_1 = (b10 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b11_1 = (b11 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float s = sqrt(g_b00_0^2 + g_b00_1^2) g_b00_0 = g_b00_0 / s g_b00_1 = g_b00_1 / s s = sqrt(g_b01_0^2 + g_b01_1^2) g_b01_0 = g_b01_0 / s g_b01_1 = g_b01_1 / s s = sqrt(g_b10_0^2 + g_b10_1^2) g_b10_0 = g_b10_0 / s g_b10_1 = g_b10_1 / s s = sqrt(g_b11_0^2 + g_b11_1^2) g_b11_0 = g_b11_0 / s g_b11_1 = g_b11_1 / s float u1 = rx0 * g_b00_0 + ry0 * g_b00_1 float v1 = rx1 * g_b10_0 + ry0 * g_b10_1 float a = u1 + sx * (v1 - u1) float u2 = rx0 * g_b01_0 + ry1 * g_b01_1 float v2 = rx1 * g_b11_0 + ry1 * g_b11_1 float b = u2 + sx * (v2 - u2) sum = sum + real(@fn1(a + sy * (b - a))) * amplitude amplitude = amplitude * @persistence p = p / 0.5 + (1i * @t * sum) i = i + 1 endwhile #index = (sum + 1) * 0.5 default: title = "Plasma" param octaves caption = "Octaves" default = 7 min = 1 endparam param persistence caption = "Persistence" default = 0.5 endparam param t caption = "Smear" default = 0.0 endparam param scale caption = "Scale" default = 1.0 endparam param offset caption = "Offset" default = (0,0) endparam func fn1 caption = "Noise function" default = abs() endfunc } mt-patterns { ; Mark Townsend, 22 October 2000 final: w = #z / @size float x = real(w) float y = imag(w) if @pattern == 0 float value = floor(x) + floor(y) if value % 2 == 0 #index = 0 else #index = 0.5 endif elseif @pattern == 1 float xf = 0.5 float zf = 0.866025404 bool bndx = false float xs = 0 float zs = 0 float xl = 0 float zl = 0 float z = y float value = 0 x = abs(x) if z < 0 z = 5.196152424 - abs(z) endif xs = x / xf zs = z / zf xs = xs - floor(xs / 6) * 6 zs = zs - floor(zs/6.0) * 6 int xm = floor(xs) % 6 int zm = floor(zs) % 6 if xm == 0 || xm == 5 if zm == 0 || zm == 5 value = 0 elseif zm == 1 || zm == 2 value = 1 elseif zm == 3 || zm == 4 value = 2 endif elseif xm == 2 || xm == 3 if zm == 0 || zm == 1 value = 2 elseif zm == 2 || zm == 3 value = 0 elseif zm == 4 || zm == 5 value = 1 endif elseif xm == 1 || xm == 4 xl = xs - xm zl = zs - zm if ((xm + zm) % 2) == 1 xl = 1.0 - xl endif if (xl == 0.0) xl = 0.0001 endif bndx = (zl / xl) < 1.0 if bndx if zm == 0 || zm == 3 value = 0 elseif zm == 2 || zm == 5 value = 1 elseif zm == 1 || zm == 4 value = 2 endif else if zm == 0 || zm == 3 value = 2 elseif zm == 2 || zm == 5 value = 0 elseif zm == 1 || zm == 4 value = 1 endif endif endif #index = value / 3 elseif @pattern == 2 float value = 0.5 float mw = @bm / @bw float mh = @bm / @bh float by = y / @bh int iby = trunc(by) by = by - iby if (by < 0.0) by = by + 1.0 endif if (by <= mh) value = 0 endif by = (y / @bh) * 0.5 iby = trunc(by) by = by - iby if (by < 0.0) by = by + 1.0 endif float bx = (x / @bw) int ibx = trunc(bx) bx = bx - ibx if (bx < 0.0) bx = bx + 1.0 endif if (bx <= mw) && (by <= 0.5) value = 0.0 endif bx = (x / @bw) + 0.5 ibx = trunc(bx) bx = bx - ibx if (bx < 0.0) bx = bx + 1.0 endif if ((bx <= mw) && (by > 0.5)) value = 0 endif #index = value elseif @pattern == 3 float t1 = sin(x * 5) float t2 = sin(y * 5) #index = sqr((t1 + t2) / 2) endif default: title = "Patterns" param pattern caption = "Pattern" enum = "Checker" "Hexagon" "Brick" "Leopard" endparam param size caption = "Size" default = 1.0 endparam param bw caption = "Brick Width" default = 1.0 endparam param bh caption = "Brick Height" default = 0.5 endparam param bm caption = "Mortar Width" default = 0.05 endparam } mt-weave { ; Mark Townsend, 15 November 2000 final: float this = 0 float that = 0 float x = 4096 + real(#z) * @size float y = 4096 + imag(#z) * @size int xi = floor(x) int yi = floor(y) float xr = x - xi float yr = y - yi float s = (1 - @width) / 2 if @shading == 0 this = yr that = xr else this = xr that = yr endif if (xi + yi) % 2 == 0 if (yr > s)&& (yr < 1 - s) #index = this else if (xr > s)&& (xr < 1 - s) #index = that else #solid = true endif endif else if (xr > s) && (xr < 1 - s) #index = that else if (yr > s) && (yr < 1 - s) #index = this else #solid = true endif endif endif default: title = "Weave" param shading caption = "Shading" enum = "Thread" "Ribbon" endparam param width caption = "Width" default = 0.9 max = 1.0 endparam param size caption = "Scale" default = 1.0 endparam } mt-plasma-convolution { ; Mark Townsend, 21 April 2001 final: float endsum = 0 add = (0,0) float sum = 0 float coef = 0 float cosum = 0 int cell = 0 while cell < 9 float amplitude = 1.0 if cell == 0 add = -@dis + flip(-@dis) coef = @c0 elseif cell == 1 add = flip(-@dis) coef = @c1 elseif cell == 2 add = @dis + flip(-@dis) coef = @c2 elseif cell == 3 add = -@dis coef = @c3 elseif cell == 4 add = 0 coef = @c4 elseif cell == 5 add = @dis coef = @c5 elseif cell == 6 add = -@dis + flip(@dis) coef = @c6 elseif cell == 7 add = flip(@dis) coef = @c7 elseif cell == 8 add = @dis + flip(@dis) coef = @c8 endif cosum = cosum + coef complex p = (#z + add) * @scale + @offset sum = 0 int i = 0 if coef != 0 while i < @octaves float bx0 = floor(real(p)) float bx1 = bx0 + 1 float rx0 = real(p) - floor(real(p)) float rx1 = rx0 - 1 float by0 = floor(imag(p)) float by1 = by0 + 1 float ry0 = imag(p) - floor(imag(p)) float ry1 = ry0 - 1 ; Positive offset to stop reflection if bx0 < 0 bx0 = bx0 + 8192 endif if bx1 < 0 bx1 = bx1 + 8192 endif if by0 < 0 by0 = by0 + 8192 endif if by1 < 0 by1 = by1 + 8192 endif float sx = rx0 * rx0 * (3 - 2 * rx0) float sy = ry0 * ry0 * (3 - 2 * ry0) float b00 = (bx0^2 * 2473 % 65536 + by0)^2 % 65536 float b01 = (bx0^2 * 2473 % 65536 + by1)^2 % 65536 float b10 = (bx1^2 * 2473 % 65536 + by0)^2 % 65536 float b11 = (bx1^2 * 2473 % 65536 + by1)^2 % 65536 float g_b00_0 = b00^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b01_0 = b01^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b10_0 = b10^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b11_0 = b11^2 * 5381 % 65536 / 4 % 16384 - 8192 float g_b00_1 = (b00 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b01_1 = (b01 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b10_1 = (b10 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float g_b11_1 = (b11 + 1)^2 * 79997 % 65536 / 4 % 16384 - 8192 float s = sqrt(g_b00_0^2 + g_b00_1^2) g_b00_0 = g_b00_0 / s g_b00_1 = g_b00_1 / s s = sqrt(g_b01_0^2 + g_b01_1^2) g_b01_0 = g_b01_0 / s g_b01_1 = g_b01_1 / s s = sqrt(g_b10_0^2 + g_b10_1^2) g_b10_0 = g_b10_0 / s g_b10_1 = g_b10_1 / s s = sqrt(g_b11_0^2 + g_b11_1^2) g_b11_0 = g_b11_0 / s g_b11_1 = g_b11_1 / s float u1 = rx0 * g_b00_0 + ry0 * g_b00_1 float v1 = rx1 * g_b10_0 + ry0 * g_b10_1 float a = u1 + sx * (v1 - u1) float u2 = rx0 * g_b01_0 + ry1 * g_b01_1 float v2 = rx1 * g_b11_0 + ry1 * g_b11_1 float b = u2 + sx * (v2 - u2) sum = sum + real(@fn1(a + sy * (b - a))) * amplitude amplitude = amplitude * @persistence p = p / 0.5 + (1i * @t * sum) i = i + 1 endwhile endif cell = cell + 1 endsum = endsum + coef * ((sum + 1) * 0.5) endwhile if cosum == 0 cosum = 1 endif #index = endsum / cosum default: title = "Plasma Convolution" param octaves caption = "Octaves" default = 7 min = 1 endparam param persistence caption = "Persistence" default = 0.5 endparam param t caption = "Smear" default = 0.0 endparam param scale caption = "Scale" default = 1.0 endparam param offset caption = "Offset" default = (0,0) endparam param dis caption = "Sample Distance" default = 0.01 endparam param c0 caption = "NW" default = 1.0 endparam param c1 caption = "N" default = 1.0 endparam param c2 caption = "NE" default = 1.0 endparam param c3 caption = "W" default = 1.0 endparam param c4 caption = "Centre" default = -8.0 endparam param c5 caption = "E" default = 1.0 endparam param c6 caption = "SW" default = 1.0 endparam param c7 caption = "S" default = 1.0 endparam param c8 caption = "SE" default = 1.0 endparam func fn1 caption = "Noise function" default = abs() endfunc } mt-decomp-epsilon { ; Mark Townsend, 17 May 2001 ; Updated 14 July 2001 ; From a Fractint formula that I wrote in January 1999 init: s = 1e19 bool trapped = false tz = 0 int iter = 0 loop: if iter >= @skip if abs(real(#z)) < real(@width) || abs(imag(#z)) < imag(@width) tz = #z trapped = true elseif (|#z| < |s|) s = #z endif endif iter = iter + 1 final: complex i = 0 if trapped i = tz else if @masking #solid = true else i = s^0.1 endif endif float angle = atan2(i) if angle < 0 angle = angle + 2 * #pi endif #index = 1 / (2 * #pi) * angle default: title = "Decomp Epsilon" param width caption = "Stalk Width" default = (0.1, 0.1) endparam param skip caption = "Skip Iterations" default = 0 min = 0 endparam param masking caption = "Masking" default = false endparam } mt-ifs { ; Mark Townsend, 24 August 2001 - 10 July 2002 ; Michael Barnsley's Iterated Function Systems. ; Logarithmic scaling of hit frequency and the ; color orbit mode inspired by Scott Draves' ; Flame fractals. global: int seed = 1234567 ; Seed for random numbers int f = 0 ; Map number float clr = 0, int cx = 0 ; Color iterate int i = 0, int j = 0 ; Loop counters int x = 0, int y = 0 ; Loop counters & integer coords int pix[#width, #height] ; "Virtual screen" array float ifs[@maps, 7] ; Parameter array float ifsclr[@maps] ; Color orbit array float max = 0 ; Maximum color value float xx = 0, float yy = 0 ; Iterates from previous iteration float xnew = 0, float ynew = 0 ; Iterates float xc = real(#center) ; Scaling constants float yc = -imag(#center) ; Adjust scaling for aspect ratio if 3 * #width < 4 * #height float scale = (#width * #magn) / 4 else scale = (#height * #magn) / 3 endif ; Initialize screen array while x < #width y = 0 while y < #height pix[x, y] = 0 y = y + 1 endwhile x = x + 1 endwhile ; Fill parameter arrays with parameters ifs[0, 0] = @m1a, ifs[0, 1] = @m1b, ifs[0, 2] = @m1c ifs[0, 3] = @m1d, ifs[0, 4] = @m1e, ifs[0, 5] = @m1f ifs[0, 6] = @m1p ifs[1, 0] = @m2a, ifs[1, 1] = @m2b, ifs[1, 2] = @m2c ifs[1, 3] = @m2d, ifs[1, 4] = @m2e, ifs[1, 5] = @m2f ifs[1, 6] = @m2p if @maps >= 3 ifs[2, 0] = @m3a, ifs[2, 1] = @m3b, ifs[2, 2] = @m3c ifs[2, 3] = @m3d, ifs[2, 4] = @m3e, ifs[2, 5] = @m3f ifs[2, 6] = @m3p endif if @maps >= 4 ifs[3, 0] = @m4a, ifs[3, 1] = @m4b, ifs[3, 2] = @m4c ifs[3, 3] = @m4d, ifs[3, 4] = @m4e, ifs[3, 5] = @m4f ifs[3, 6] = @m4p endif if @maps >= 5 ifs[4, 0] = @m5a, ifs[4, 1] = @m5b, ifs[4, 2] = @m5c ifs[4, 3] = @m5d, ifs[4, 4] = @m5e, ifs[4, 5] = @m5f ifs[4, 6] = @m5p endif if @maps >= 6 ifs[5, 0] = @m6a, ifs[5, 1] = @m6b, ifs[5, 2] = @m6c ifs[5, 3] = @m6d, ifs[5, 4] = @m6e, ifs[5, 5] = @m6f ifs[5, 6] = @m6p endif if @maps >= 7 ifs[6, 0] = @m7a, ifs[6, 1] = @m7b, ifs[6, 2] = @m7c ifs[6, 3] = @m7d, ifs[6, 4] = @m7e, ifs[6, 5] = @m7f ifs[6, 6] = @m7p endif if @maps >= 8 ifs[7, 0] = @m8a, ifs[7, 1] = @m8b, ifs[7, 2] = @m8c ifs[7, 3] = @m8d, ifs[7, 4] = @m8e, ifs[7, 5] = @m8f ifs[7, 6] = @m8p endif if @maps >= 9 ifs[8, 0] = @m9a, ifs[8, 1] = @m9b, ifs[8, 2] = @m9c ifs[8, 3] = @m9d, ifs[8, 4] = @m9e, ifs[8, 5] = @m9f ifs[8, 6] = @m9p endif if @maps >= 10 ifs[9, 0] = @m10a, ifs[9, 1] = @m10b, ifs[9, 2] = @m10c ifs[9, 3] = @m10d, ifs[9, 4] = @m10e, ifs[9, 5] = @m10f ifs[9, 6] = @m10p endif if @maps >= 11 ifs[10, 0] = @m11a, ifs[10, 1] = @m11b, ifs[10, 2] = @m11c ifs[10, 3] = @m11d, ifs[10, 4] = @m11e, ifs[10, 5] = @m11f ifs[10, 6] = @m11p endif if @maps >= 12 ifs[11, 0] = @m12a, ifs[11, 1] = @m12b, ifs[11, 2] = @m12c ifs[11, 3] = @m12d, ifs[11, 4] = @m12e, ifs[11, 5] = @m12f ifs[11, 6] = @m12p, endif if @maps >= 13 ifs[12, 0] = @m13a, ifs[12, 1] = @m13b, ifs[12, 2] = @m13c ifs[12, 3] = @m13d, ifs[12, 4] = @m13e, ifs[12, 5] = @m13f ifs[12, 6] = @m13p endif if @maps >= 14 ifs[13, 0] = @m14a, ifs[13, 1] = @m14b, ifs[13, 2] = @m14c ifs[13, 3] = @m14d, ifs[13, 4] = @m14e, ifs[13, 5] = @m14f ifs[13, 6] = @m14p endif if @maps >= 15 ifs[14, 0] = @m15a, ifs[14, 1] = @m15b, ifs[14, 2] = @m15c ifs[14, 3] = @m15d, ifs[14, 4] = @m15e, ifs[14, 5] = @m15f ifs[14, 6] = @m15p endif if @maps >= 16 ifs[15, 0] = @m16a, ifs[15, 1] = @m16b, ifs[15, 2] = @m16c ifs[15, 3] = @m16d, ifs[15, 4] = @m16e, ifs[15, 5] = @m16f ifs[15, 6] = @m16p endif if @maps >= 17 ifs[16, 0] = @m17a, ifs[16, 1] = @m17b, ifs[16, 2] = @m17c ifs[16, 3] = @m17d, ifs[16, 4] = @m17e, ifs[16, 5] = @m17f ifs[16, 6] = @m17p endif if @maps >= 18 ifs[17, 0] = @m18a, ifs[17, 1] = @m18b, ifs[17, 2] = @m18c ifs[17, 3] = @m18d, ifs[17, 4] = @m18e, ifs[17, 5] = @m18f ifs[17, 6] = @m18p endif if @maps >= 19 ifs[18, 0] = @m19a, ifs[18, 1] = @m19b, ifs[18, 2] = @m19c ifs[18, 3] = @m19d, ifs[18, 4] = @m19e, ifs[18, 5] = @m19f ifs[18, 6] = @m19p endif if @maps >= 20 ifs[19, 0] = @m20a, ifs[19, 1] = @m20b, ifs[19, 2] = @m20c ifs[19, 3] = @m20d, ifs[19, 4] = @m20e, ifs[19, 5] = @m20f ifs[19, 6] = @m20p endif if @maps >= 21 ifs[20, 0] = @m21a, ifs[20, 1] = @m21b, ifs[20, 2] = @m21c ifs[20, 3] = @m21d, ifs[20, 4] = @m21e, ifs[20, 5] = @m21f ifs[20, 6] = @m21p endif if @maps >= 22 ifs[21, 0] = @m22a, ifs[21, 1] = @m22b, ifs[21, 2] = @m22c ifs[21, 3] = @m22d, ifs[21, 4] = @m22e, ifs[21, 5] = @m22f ifs[21, 6] = @m22p endif if @maps >= 23 ifs[22, 0] = @m23a, ifs[22, 1] = @m23b, ifs[22, 2] = @m23c ifs[22, 3] = @m23d, ifs[22, 4] = @m23e, ifs[22, 5] = @m23f ifs[22, 6] = @m23p endif if @maps >= 24 ifs[23, 0] = @m24a, ifs[23, 1] = @m24b, ifs[23, 2] = @m24c ifs[23, 3] = @m24d, ifs[23, 4] = @m24e, ifs[23, 5] = @m24f ifs[23, 6] = @m24p endif if @maps >= 25 ifs[24, 0] = @m25a, ifs[24, 1] = @m25b, ifs[24, 2] = @m25c ifs[24, 3] = @m25d, ifs[24, 4] = @m25e, ifs[24, 5] = @m25f ifs[24, 6] = @m25p endif if @maps >= 26 ifs[25, 0] = @m26a, ifs[25, 1] = @m26b, ifs[25, 2] = @m26c ifs[25, 3] = @m26d, ifs[25, 4] = @m26e, ifs[25, 5] = @m26f ifs[25, 6] = @m26p endif if @maps >= 27 ifs[26, 0] = @m27a, ifs[26, 1] = @m27b, ifs[26, 2] = @m27c ifs[26, 3] = @m27d, ifs[26, 4] = @m27e, ifs[26, 5] = @m27f ifs[26, 6] = @m27p endif if @maps >= 28 ifs[27, 0] = @m28a, ifs[27, 1] = @m28b, ifs[27, 2] = @m28c ifs[27, 3] = @m28d, ifs[27, 4] = @m28e, ifs[27, 5] = @m28f ifs[27, 6] = @m28p endif if @maps >= 29 ifs[28, 0] = @m29a, ifs[28, 1] = @m29b, ifs[28, 2] = @m29c ifs[28, 3] = @m29d, ifs[28, 4] = @m29e, ifs[28, 5] = @m29f ifs[28, 6] = @m29p endif if @maps >= 30 ifs[29, 0] = @m30a, ifs[29, 1] = @m30b, ifs[29, 2] = @m30c ifs[29, 3] = @m30d, ifs[29, 4] = @m30e, ifs[29, 5] = @m30f ifs[29, 6] = @m30p endif if @maps >= 31 ifs[30, 0] = @m31a, ifs[30, 1] = @m31b, ifs[30, 2] = @m31c ifs[30, 3] = @m31d, ifs[30, 4] = @m31e, ifs[30, 5] = @m31f ifs[30, 6] = @m31p endif if @maps >= 32 ifs[31, 0] = @m32a, ifs[31, 1] = @m32b, ifs[31, 2] = @m32c ifs[31, 3] = @m32d, ifs[31, 4] = @m32e, ifs[31, 5] = @m32f ifs[31, 6] = @m32p endif if @maps >= 33 ifs[32, 0] = @m33a, ifs[32, 1] = @m33b, ifs[32, 2] = @m33c ifs[32, 3] = @m33d, ifs[32, 4] = @m33e, ifs[32, 5] = @m33f ifs[32, 6] = @m33p endif if @maps >= 34 ifs[33, 0] = @m34a, ifs[33, 1] = @m34b, ifs[33, 2] = @m34c ifs[33, 3] = @m34d, ifs[33, 4] = @m34e, ifs[33, 5] = @m34f ifs[33, 6] = @m34p endif if @maps >= 35 ifs[34, 0] = @m35a, ifs[34, 1] = @m35b, ifs[34, 2] = @m35c ifs[34, 3] = @m35d, ifs[34, 4] = @m35e, ifs[34, 5] = @m35f ifs[34, 6] = @m35p endif if @maps == 36 ifs[35, 0] = @m36a, ifs[35, 1] = @m36b, ifs[35, 2] = @m36c ifs[35, 3] = @m36d, ifs[35, 4] = @m36e, ifs[35, 5] = @m36f ifs[35, 6] = @m36p endif ; Initialize color array if @colorby == "Color Orbit" if @maps <= 10 ifsclr[0] = 1 i = 1 while i < @maps ifsclr[i] = 0 i = i + 1 endwhile else i = 0 while i < @maps ifsclr[i] = ifs[i, 6] i = i + 1 endwhile endif endif i = 0 ; Main iteration loop int nsamples = #width * #height * @max while i < nsamples j = 0 seed = random(seed) float r = abs(seed / #randomrange) repeat ; Find map to use r = r - ifs[j, 6] f = j, j = j + 1 until (r < 0) || (j == @maps) if @colorby == "Color Orbit" clr = (clr + ifsclr[f]) / 2 cx = round(clr * 1000) if cx > max max = cx endif endif ; Calculate orbit xnew = ifs[f, 0] * xx + ifs[f, 1] * yy + ifs[f, 4] ynew = ifs[f, 2] * xx + ifs[f, 3] * yy + ifs[f, 5] xx = xnew yy = ynew ; Scale to screen x = round(((xx - xc) * cos(#angle) - (-yy - yc) * \ sin(#angle)) * scale + #width / 2) y = round(((xx - xc) * sin(#angle) + (-yy - yc) * \ cos(#angle)) * scale + #height / 2) ; Plot the point only if inside array if x >= 0 && x < #width && y >= 0 && y < #height if @colorby == "Hit Frequency" pix[x, y] = pix[x, y] + 1 if pix[x, y] > max max = pix[x, y] endif elseif (@colorby == "Color Orbit") pix[x, y] = cx else ; Map Number pix[x, y] = f + 1 endif endif i = i + 1 endwhile final: if @colorby == "Hit Frequency" #index = log(pix[#x, #y]) / log(max) elseif (@colorby == "Color Orbit") #index = pix[#x, #y] / max else ; Map Number #index = pix[#x, #y] / (@maps + 1) endif if @solid if pix[#x, #y] == 0 #solid = true endif endif default: title = "Iterated Function Systems" render = false int param max caption = "Sample Density" default = 50 min = 1 endparam int param colorby caption = "Color By" enum = "Hit Frequency" "Map Number" "Color Orbit" endparam bool param solid caption = "Solid Background" default = false endparam int param maps caption = "Number of Maps" default = 4 min = 2 max = 36 endparam bool param showmaps caption = "Show Maps" default = false endparam heading caption = "Map 1" visible = (@showmaps == true) endheading float param m1a caption = "a" default = 0 visible = (@showmaps == true) endparam float param m1b caption = "b" default = 0 visible = (@showmaps == true) endparam float param m1c caption = "c" default = 0 visible = (@showmaps == true) endparam float param m1d caption = "d" default = 0.16 visible = (@showmaps == true) endparam float param m1e caption = "e" default = 0 visible = (@showmaps == true) endparam float param m1f caption = "f" default = 0 visible = (@showmaps == true) endparam float param m1p caption = "p" default = 0.01 visible = (@showmaps == true) endparam heading caption = "Map 2" visible = (@showmaps == true) endheading float param m2a caption = "a" default = 0.85 visible = (@showmaps == true) endparam float param m2b caption = "b" default = 0.04 visible = (@showmaps == true) endparam float param m2c caption = "c" default = -0.04 visible = (@showmaps == true) endparam float param m2d caption = "d" default = 0.85 visible = (@showmaps == true) endparam float param m2e caption = "e" default = 0.0 visible = (@showmaps == true) endparam float param m2f caption = "f" default = 1.6 visible = (@showmaps == true) endparam float param m2p caption = "p" default = 0.85 visible = (@showmaps == true) endparam heading caption = "Map 3" visible = (@maps >= 3) && (@showmaps == true) endheading float param m3a caption = "a" default = 0.2 visible = (@maps >= 3) && (@showmaps == true) endparam float param m3b caption = "b" default = -0.26 visible = (@maps >= 3) && (@showmaps == true) endparam float param m3c caption = "c" default = 0.23 visible = (@maps >= 3) && (@showmaps == true) endparam float param m3d caption = "d" default = 0.22 visible = (@maps >= 3) && (@showmaps == true) endparam float param m3e caption = "e" default = 0.00 visible = (@maps >= 3) && (@showmaps == true) endparam float param m3f caption = "f" default = 1.6 visible = (@maps >= 3) && (@showmaps == true) endparam float param m3p caption = "p" default = 0.07 visible = (@maps >= 3) && (@showmaps == true) endparam heading caption = "Map 4" visible = (@maps >= 4) && (@showmaps == true) endheading float param m4a caption = "a" default = -0.15 visible = (@maps >= 4) && (@showmaps == true) endparam float param m4b caption = "b" default = 0.28 visible = (@maps >= 4) && (@showmaps == true) endparam float param m4c caption = "c" default = 0.26 visible = (@maps >= 4) && (@showmaps == true) endparam float param m4d caption = "d" default = 0.24 visible = (@maps >= 4) && (@showmaps == true) endparam float param m4e caption = "e" default = 0.00 visible = (@maps >= 4) && (@showmaps == true) endparam float param m4f caption = "f" default = 0.44 visible = (@maps >= 4) && (@showmaps == true) endparam float param m4p caption = "p" default = 0.07 visible = (@maps >= 4) && (@showmaps == true) endparam heading caption = "Map 5" visible = (@maps >= 5) && (@showmaps == true) endheading float param m5a caption = "a" default = 0 visible = (@maps >= 5) && (@showmaps == true) endparam float param m5b caption = "b" default = 0 visible = (@maps >= 5) && (@showmaps == true) endparam float param m5c caption = "c" default = 0 visible = (@maps >= 5) && (@showmaps == true) endparam float param m5d caption = "d" default = 0 visible = (@maps >= 5) && (@showmaps == true) endparam float param m5e caption = "e" default = 0 visible = (@maps >= 5) && (@showmaps == true) endparam float param m5f caption = "f" default = 0 visible = (@maps >= 5) && (@showmaps == true) endparam float param m5p caption = "p" default = 0 visible = (@maps >= 5) && (@showmaps == true) endparam heading caption = "Map 6" visible = (@maps >= 6) && (@showmaps == true) endheading float param m6a caption = "a" default = 0 visible = (@maps >= 6) && (@showmaps == true) endparam float param m6b caption = "b" default = 0 visible = (@maps >= 6) && (@showmaps == true) endparam float param m6c caption = "c" default = 0 visible = (@maps >= 6) && (@showmaps == true) endparam float param m6d caption = "d" default = 0 visible = (@maps >= 6) && (@showmaps == true) endparam float param m6e caption = "e" default = 0 visible = (@maps >= 6) && (@showmaps == true) endparam float param m6f caption = "f" default = 0 visible = (@maps >= 6) && (@showmaps == true) endparam float param m6p caption = "p" default = 0 visible = (@maps >= 6) && (@showmaps == true) endparam heading caption = "Map 7" visible = (@maps >= 7) && (@showmaps == true) endheading float param m7a caption = "a" default = 0 visible = (@maps >= 7) && (@showmaps == true) endparam float param m7b caption = "b" default = 0 visible = (@maps >= 7) && (@showmaps == true) endparam float param m7c caption = "c" default = 0 visible = (@maps >= 7) && (@showmaps == true) endparam float param m7d caption = "d" default = 0 visible = (@maps >= 7) && (@showmaps == true) endparam float param m7e caption = "e" default = 0 visible = (@maps >= 7) && (@showmaps == true) endparam float param m7f caption = "f" default = 0 visible = (@maps >= 7) && (@showmaps == true) endparam float param m7p caption = "p" default = 0 visible = (@maps >= 7) && (@showmaps == true) endparam heading caption = "Map 8" visible = (@maps >= 8) && (@showmaps == true) endheading float param m8a caption = "a" default = 0 visible = (@maps >= 8) && (@showmaps == true) endparam float param m8b caption = "b" default = 0 visible = (@maps >= 8) && (@showmaps == true) endparam float param m8c caption = "c" default = 0 visible = (@maps >= 8) && (@showmaps == true) endparam float param m8d caption = "d" default = 0 visible = (@maps >= 8) && (@showmaps == true) endparam float param m8e caption = "e" default = 0 visible = (@maps >= 8) && (@showmaps == true) endparam float param m8f caption = "f" default = 0 visible = (@maps >= 8) && (@showmaps == true) endparam float param m8p caption = "p" default = 0 visible = (@maps >= 8) && (@showmaps == true) endparam heading caption = "Map 9" visible = (@maps >= 9) && (@showmaps == true) endheading float param m9a caption = "a" default = 0 visible = (@maps >= 9) && (@showmaps == true) endparam float param m9b caption = "b" default = 0 visible = (@maps >= 9) && (@showmaps == true) endparam float param m9c caption = "c" default = 0 visible = (@maps >= 9) && (@showmaps == true) endparam float param m9d caption = "d" default = 0 visible = (@maps >= 9) && (@showmaps == true) endparam float param m9e caption = "e" default = 0 visible = (@maps >= 9) && (@showmaps == true) endparam float param m9f caption = "f" default = 0 visible = (@maps >= 9) && (@showmaps == true) endparam float param m9p caption = "p" default = 0 visible = (@maps >= 9) && (@showmaps == true) endparam heading caption = "Map 10" visible = (@maps >= 10) && (@showmaps == true) endheading float param m10a caption = "a" default = 0 visible = (@maps >= 10) && (@showmaps == true) endparam float param m10b caption = "b" default = 0 visible = (@maps >= 10) && (@showmaps == true) endparam float param m10c caption = "c" default = 0 visible = (@maps >= 10) && (@showmaps == true) endparam float param m10d caption = "d" default = 0 visible = (@maps >= 10) && (@showmaps == true) endparam float param m10e caption = "e" default = 0 visible = (@maps >= 10) && (@showmaps == true) endparam float param m10f caption = "f" default = 0 visible = (@maps >= 10) && (@showmaps == true) endparam float param m10p caption = "p" default = 0 visible = (@maps >= 10) && (@showmaps == true) endparam heading caption = "Map 11" visible = (@maps >= 11) && (@showmaps == true) endheading float param m11a caption = "a" default = 0 visible = (@maps >= 11) && (@showmaps == true) endparam float param m11b caption = "b" default = 0 visible = (@maps >= 11) && (@showmaps == true) endparam float param m11c caption = "c" default = 0 visible = (@maps >= 11) && (@showmaps == true) endparam float param m11d caption = "d" default = 0 visible = (@maps >= 11) && (@showmaps == true) endparam float param m11e caption = "e" default = 0 visible = (@maps >= 11) && (@showmaps == true) endparam float param m11f caption = "f" default = 0 visible = (@maps >= 11) && (@showmaps == true) endparam float param m11p caption = "p" default = 0 visible = (@maps >= 11) && (@showmaps == true) endparam heading caption = "Map 12" visible = (@maps >= 12) && (@showmaps == true) endheading float param m12a caption = "a" default = 0 visible = (@maps >= 12) && (@showmaps == true) endparam float param m12b caption = "b" default = 0 visible = (@maps >= 12) && (@showmaps == true) endparam float param m12c caption = "c" default = 0 visible = (@maps >= 12) && (@showmaps == true) endparam float param m12d caption = "d" default = 0 visible = (@maps >= 12) && (@showmaps == true) endparam float param m12e caption = "e" default = 0 visible = (@maps >= 12) && (@showmaps == true) endparam float param m12f caption = "f" default = 0 visible = (@maps >= 12) && (@showmaps == true) endparam float param m12p caption = "p" default = 0 visible = (@maps >= 12) && (@showmaps == true) endparam heading caption = "Map 13" visible = (@maps >= 13) && (@showmaps == true) endheading float param m13a caption = "a" default = 0 visible = (@maps >= 13) && (@showmaps == true) endparam float param m13b caption = "b" default = 0 visible = (@maps >= 13) && (@showmaps == true) endparam float param m13c caption = "c" default = 0 visible = (@maps >= 13) && (@showmaps == true) endparam float param m13d caption = "d" default = 0 visible = (@maps >= 13) && (@showmaps == true) endparam float param m13e caption = "e" default = 0 visible = (@maps >= 13) && (@showmaps == true) endparam float param m13f caption = "f" default = 0 visible = (@maps >= 13) && (@showmaps == true) endparam float param m13p caption = "p" default = 0 visible = (@maps >= 13) && (@showmaps == true) endparam heading caption = "Map 14" visible = (@maps >= 14) && (@showmaps == true) endheading float param m14a caption = "a" default = 0 visible = (@maps >= 14) && (@showmaps == true) endparam float param m14b caption = "b" default = 0 visible = (@maps >= 14) && (@showmaps == true) endparam float param m14c caption = "c" default = 0 visible = (@maps >= 14) && (@showmaps == true) endparam float param m14d caption = "d" default = 0 visible = (@maps >= 14) && (@showmaps == true) endparam float param m14e caption = "e" default = 0 visible = (@maps >= 14) && (@showmaps == true) endparam float param m14f caption = "f" default = 0 visible = (@maps >= 14) && (@showmaps == true) endparam float param m14p caption = "p" default = 0 visible = (@maps >= 14) && (@showmaps == true) endparam heading caption = "Map 15" visible = (@maps >= 15) && (@showmaps == true) endheading float param m15a caption = "a" default = 0 visible = (@maps >= 15) && (@showmaps == true) endparam float param m15b caption = "b" default = 0 visible = (@maps >= 15) && (@showmaps == true) endparam float param m15c caption = "c" default = 0 visible = (@maps >= 15) && (@showmaps == true) endparam float param m15d caption = "d" default = 0 visible = (@maps >= 15) && (@showmaps == true) endparam float param m15e caption = "e" default = 0 visible = (@maps >= 15) && (@showmaps == true) endparam float param m15f caption = "f" default = 0 visible = (@maps >= 15) && (@showmaps == true) endparam float param m15p caption = "p" default = 0 visible = (@maps >= 15) && (@showmaps == true) endparam heading caption = "Map 16" visible = (@maps >= 16) && (@showmaps == true) endheading float param m16a caption = "a" default = 0 visible = (@maps >= 16) && (@showmaps == true) endparam float param m16b caption = "b" default = 0 visible = (@maps >= 16) && (@showmaps == true) endparam float param m16c caption = "c" default = 0 visible = (@maps >= 16) && (@showmaps == true) endparam float param m16d caption = "d" default = 0 visible = (@maps >= 16) && (@showmaps == true) endparam float param m16e caption = "e" default = 0 visible = (@maps >= 16) && (@showmaps == true) endparam float param m16f caption = "f" default = 0 visible = (@maps >= 16) && (@showmaps == true) endparam float param m16p caption = "p" default = 0 visible = (@maps >= 16) && (@showmaps == true) endparam heading caption = "Map 17" visible = (@maps >= 17) && (@showmaps == true) endheading float param m17a caption = "a" default = 0 visible = (@maps >= 17) && (@showmaps == true) endparam float param m17b caption = "b" default = 0 visible = (@maps >= 17) && (@showmaps == true) endparam float param m17c caption = "c" default = 0 visible = (@maps >= 17) && (@showmaps == true) endparam float param m17d caption = "d" default = 0 visible = (@maps >= 17) && (@showmaps == true) endparam float param m17e caption = "e" default = 0 visible = (@maps >= 17) && (@showmaps == true) endparam float param m17f caption = "f" default = 0 visible = (@maps >= 17) && (@showmaps == true) endparam float param m17p caption = "p" default = 0 visible = (@maps >= 17) && (@showmaps == true) endparam heading caption = "Map 18" visible = (@maps >= 18) && (@showmaps == true) endheading float param m18a caption = "a" default = 0 visible = (@maps >= 18) && (@showmaps == true) endparam float param m18b caption = "b" default = 0 visible = (@maps >= 18) && (@showmaps == true) endparam float param m18c caption = "c" default = 0 visible = (@maps >= 18) && (@showmaps == true) endparam float param m18d caption = "d" default = 0 visible = (@maps >= 18) && (@showmaps == true) endparam float param m18e caption = "e" default = 0 visible = (@maps >= 18) && (@showmaps == true) endparam float param m18f caption = "f" default = 0 visible = (@maps >= 18) && (@showmaps == true) endparam float param m18p caption = "p" default = 0 visible = (@maps >= 18) && (@showmaps == true) endparam heading caption = "Map 19" visible = (@maps >= 19) && (@showmaps == true) endheading float param m19a caption = "a" default = 0 visible = (@maps >= 19) && (@showmaps == true) endparam float param m19b caption = "b" default = 0 visible = (@maps >= 19) && (@showmaps == true) endparam float param m19c caption = "c" default = 0 visible = (@maps >= 19) && (@showmaps == true) endparam float param m19d caption = "d" default = 0 visible = (@maps >= 19) && (@showmaps == true) endparam float param m19e caption = "e" default = 0 visible = (@maps >= 19) && (@showmaps == true) endparam float param m19f caption = "f" default = 0 visible = (@maps >= 19) && (@showmaps == true) endparam float param m19p caption = "p" default = 0 visible = (@maps >= 19) && (@showmaps == true) endparam heading caption = "Map 20" visible = (@maps >= 20) && (@showmaps == true) endheading float param m20a caption = "a" default = 0 visible = (@maps >= 20) && (@showmaps == true) endparam float param m20b caption = "b" default = 0 visible = (@maps >= 20) && (@showmaps == true) endparam float param m20c caption = "c" default = 0 visible = (@maps >= 20) && (@showmaps == true) endparam float param m20d caption = "d" default = 0 visible = (@maps >= 20) && (@showmaps == true) endparam float param m20e caption = "e" default = 0 visible = (@maps >= 20) && (@showmaps == true) endparam float param m20f caption = "f" default = 0 visible = (@maps >= 20) && (@showmaps == true) endparam float param m20p caption = "p" default = 0 visible = (@maps >= 20) && (@showmaps == true) endparam heading caption = "Map 21" visible = (@maps >= 21) && (@showmaps == true) endheading float param m21a caption = "a" default = 0 visible = (@maps >= 21) && (@showmaps == true) endparam float param m21b caption = "b" default = 0 visible = (@maps >= 21) && (@showmaps == true) endparam float param m21c caption = "c" default = 0 visible = (@maps >= 21) && (@showmaps == true) endparam float param m21d caption = "d" default = 0 visible = (@maps >= 21) && (@showmaps == true) endparam float param m21e caption = "e" default = 0 visible = (@maps >= 21) && (@showmaps == true) endparam float param m21f caption = "f" default = 0 visible = (@maps >= 21) && (@showmaps == true) endparam float param m21p caption = "p" default = 0 visible = (@maps >= 21) && (@showmaps == true) endparam heading caption = "Map 22" visible = (@maps >= 22) && (@showmaps == true) endheading float param m22a caption = "a" default = 0 visible = (@maps >= 22) && (@showmaps == true) endparam float param m22b caption = "b" default = 0 visible = (@maps >= 22) && (@showmaps == true) endparam float param m22c caption = "c" default = 0 visible = (@maps >= 22) && (@showmaps == true) endparam float param m22d caption = "d" default = 0 visible = (@maps >= 22) && (@showmaps == true) endparam float param m22e caption = "e" default = 0 visible = (@maps >= 22) && (@showmaps == true) endparam float param m22f caption = "f" default = 0 visible = (@maps >= 22) && (@showmaps == true) endparam float param m22p caption = "p" default = 0 visible = (@maps >= 22) && (@showmaps == true) endparam heading caption = "Map 23" visible = (@maps >= 23) && (@showmaps == true) endheading float param m23a caption = "a" default = 0 visible = (@maps >= 23) && (@showmaps == true) endparam float param m23b caption = "b" default = 0 visible = (@maps >= 23) && (@showmaps == true) endparam float param m23c caption = "c" default = 0 visible = (@maps >= 23) && (@showmaps == true) endparam float param m23d caption = "d" default = 0 visible = (@maps >= 23) && (@showmaps == true) endparam float param m23e caption = "e" default = 0 visible = (@maps >= 23) && (@showmaps == true) endparam float param m23f caption = "f" default = 0 visible = (@maps >= 23) && (@showmaps == true) endparam float param m23p caption = "p" default = 0 visible = (@maps >= 23) && (@showmaps == true) endparam heading caption = "Map 24" visible = (@maps >= 24) && (@showmaps == true) endheading float param m24a caption = "a" default = 0 visible = (@maps >= 24) && (@showmaps == true) endparam float param m24b caption = "b" default = 0 visible = (@maps >= 24) && (@showmaps == true) endparam float param m24c caption = "c" default = 0 visible = (@maps >= 24) && (@showmaps == true) endparam float param m24d caption = "d" default = 0 visible = (@maps >= 24) && (@showmaps == true) endparam float param m24e caption = "e" default = 0 visible = (@maps >= 24) && (@showmaps == true) endparam float param m24f caption = "f" default = 0 visible = (@maps >= 24) && (@showmaps == true) endparam float param m24p caption = "p" default = 0 visible = (@maps >= 24) && (@showmaps == true) endparam heading caption = "Map 25" visible = (@maps >= 25) && (@showmaps == true) endheading float param m25a caption = "a" default = 0 visible = (@maps >= 25) && (@showmaps == true) endparam float param m25b caption = "b" default = 0 visible = (@maps >= 25) && (@showmaps == true) endparam float param m25c caption = "c" default = 0 visible = (@maps >= 25) && (@showmaps == true) endparam float param m25d caption = "d" default = 0 visible = (@maps >= 25) && (@showmaps == true) endparam float param m25e caption = "e" default = 0 visible = (@maps >= 25) && (@showmaps == true) endparam float param m25f caption = "f" default = 0 visible = (@maps >= 25) && (@showmaps == true) endparam float param m25p caption = "p" default = 0 visible = (@maps >= 25) && (@showmaps == true) endparam heading caption = "Map 26" visible = (@maps >= 26) && (@showmaps == true) endheading float param m26a caption = "a" default = 0 visible = (@maps >= 26) && (@showmaps == true) endparam float param m26b caption = "b" default = 0 visible = (@maps >= 26) && (@showmaps == true) endparam float param m26c caption = "c" default = 0 visible = (@maps >= 26) && (@showmaps == true) endparam float param m26d caption = "d" default = 0 visible = (@maps >= 26) && (@showmaps == true) endparam float param m26e caption = "e" default = 0 visible = (@maps >= 26) && (@showmaps == true) endparam float param m26f caption = "f" default = 0 visible = (@maps >= 26) && (@showmaps == true) endparam float param m26p caption = "p" default = 0 visible = (@maps >= 26) && (@showmaps == true) endparam heading caption = "Map 27" visible = (@maps >= 27) && (@showmaps == true) endheading float param m27a caption = "a" default = 0 visible = (@maps >= 27) && (@showmaps == true) endparam float param m27b caption = "b" default = 0 visible = (@maps >= 27) && (@showmaps == true) endparam float param m27c caption = "c" default = 0 visible = (@maps >= 27) && (@showmaps == true) endparam float param m27d caption = "d" default = 0 visible = (@maps >= 27) && (@showmaps == true) endparam float param m27e caption = "e" default = 0 visible = (@maps >= 27) && (@showmaps == true) endparam float param m27f caption = "f" default = 0 visible = (@maps >= 27) && (@showmaps == true) endparam float param m27p caption = "p" default = 0 visible = (@maps >= 27) && (@showmaps == true) endparam heading caption = "Map 28" visible = (@maps >= 28) && (@showmaps == true) endheading float param m28a caption = "a" default = 0 visible = (@maps >= 28) && (@showmaps == true) endparam float param m28b caption = "b" default = 0 visible = (@maps >= 28) && (@showmaps == true) endparam float param m28c caption = "c" default = 0 visible = (@maps >= 28) && (@showmaps == true) endparam float param m28d caption = "d" default = 0 visible = (@maps >= 28) && (@showmaps == true) endparam float param m28e caption = "e" default = 0 visible = (@maps >= 28) && (@showmaps == true) endparam float param m28f caption = "f" default = 0 visible = (@maps >= 28) && (@showmaps == true) endparam float param m28p caption = "p" default = 0 visible = (@maps >= 28) && (@showmaps == true) endparam heading caption = "Map 29" visible = (@maps >= 29) && (@showmaps == true) endheading float param m29a caption = "a" default = 0 visible = (@maps >= 29) && (@showmaps == true) endparam float param m29b caption = "b" default = 0 visible = (@maps >= 29) && (@showmaps == true) endparam float param m29c caption = "c" default = 0 visible = (@maps >= 29) && (@showmaps == true) endparam float param m29d caption = "d" default = 0 visible = (@maps >= 29) && (@showmaps == true) endparam float param m29e caption = "e" default = 0 visible = (@maps >= 29) && (@showmaps == true) endparam float param m29f caption = "f" default = 0 visible = (@maps >= 29) && (@showmaps == true) endparam float param m29p caption = "p" default = 0 visible = (@maps >= 29) && (@showmaps == true) endparam heading caption = "Map 30" visible = (@maps >= 30) && (@showmaps == true) endheading float param m30a caption = "a" default = 0 visible = (@maps >= 30) && (@showmaps == true) endparam float param m30b caption = "b" default = 0 visible = (@maps >= 30) && (@showmaps == true) endparam float param m30c caption = "c" default = 0 visible = (@maps >= 30) && (@showmaps == true) endparam float param m30d caption = "d" default = 0 visible = (@maps >= 30) && (@showmaps == true) endparam float param m30e caption = "e" default = 0 visible = (@maps >= 30) && (@showmaps == true) endparam float param m30f caption = "f" default = 0 visible = (@maps >= 30) && (@showmaps == true) endparam float param m30p caption = "p" default = 0 visible = (@maps >= 30) && (@showmaps == true) endparam heading caption = "Map 31" visible = (@maps >= 31) && (@showmaps == true) endheading float param m31a caption = "a" default = 0 visible = (@maps >= 31) && (@showmaps == true) endparam float param m31b caption = "b" default = 0 visible = (@maps >= 31) && (@showmaps == true) endparam float param m31c caption = "c" default = 0 visible = (@maps >= 31) && (@showmaps == true) endparam float param m31d caption = "d" default = 0 visible = (@maps >= 31) && (@showmaps == true) endparam float param m31e caption = "e" default = 0 visible = (@maps >= 31) && (@showmaps == true) endparam float param m31f caption = "f" default = 0 visible = (@maps >= 31) && (@showmaps == true) endparam float param m31p caption = "p" default = 0 visible = (@maps >= 31) && (@showmaps == true) endparam heading caption = "Map 32" visible = (@maps >= 32) && (@showmaps == true) endheading float param m32a caption = "a" default = 0 visible = (@maps >= 32) && (@showmaps == true) endparam float param m32b caption = "b" default = 0 visible = (@maps >= 32) && (@showmaps == true) endparam float param m32c caption = "c" default = 0 visible = (@maps >= 32) && (@showmaps == true) endparam float param m32d caption = "d" default = 0 visible = (@maps >= 32) && (@showmaps == true) endparam float param m32e caption = "e" default = 0 visible = (@maps >= 32) && (@showmaps == true) endparam float param m32f caption = "f" default = 0 visible = (@maps >= 32) && (@showmaps == true) endparam float param m32p caption = "p" default = 0 visible = (@maps >= 32) && (@showmaps == true) endparam heading caption = "Map 33" visible = (@maps >= 33) && (@showmaps == true) endheading float param m33a caption = "a" default = 0 visible = (@maps >= 33) && (@showmaps == true) endparam float param m33b caption = "b" default = 0 visible = (@maps >= 33) && (@showmaps == true) endparam float param m33c caption = "c" default = 0 visible = (@maps >= 33) && (@showmaps == true) endparam float param m33d caption = "d" default = 0 visible = (@maps >= 33) && (@showmaps == true) endparam float param m33e caption = "e" default = 0 visible = (@maps >= 33) && (@showmaps == true) endparam float param m33f caption = "f" default = 0 visible = (@maps >= 33) && (@showmaps == true) endparam float param m33p caption = "p" default = 0 visible = (@maps >= 33) && (@showmaps == true) endparam heading caption = "Map 34" visible = (@maps >= 34) && (@showmaps == true) endheading float param m34a caption = "a" default = 0 visible = (@maps >= 34) && (@showmaps == true) endparam float param m34b caption = "b" default = 0 visible = (@maps >= 34) && (@showmaps == true) endparam float param m34c caption = "c" default = 0 visible = (@maps >= 34) && (@showmaps == true) endparam float param m34d caption = "d" default = 0 visible = (@maps >= 34) && (@showmaps == true) endparam float param m34e caption = "e" default = 0 visible = (@maps >= 34) && (@showmaps == true) endparam float param m34f caption = "f" default = 0 visible = (@maps >= 34) && (@showmaps == true) endparam float param m34p caption = "p" default = 0 visible = (@maps >= 34) && (@showmaps == true) endparam heading caption = "Map 35" visible = (@maps >= 35) && (@showmaps == true) endheading float param m35a caption = "a" default = 0 visible = (@maps >= 35) && (@showmaps == true) endparam float param m35b caption = "b" default = 0 visible = (@maps >= 35) && (@showmaps == true) endparam float param m35c caption = "c" default = 0 visible = (@maps >= 35) && (@showmaps == true) endparam float param m35d caption = "d" default = 0 visible = (@maps >= 35) && (@showmaps == true) endparam float param m35e caption = "e" default = 0 visible = (@maps >= 35) && (@showmaps == true) endparam float param m35f caption = "f" default = 0 visible = (@maps >= 35) && (@showmaps == true) endparam float param m35p caption = "p" default = 0 visible = (@maps >= 35) && (@showmaps == true) endparam heading caption = "Map 36" visible = (@maps >= 36) && (@showmaps == true) endheading float param m36a caption = "a" default = 0 visible = (@maps >= 36) && (@showmaps == true) endparam float param m36b caption = "b" default = 0 visible = (@maps >= 36) && (@showmaps == true) endparam float param m36c caption = "c" default = 0 visible = (@maps >= 36) && (@showmaps == true) endparam float param m36d caption = "d" default = 0 visible = (@maps >= 36) && (@showmaps == true) endparam float param m36e caption = "e" default = 0 visible = (@maps >= 36) && (@showmaps == true) endparam float param m36f caption = "f" default = 0 visible = (@maps >= 36) && (@showmaps == true) endparam float param m36p caption = "p" default = 0 visible = (@maps >= 36) && (@showmaps == true) endparam } mt-perlin-noise { ; Mark Townsend, 17 Nov 2000 ; Based on original code by Ken Perlin, ; with ideas from Damien M. Jones. global: int p[514] float g[514, 2] int i = 0 int j = 0 int k = 0 int seed = @seed while i < 256 p[i] = i j = 0 while j < 2 seed = random(seed) g[i, j] = seed / #randomrange j = j + 1 endwhile float s = sqrt(g[i, 0]* g[i, 0] + g[i, 1] * g[i, 1]) g[i, 0] = g[i, 0] / s g[i, 1] = g[i, 1] / s i = i + 1 endwhile i = 0 while i < 256 k = p[i] seed = random(seed) j = abs(seed) % 256 p[i] = p[j] p[j] = k i = i + 1 endwhile i = 0 while i < 256 p[256 + i] = p[i] j = 0 while j < 2 g[256 + i, j] = g[i, j] j = j + 1 endwhile i = i + 1 endwhile final: int iter = 0, float sum = 0 float amplitude = 1.0 r = (0,1) ^ (1/3) zr = (0,1) ^ (@angle / 90.0) w = #z * @scale * zr + @offset while iter < @octaves float t = real(w) % 4096 + 4096 int bx0 = floor(t) % 256 int bx1 = (bx0 + 1) % 256 float rx0 = t - floor(t) float rx1 = rx0 - 1 t = imag(w) % 4096 + 4096 int by0 = floor(t) % 256 int by1 = (by0 + 1) % 256 float ry0 = t - floor(t) float ry1 = ry0 - 1 int b00 = p[p[bx0] + by0] int b10 = p[p[bx1] + by0] int b01 = p[p[bx0] + by1] int b11 = p[p[bx1] + by1] float sx = (rx0 * rx0 * (3 - 2 * rx0)) float sy = (ry0 * ry0 * (3 - 2 * ry0)) float u = rx0 * g[b00, 0] + ry0 * g[b00, 1] float v = rx1 * g[b10, 0] + ry0 * g[b10, 1] float a = u + sx * (v - u) u = rx0 * g[b01, 0] + ry1 * g[b01, 1] v = rx1 * g[b11, 0] + ry1 * g[b11, 1] float b = u + sx * (v - u) sum = sum + real(@fn1(a + sy * (b - a))) * amplitude w = w * r / 0.5 amplitude = amplitude * @persistence iter = iter + 1 endwhile #index = (sum + 1) * 0.5 default: title = "Perlin Noise" param octaves caption = "Octaves" default = 7 min = 1 endparam param persistence caption = "Persistence" default = 0.5 endparam func fn1 caption = "Function" default = ident() endfunc param scale caption = "Scale" default = 1.0 endparam param offset caption = "Offset" default = (0,0) endparam float param angle caption = "Rotation" default = 0 endparam param @seed caption = "Random Seed" default = 1234567 endparam } mt-latoocarfian { ; Mark Townsend, 18 August 2001 ; Strange attractors from Clifford Pickover's ; book "Chaos in Wonderland" (the "De Jong" ; mutation uses similar equations from A. K. ; Dewdney's "The Armchair Universe".) global: float max = 0 int i = 0 float xx = 0, float yy = 0 float a = 0, float b = 0 float c = 0, float d = 0 int seed = @seed if !@rnd a = @a b = @b c = @c d = @d else ; We randomize the parameters in a loop ; until we find a set that has a reasonably ; high Lyapunov exponent. float L = -1 while L < @lthresh ; Parameters in the range (-3 < a, b < 3) ; and (0.5 < c, d < 1.5) seed = random(seed) a = (seed / #randomrange) * 3 seed = random(seed) b = (seed / #randomrange) * 3 seed = random(seed) c = (seed / #randomrange) + 0.5 seed = random(seed) d = (seed / #randomrange) + 0.5 float Lsum = 0 float lx = 0.1 float ly = 0.1 float xe = lx + 0.000001 float ye = ly i = 0 while i < 1000 ; Pickover suggests 10 million iterations, ; but this is enough to produce decent ; attractors if @mutation == "Standard" xx = sin(ly * b) + c * sin(lx * b) yy = (sin(lx * a) + d * sin(ly * a)) elseif @mutation == "Alpha" xx = sin(ly * b) + sin(lx * b)^2 + sin(lx * b)^3 yy = sin(lx * a) + sin(ly * a)^2 + sin(ly * c)^3 elseif @mutation == "Beta" xx = sin(ly * b) + sin(lx * b)^2 yy = sin(lx * a) + sin(ly * a)^2 elseif @mutation == "Gamma" xx = abs(sin(ly * b)) + sin(lx * b)^2 yy = abs(sin(lx * a)) + sin(ly * a)^2 elseif @mutation == "De Jong" xx = sin(ly * a) - cos(lx * b) yy = sin(lx * c) - cos(ly * d) endif float xsave = xx, float ysave = yy, lx = xe, ly = ye i = i + 1 if @mutation == "Standard" xx = sin(ly * b) + c * sin(lx * b) yy = (sin(lx * a) + d * sin(ly * a)) elseif @mutation == "Alpha" xx = sin(ly * b) + sin(lx * b)^2 + sin(lx * b)^3 yy = sin(lx * a) + sin(ly * a)^2 + sin(ly * c)^3 elseif @mutation == "Beta" xx = sin(ly * b) + sin(lx * b)^2 yy = sin(lx * a) + sin(ly * a)^2 elseif @mutation == "Gamma" xx = abs(sin(ly * b)) + sin(lx * b)^2 yy = abs(sin(lx * a)) + sin(ly * a)^2 elseif @mutation == "De Jong" xx = sin(ly * a) - cos(lx * b) yy = sin(lx * c) - cos(ly * d) endif float dLx = xx - xsave, float dLy = yy - ysave float dL2 = dLx * dLx + dLy * dLy float df = 1000000000000. * dL2 float rs = 1/sqrt(df) xe = xsave + rs * (xx - xsave) ye = ysave + rs * (yy - ysave) xx = xsave, yy = ysave Lsum = Lsum + log(df) L = 0.721347 * lsum / i lx = xx ly = yy endwhile endwhile endif int pix[#width, #height] if 3 * #width < 4 * #height float scale = (#width * #magn) / 4 else scale = (#height * #magn) / 3 endif int x = 0, int y = 0 ; initialize array while x < #width y = 0 while y < #height pix[x, y] = 0 y = y + 1 endwhile x = x + 1 endwhile float xnew = 0 float ynew = 0 xx = 0.1 yy = 0.1 i = 0 int iters = #width * #height * @max while i < iters if @mutation == "Standard" xnew = sin(yy * b) + c * sin(xx * b) ynew = (sin(xx * a) + d * sin(yy * a)) elseif @mutation == "Alpha" xnew = sin(yy * b) + sin(xx * b)^2 + sin(xx * b)^3 ynew = sin(xx * a) + sin(yy * a)^2 + sin(yy * c)^3 elseif @mutation == "Beta" xnew = sin(yy * b) + sin(xx * b)^2 ynew = sin(xx * a) + sin(yy * a)^2 elseif @mutation == "Gamma" xnew = abs(sin(yy * b)) + sin(xx * b)^2 ynew = abs(sin(xx * a)) + sin(yy * a)^2 elseif @mutation == "De Jong" xnew = sin(yy * a) - cos(xx * b) ynew = sin(xx * c) - cos(yy * d) endif xx = xnew yy = ynew float xc = real(#center) float yc = imag(#center) x = round(((xx - xc) * cos(#angle) - (yy + yc) * \ sin(#angle)) * scale + #width / 2) y = round(((xx - xc) * sin(#angle) + (yy + yc) * \ cos(#angle)) * scale + #height / 2) ; plot the point only if inside array if x >= 0 && x < #width && y >= 0 && y < #height pix[x, y] = pix[x, y] + 1 if pix[x, y] > max max = pix[x, y] endif endif i = i + 1 endwhile final: #index = (log(pix[#x, #y])) / log(max) default: title = "Latööcarfian Attractors" render = false param mutation caption = "Mutation" enum = "Standard" "Alpha" "Beta" "Gamma" "De Jong" endparam int param max caption = "Sample Density" default = 30 min = 1 endparam float param a caption = "a" default = -0.966918 visible = !@rnd endparam param b caption = "b" default = 2.879879 visible = !@rnd endparam float param c caption = "c" default = 0.765145 visible = !@rnd && (@mutation == "Standard" || \ @mutation == "Alpha" || @mutation == "De Jong") endparam float param d caption = "d" default = 0.744728 visible = !@rnd && (@mutation == "Standard" || \ @mutation == "De Jong") endparam bool param rnd caption = "Random Parameters" default = false endparam float param lthresh caption = "Lyapunov" default = 0.3 visible = @rnd endparam int param seed caption = "Seed" default = 12345678 visible = @rnd endparam } mt-convoluted-traps { ; Mark Townsend, July 2001 init: ; Orbit trap variables trap_z = 0 int trap_iter = 0 float Px = 0.5 + @width float Py = 0.5 - @width float xabs float yabs float temp float x = 0 float y = 0 float min = 0 float index = 0 int iter = 0 bool trapped = false loop: if @exploring if ! trapped x = real(#z) y = imag(#z) xabs = abs(x) yabs = abs(y) if iter >= @low_iter && iter <= @high_iter ; within range if @trap == "Squares" if ((Xabs < Px) && (Xabs > Py) && (Yabs < Px) && (Yabs > Py)) float awr5 = abs(Xabs - 0.5) float awi5 = abs(Yabs - 0.5) if (awr5 <= awi5) temp = awr5 else temp = awi5 endif if !trapped && (temp < @width) trapped = true trap_z = #z trap_iter = iter min = temp endif endif elseif @trap == "Stalks" if Xabs <= Yabs temp = Xabs else temp = Yabs endif if !trapped && temp < @width trapped = true trap_z = #z min = temp trap_iter = iter endif elseif @trap == "Harlequin" complex a = @mul * atan(y / x) a = a * a + @hseed a = @fnh(1 - a) / a temp = abs(|#z| - |a|) if !trapped && (temp < @width) trapped = true trap_z = #z trap_iter = iter min = temp endif endif ; trap type endif ; iteration range iter = iter + 1 endif endif ; exploring final: if @fix float dis = @dis / #magn else dis = @dis endif if @exploring if trapped if @coloring == "Distance" index = min elseif @coloring == "Magnitude" index = cabs(trap_z) elseif @coloring == "Real" index = abs(real(trap_z)) elseif @coloring == "Imag" index = abs(imag(trap_z)) elseif @coloring == "Iteration" index = 0.1 * trap_iter elseif @coloring == "Angle" float angle = atan2(trap_z) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle index = angle endif #color = gradient(index) else #color = @back endif else color c float alpha = 0 float red = 0 float green = 0 float blue = 0 float dv = 0 ; summed divisor ; Array for sample points complex add[9] add[0] = -dis + flip(-dis) add[1] = flip(-dis) add[2] = dis + flip(-dis) add[3] = -dis add[4] = 0 add[5] = dis add[6] = -dis + flip(dis) add[7] = flip(dis) add[8] = dis + flip(dis) ; Initializing weights and setting up presets float sv[9] if @preset == "Custom" ; From parameters sv[0] = @s0, sv[1] = @s1, sv[2] = @s2 sv[3] = @s3, sv[4] = @s4, sv[5] = @s5 sv[6] = @s6, sv[7] = @s7, sv[8] = @s8 elseif @preset == "Center" ; For speed when changing parameters sv[0] = 0, sv[1] = 0, sv[2] = 0 sv[3] = 0, sv[4] = 1, sv[5] = 0 sv[6] = 0, sv[7] = 0, sv[8] = 0 elseif @preset == "Soften" sv[0] = 1, sv[1] = 1, sv[2] = 1 sv[3] = 1, sv[4] = 1, sv[5] = 1 sv[6] = 1, sv[7] = 1, sv[8] = 1 elseif @preset == "Edge Detect" sv[0] = 1, sv[1] = 1, sv[2] = 1 sv[3] = 1, sv[4] = -8, sv[5] = 1 sv[6] = 1, sv[7] = 1, sv[8] = 1 endif ; Main loop goes through each of the sample points int citer = 0 while citer < 9 if sv[citer] != 0 ; for speed we don't calculate if weight is zero dv = dv + sv[citer] ; summing weights z = #pixel + add[citer] ; adjust for sample point iter = 0 trapped = false ; Fractal iteration loop while (iter <= @max) && (|z| < @bailout) && !trapped ; Orbit trap x = real(z) y = imag(z) xabs = abs(x) yabs = abs(y) if iter >= @low_iter && iter <= @high_iter ; within range if @trap == "Squares" if ((Xabs < Px) && (Xabs > Py) && (Yabs < Px) && (Yabs > Py)) float awr5 = abs(Xabs - 0.5) float awi5 = abs(Yabs - 0.5) if (awr5 <= awi5) temp = awr5 else temp = awi5 endif if !trapped && (temp < @width) trapped = true trap_z = z trap_iter = iter min = temp endif endif elseif @trap == "Stalks" if Xabs <= Yabs temp = Xabs else temp = Yabs endif if !trapped && temp < @width trapped = true trap_z = z min = temp trap_iter = iter endif elseif @trap == "Harlequin" complex a = @mul * atan(y / x) a = a * a + @hseed a = @fnh(1 - a) / a temp = abs(|z| - |a|) if !trapped && (temp < @width) trapped = true trap_z = z trap_iter = iter min = temp endif endif ; trap type endif ; iteration range z = z^2 + @seed ; iterate fractal iter = iter + 1 endwhile ; end of fractal loop ; The "final" section for each point grabs the color and sums ; the red, green, blue and alpha components if trapped if @coloring == "Distance" index = min elseif @coloring == "Magnitude" index = cabs(trap_z) elseif @coloring == "Real" index = abs(real(trap_z)) elseif @coloring == "Imag" index = abs(imag(trap_z)) elseif @coloring == "Iteration" index = 0.1 * trap_iter elseif @coloring == "Angle" float angle = atan2(trap_z) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle index = angle endif c = gradient(index) else c = @back endif red = red + sv[citer] * red(c) green = green + sv[citer] * green(c) blue = blue + sv[citer] * blue(c) alpha = alpha + sv[citer] * alpha(c) endif citer = citer + 1 endwhile ; end convolution loop if dv == 0 ; can't divide by zero, of course dv = 1 endif ; Divide components with summed divisor red = red / dv green = green / dv blue = blue / dv alpha = alpha / dv if @trans == "None" #color = rgb(red, green, blue) elseif @trans == "Convolution" ; use convoluted alpha #color = rgba(red, green, blue, alpha) elseif @trans == "Luminance" ; construct color from components c = rgb(red, green, blue) ; grab the luminance alpha = lum(c) ; construct new color with luminance value used for alpha #color = rgba(red, green, blue, alpha) endif endif default: title = "Convoluted Traps (Direct)" heading caption = "Fractal" endheading bool param exploring caption = "Exploring Mode" default = true endparam int param max caption = "Maximum Iterations" default = 100 min = 1 endparam complex param seed caption = "Julia Seed" endparam float param bailout caption = "Bailout Value" default = 100 min = 0 endparam heading caption = "Orbit Trap" endheading param trap caption = "Trap Type" enum = "Squares" "Stalks" "Harlequin" endparam param coloring caption = "Coloring Mode" enum = "Distance" "Magnitude" "Real" "Imag" "Iteration" "Angle" endparam float param mul caption = "Mulitplier" default = 2 visible = @trap == "Harlequin" endparam param hseed caption = "Julia Seed" visible = @trap == "Harlequin" endparam func fnh caption = "Function" default = exp() visible = @trap == "Harlequin" endfunc param width caption = "Element Size" default = 0.1 endparam int param low_iter caption = "Lowest Iteration" default = 1 min = 0 endparam int param high_iter caption = "Highest Iteration" default = 100 endparam heading caption = "Convolution" visible = !@exploring endheading param preset caption = "Preset" enum = "Custom" "Center" "Soften" "Edge Detect" default = 1 visible = !@exploring endparam float param dis caption = "Sample Distance" default = 0.01 visible = !@exploring endparam bool param fix caption = "Fixed Width" default = true endparam float param s0 caption = "NW" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s1 caption = "N" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s2 caption = "NE" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s3 caption = "W" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s4 caption = "Centre" default = -8 visible = !@exploring && (@preset == "Custom") endparam float param s5 caption = "E" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s6 caption = "SW" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s7 caption = "S" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s8 caption = "SE" default = 1 visible = !@exploring && (@preset == "Custom") endparam heading caption = "Color Parameters" endheading color param back caption = "Background Color" default = rgba(0,0,0,1) endparam param trans caption = "Opacity" enum = "None" "Convolution" "Luminance" visible = !@exploring endparam } mt-textured-trap { ; Mark Townsend, January 2003 global: int p[514] float g[514, 2] int ia = 0 int j = 0 int k = 0 int seed = @nseed while ia < 256 p[ia] = ia j = 0 while j < 2 seed = random(seed) g[ia, j] = seed / #randomrange j = j + 1 endwhile float s = sqrt(g[ia, 0]* g[ia, 0] + g[ia, 1] * g[ia, 1]) g[ia, 0] = g[ia, 0] / s g[ia, 1] = g[ia, 1] / s ia = ia + 1 endwhile ia = 0 while ia < 256 k = p[ia] seed = random(seed) j = abs(seed) % 256 p[ia] = p[j] p[j] = k ia = ia + 1 endwhile ia = 0 while ia < 256 p[256 + ia] = p[ia] j = 0 while j < 2 g[256 + ia, j] = g[ia, j] j = j + 1 endwhile ia = ia + 1 endwhile init: ; Orbit trap variables float dist = 0 trap_z = 0 trap_p = 0 int trap_iter = 0 float x = 0 float min = 1e30 float index = 0 int iter = 0 int i float sum = 0 float amplitude = 0 float t = 0 complex w = 0 loop: iter = iter + 1 pnt = (#z / @scale) - @offset ; Iterate the Popcorn formula i = 0 x = real(pnt) y = imag(pnt) while i < @max_iterations xx = x x = x - @h * real(@fn1(y + @fn2(@a * y))) y = y - @h * real(@fn3(xx + @fn4(@b * xx))) i = i + 1 endwhile pnt = (x + flip(y)) + @offset dist = cabs(#z - pnt) if dist < min trap_z = #z trap_p = pnt min = dist trap_iter = iter endif final: if @coloring == "Distance" index = min elseif @coloring == "Magnitude" index = cabs(trap_z) elseif @coloring == "Real" index = abs(real(trap_z)) elseif @coloring == "Imag" index = abs(imag(trap_z)) elseif @coloring == "Iteration" index = 0.1 * trap_iter elseif @coloring == "Angle" float angle = atan2(trap_z) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle index = angle elseif @coloring == "Modulated Iter" index = ((trap_iter) % 8) / 8 endif ; duplicate standard color parameters complex w = 0 float t = 0 if @textured amplitude = 1.0 r = (0,1) ^ (1/3) if @initial == 0 w = #pixel elseif @initial == 1 w = trap_z elseif @initial == 2 w = trap_p endif zr = (0,1) ^ (@nangle / 90.0) w = w * @nscale * zr + @noffset iter = 0 sum = 0 while iter < @octaves float t = real(w) % 4096 + 4096 int bx0 = floor(t) % 256 int bx1 = (bx0 + 1) % 256 float rx0 = t - floor(t) float rx1 = rx0 - 1 t = imag(w) % 4096 + 4096 int by0 = floor(t) % 256 int by1 = (by0 + 1) % 256 float ry0 = t - floor(t) float ry1 = ry0 - 1 int b00 = p[p[bx0] + by0] int b10 = p[p[bx1] + by0] int b01 = p[p[bx0] + by1] int b11 = p[p[bx1] + by1] float sx = (rx0 * rx0 * (3 - 2 * rx0)) float sy = (ry0 * ry0 * (3 - 2 * ry0)) float u = rx0 * g[b00, 0] + ry0 * g[b00, 1] float v = rx1 * g[b10, 0] + ry0 * g[b10, 1] float a = u + sx * (v - u) u = rx0 * g[b01, 0] + ry1 * g[b01, 1] v = rx1 * g[b11, 0] + ry1 * g[b11, 1] float b = u + sx * (v - u) sum = sum + real(@fbmn1(a + sy * (b - a))) * amplitude w = w * r / 0.5 amplitude = amplitude * @persistence iter = iter + 1 endwhile t = (sum + 1) * 0.5 endif if @benabled #index = trunc(@fbands * (index + @amount * t)) / @fbands else #index = index + @amount * t endif default: title = "Textured Trap" heading caption = "Orbit Trap" endheading param coloring caption = "Coloring Mode" enum = "Distance" "Magnitude" "Real" "Imag" "Iteration" "Angle" "Modulated Iter" endparam param width caption = "Element Size" default = 0.1 ; Parameter never used! visible = false endparam param a caption = "Re Alpha" default = 3.0 endparam param b caption = "Im Alpha" default = 3.0 endparam func fn1 caption = "Re Popcorn #1" default = sin() endfunc func fn2 caption = "Re Popcorn #2" default = tan() endfunc func fn3 caption = "Im Popcorn #1" default = sin() endfunc func fn4 caption = "Im Popcorn #2" default = tan() endfunc param h caption = "Step Size" default = 0.05 hint = "This is step size for the Popcorn formula." endparam param max_iterations caption = "Iterations" default = 1 min = 1 endparam param @scale caption = "Scale" default = 0.5 endparam param offset caption = "Offset" default = (0,0) endparam heading caption = "Texture" endheading bool param textured caption = "Enabled" default = false endparam param initial caption = "Initialisation" enum = "Pixel" "Orbit" "Trap" visible = @textured endparam float param amount caption = "Amount" default = 0.1 visible = @textured endparam param octaves caption = "Octaves" default = 7 min = 1 visible = @textured endparam param persistence caption = "Persistence" default = 0.5 visible = @textured endparam func fbmn1 caption = "Function" default = ident() visible = @textured endfunc param nscale caption = "Scale" default = 1.0 visible = @textured endparam param noffset caption = "Offset" default = (0,0) visible = @textured endparam float param nangle caption = "Rotation" default = 0 visible = @textured endparam param @nseed caption = "Random Seed" default = 1234567 visible = @textured endparam heading caption = "Banding" endheading bool param benabled caption = "Enabled" default = false endparam int param fbands caption = "Band Factor" min = 1 default = 10 visible = @benabled == true endparam } mt-textured-trap-d { ; Mark Townsend, January 2003 global: int p[514] float g[514, 2] int ia = 0 int j = 0 int k = 0 int seed = @nseed while ia < 256 p[ia] = ia j = 0 while j < 2 seed = random(seed) g[ia, j] = seed / #randomrange j = j + 1 endwhile float s = sqrt(g[ia, 0]* g[ia, 0] + g[ia, 1] * g[ia, 1]) g[ia, 0] = g[ia, 0] / s g[ia, 1] = g[ia, 1] / s ia = ia + 1 endwhile ia = 0 while ia < 256 k = p[ia] seed = random(seed) j = abs(seed) % 256 p[ia] = p[j] p[j] = k ia = ia + 1 endwhile ia = 0 while ia < 256 p[256 + ia] = p[ia] j = 0 while j < 2 g[256 + ia, j] = g[ia, j] j = j + 1 endwhile ia = ia + 1 endwhile init: ; Orbit trap variables float dist = 0 trap_z = 0 trap_p = 0 int trap_iter = 0 float x = 0 float min = 1e30 float index = 1 int iter = 0 int i float sum = 0 float amplitude = 0 float t = 0 complex w = 0 loop: if @exploring iter = iter + 1 pnt = (#z / @scale) - @offset ; Iterate the Popcorn formula i = 0 x = real(pnt) y = imag(pnt) while i < @max_iterations xx = x x = x - @h * real(@fn1(y + @fn2(@a * y))) y = y - @h * real(@fn3(xx + @fn4(@b * xx))) i = i + 1 endwhile pnt = (x + flip(y)) + @offset dist = cabs(#z - pnt) if dist < min trap_z = #z trap_p = pnt min = dist trap_iter = iter endif endif ; exploring final: if @exploring if @coloring == "Distance" index = min elseif @coloring == "Magnitude" index = cabs(trap_z) elseif @coloring == "Real" index = abs(real(trap_z)) elseif @coloring == "Imag" index = abs(imag(trap_z)) elseif @coloring == "Iteration" index = 0.1 * trap_iter elseif @coloring == "Angle" float angle = atan2(trap_z) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle index = angle endif complex w = 0 float t = 0 if @textured amplitude = 1.0 r = (0,1) ^ (1/3) if @initial == 0 w = #pixel elseif @initial == 1 w = trap_z elseif @initial == 2 w = trap_p endif zr = (0,1) ^ (@nangle / 90.0) w = w * @nscale * zr + @noffset iter = 0 sum = 0 while iter < @octaves float t = real(w) % 4096 + 4096 int bx0 = floor(t) % 256 int bx1 = (bx0 + 1) % 256 float rx0 = t - floor(t) float rx1 = rx0 - 1 t = imag(w) % 4096 + 4096 int by0 = floor(t) % 256 int by1 = (by0 + 1) % 256 float ry0 = t - floor(t) float ry1 = ry0 - 1 int b00 = p[p[bx0] + by0] int b10 = p[p[bx1] + by0] int b01 = p[p[bx0] + by1] int b11 = p[p[bx1] + by1] float sx = (rx0 * rx0 * (3 - 2 * rx0)) float sy = (ry0 * ry0 * (3 - 2 * ry0)) float u = rx0 * g[b00, 0] + ry0 * g[b00, 1] float v = rx1 * g[b10, 0] + ry0 * g[b10, 1] float a = u + sx * (v - u) u = rx0 * g[b01, 0] + ry1 * g[b01, 1] v = rx1 * g[b11, 0] + ry1 * g[b11, 1] float b = u + sx * (v - u) sum = sum + real(@fbmn1(a + sy * (b - a))) * amplitude w = w * r / 0.5 amplitude = amplitude * @persistence iter = iter + 1 endwhile t = (sum + 1) * 0.5 endif #color = gradient(index + @amount * t) else color c float alpha = 0 float red = 0 float green = 0 float blue = 0 float dv = 0 ; summed divisor ; Array for sample points complex add[9] float dst = @dis / #magn add[0] = -dst + flip(-dst) add[1] = flip(-dst) add[2] = dst + flip(-dst) add[3] = -dst add[4] = 0 add[5] = dst add[6] = -dst + flip(dst) add[7] = flip(dst) add[8] = dst + flip(dst) ; Initializing weights and setting up presets float sv[9] if @preset == "Custom" ; From parameters sv[0] = @s0, sv[1] = @s1, sv[2] = @s2 sv[3] = @s3, sv[4] = @s4, sv[5] = @s5 sv[6] = @s6, sv[7] = @s7, sv[8] = @s8 elseif @preset == "Center" ; For speed when changing parameters sv[0] = 0, sv[1] = 0, sv[2] = 0 sv[3] = 0, sv[4] = 1, sv[5] = 0 sv[6] = 0, sv[7] = 0, sv[8] = 0 elseif @preset == "Soften" sv[0] = 1, sv[1] = 1, sv[2] = 1 sv[3] = 1, sv[4] = 1, sv[5] = 1 sv[6] = 1, sv[7] = 1, sv[8] = 1 elseif @preset == "Edge Detect" sv[0] = 1, sv[1] = 1, sv[2] = 1 sv[3] = 1, sv[4] = -8, sv[5] = 1 sv[6] = 1, sv[7] = 1, sv[8] = 1 endif ; Main loop goes through each of the sample points int citer = 0 while citer < 9 if sv[citer] != 0 ; for speed we don't calculate if weight is zero dv = dv + sv[citer] ; summing weights z = #pixel + add[citer] ; adjust for sample point iter = 0 ; Fractal iteration loop min = 1e30 while (iter <= @max) && (|z| < @bailout) pnt = (z / @scale) - @offset ; Iterate the Popcorn formula i = 0 x = real(pnt) y = imag(pnt) while i < @max_iterations xx = x x = x - @h * real(@fn1(y + @fn2(@a * y))) y = y - @h * real(@fn3(xx + @fn4(@b * xx))) i = i + 1 endwhile pnt = (x + flip(y)) + @offset dist = cabs(z - pnt) if dist < min && iter > 0 trap_z = z trap_p = pnt min = dist trap_iter = iter endif ; iterate fractal if @type == "Standard Julia" z = z^2 + @seed elseif @type == "Celtic Julia" z = z^2 z = z - real(z) + abs(real(z)) - @seed endif iter = iter + 1 endwhile ; The "final" section for each point grabs the color and sums ; the red, green, blue and alpha components if @coloring == "Distance" index = min elseif @coloring == "Magnitude" index = cabs(trap_z) elseif @coloring == "Real" index = abs(real(trap_z)) elseif @coloring == "Imag" index = abs(imag(trap_z)) elseif @coloring == "Iteration" index = 0.1 * trap_iter elseif @coloring == "Angle" float angle = atan2(trap_z) if angle < 0 angle = angle + 2 * #pi endif angle = 1 / (2 * #pi) * angle index = angle endif if @textured amplitude = 1.0 r = (0,1) ^ (1/3) if @initial == 0 w = #pixel + add[citer] elseif @initial == 1 w = trap_z elseif @initial == 2 w = trap_p endif zr = (0,1) ^ (@nangle / 90.0) w = w * @nscale * zr + @noffset iter = 0 sum = 0 while iter < @octaves float t = real(w) % 4096 + 4096 int bx0 = floor(t) % 256 int bx1 = (bx0 + 1) % 256 float rx0 = t - floor(t) float rx1 = rx0 - 1 t = imag(w) % 4096 + 4096 int by0 = floor(t) % 256 int by1 = (by0 + 1) % 256 float ry0 = t - floor(t) float ry1 = ry0 - 1 int b00 = p[p[bx0] + by0] int b10 = p[p[bx1] + by0] int b01 = p[p[bx0] + by1] int b11 = p[p[bx1] + by1] float sx = (rx0 * rx0 * (3 - 2 * rx0)) float sy = (ry0 * ry0 * (3 - 2 * ry0)) float u = rx0 * g[b00, 0] + ry0 * g[b00, 1] float v = rx1 * g[b10, 0] + ry0 * g[b10, 1] float a = u + sx * (v - u) u = rx0 * g[b01, 0] + ry1 * g[b01, 1] v = rx1 * g[b11, 0] + ry1 * g[b11, 1] float b = u + sx * (v - u) sum = sum + real(@fbmn1(a + sy * (b - a))) * amplitude w = w * r / 0.5 amplitude = amplitude * @persistence iter = iter + 1 endwhile t = (sum + 1) * 0.5 endif c = gradient(index + @amount * t) red = red + sv[citer] * red(c) green = green + sv[citer] * green(c) blue = blue + sv[citer] * blue(c) alpha = alpha + sv[citer] * alpha(c) endif citer = citer + 1 endwhile ; end convolution loop if dv == 0 ; can't divide by zero, of course dv = 1 endif ; Divide components with summed divisor red = red / dv green = green / dv blue = blue / dv alpha = alpha / dv if @trans == "None" #color = rgb(red, green, blue) elseif @trans == "Convolution" ; use convoluted alpha #color = rgba(red, green, blue, alpha) elseif @trans == "Luminance" ; construct color from components c = rgb(red, green, blue) ; grab the luminance alpha = lum(c) ; construct new color with luminance value used for alpha #color = rgba(red, green, blue, alpha) endif endif default: title = "Textured Trap (Direct)" heading caption = "Fractal" endheading bool param exploring caption = "Exploring Mode" default = true endparam param type caption = "Type" enum = "Standard Julia" "Celtic Julia" endparam int param max caption = "Maximum Iterations" default = 100 min = 1 endparam complex param seed caption = "Julia Seed" endparam float param bailout caption = "Bailout Value" default = 100 min = 0 endparam heading caption = "Orbit Trap" endheading param coloring caption = "Coloring Mode" enum = "Distance" "Magnitude" "Real" "Imag" "Iteration" "Angle" endparam param width caption = "Element Size" default = 0.1 endparam param a caption = "Re Alpha" default = 3.0 endparam param b caption = "Im Alpha" default = 3.0 endparam func fn1 caption = "Re Popcorn #1" default = sin() endfunc func fn2 caption = "Re Popcorn #2" default = tan() endfunc func fn3 caption = "Im Popcorn #1" default = sin() endfunc func fn4 caption = "Im Popcorn #2" default = tan() endfunc param h caption = "Step Size" default = 0.05 hint = "This is step size for the Popcorn formula." endparam param max_iterations caption = "Iterations" default = 1 min = 1 endparam param @scale caption = "Scale" default = 0.5 endparam param offset caption = "Offset" default = (0,0) endparam heading caption = "Convolution" visible = !@exploring endheading param preset caption = "Preset" enum = "Custom" "Center" "Soften" "Edge Detect" default = 1 visible = !@exploring endparam float param dis caption = "Sample Distance" default = 0.01 visible = !@exploring endparam float param s0 caption = "NW" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s1 caption = "N" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s2 caption = "NE" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s3 caption = "W" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s4 caption = "Centre" default = -8 visible = !@exploring && (@preset == "Custom") endparam float param s5 caption = "E" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s6 caption = "SW" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s7 caption = "S" default = 1 visible = !@exploring && (@preset == "Custom") endparam float param s8 caption = "SE" default = 1 visible = !@exploring && (@preset == "Custom") endparam param trans caption = "Opacity" enum = "None" "Convolution" "Luminance" visible = !@exploring endparam heading caption = "Texture" endheading bool param textured caption = "Enabled" default = false endparam param initial caption = "Initialisation" enum = "Pixel" "Orbit" "Trap" visible = @textured endparam float param amount caption = "Amount" default = 0.1 visible = @textured endparam param octaves caption = "Octaves" default = 7 min = 1 visible = @textured endparam param persistence caption = "Persistence" default = 0.5 visible = @textured endparam func fbmn1 caption = "Function" default = ident() visible = @textured endfunc param nscale caption = "Scale" default = 1.0 visible = @textured endparam param noffset caption = "Offset" default = (0,0) visible = @textured endparam float param nangle caption = "Rotation" default = 0 visible = @textured endparam param @nseed caption = "Random Seed" default = 1234567 visible = @textured endparam } mt-perlin-noise-3d { ; Mark Townsend, 17 Nov 2000 ; Based on original code by Ken Perlin, ; with ideas from Damien M. Jones. global: int p[514] float g[514, 3] int i = 0 int j = 0 int k = 0 int seed = @seed while i < 256 p[i] = i j = 0 while j < 3 seed = random(seed) g[i, j] = seed / #randomrange j = j + 1 endwhile float s = sqrt(g[i, 0] * g[i, 0] + g[i, 1] * \ g[i, 1] + g[i, 2] * g[i, 2]) g[i, 0] = g[i, 0] / s g[i, 1] = g[i, 1] / s g[i, 2] = g[i, 2] / s i = i + 1 endwhile i = 0 while i < 256 k = p[i] j = abs(seed) % 256 seed = random(seed) p[i] = p[j] p[j] = k i = i + 1 endwhile i = 0 while i < 256 p[256 + i] = p[i] j = 0 while j < 3 g[256 + i , j] = g[i, j] j = j + 1 endwhile i = i + 1 endwhile final: int iter = 0, float sum = 0 float amplitude = 1.0 r = (0,1) ^ (1/3) zr = (0,1) ^ (@angle / 90.0) w = #z * @scale * zr + @offset while iter < @octaves float t = real(w) % 4096 + 4096 int bx0 = floor(t) % 256 int bx1 = (bx0 + 1) % 256 float rx0 = t - floor(t) float rx1 = rx0 - 1 t = imag(w) % 4096 + 4096 int by0 = floor(t) % 256 int by1 = (by0 + 1) % 256 float ry0 = t - floor(t) float ry1 = ry0 - 1 t = @z % 4096 + 4096 int bz0 = floor(t) % 256 int bz1 = (bz0 + 1) % 256 float rz0 = t - floor(t) float rz1 = rz0 - 1 int b00 = p[p[bx0] + by0] int b10 = p[p[bx1] + by0] int b01 = p[p[bx0] + by1] int b11 = p[p[bx1] + by1] t = (rx0 * rx0 * (3.0 - 2.0 * rx0)) float sy = (ry0 * ry0 * (3.0 - 2.0 * ry0)) float sz = (rz0 * rz0 * (3.0 - 2.0 * rz0)) float u = (rx0 * g[b00 + bz0, 0] + ry0 * g[b00 + bz0, 1] + rz0 * g[b00 + bz0, 2]) float v = (rx1 * g[b10 + bz0, 0] + ry0 * g[b10 + bz0, 1] + rz0 * g[b10 + bz0, 2]) float a = (u + t * (v - u)) u = (rx0 * g[b01 + bz0, 0] + ry1 * g[b01 + bz0, 1] + rz0 * g[b01 + bz0, 2]) v = (rx1 * g[b11 + bz0, 0] + ry1 * g[b11 + bz0, 1] + rz0 * g[b11 + bz0, 2]) float b = (u + t * (v - u)) float c = (a + sy * (b - a)) u = (rx0 * g[b00 + bz1, 0] + ry0 * g[b00 + bz1, 1] + rz1 * g[b00 + bz1, 2]) v = (rx1 * g[b10 + bz1, 0] + ry0 * g[b10 + bz1, 1] + rz1 * g[b10 + bz1, 2]) a = (u + t * (v - u)) u = (rx0 * g[b01 + bz1, 0] + ry1 * g[b01 + bz1, 1] + rz1 * g[b01 + bz1, 2]) v = (rx1 * g[b11 + bz1, 0] + ry1 * g[b11 + bz1, 1] + rz1 * g[b11 + bz1, 2]) b = (u + t * (v - u)) float d = (a + sy *(b - a)) sum = sum + real(@fn1(c + sz * (d - c))) * amplitude w = w * r / 0.5 amplitude = amplitude * @persistence iter = iter + 1 endwhile #index = (sum + 1) * 0.5 default: title = "Perlin Noise 3D" param octaves caption = "Octaves" default = 7 min = 1 endparam param persistence caption = "Persistence" default = 0.5 endparam func fn1 caption = "Function" default = ident() endfunc param z caption = "Z Coordinate" default = 0.0 endparam param scale caption = "Scale" default = 1.0 endparam param offset caption = "Offset" default = (0,0) endparam float param angle caption = "Rotation" default = 0 endparam param @seed caption = "Random Seed" default = 1234567 endparam } mt-hodge { ; Mark Townsend, 31 October 2000 ; The Hodge cellular automaton rule ; from Rudy Rucker's CA Laboratory global: int c[@size, @size], int oc[@size, @size] int x = 0, int y = 0, int seed = @seed ; Fill array with random values while x < @size y = 0 while y < @size seed = random(seed) oc[x, y] = seed % @states y = y + 1 endwhile x = x + 1 endwhile ; Run CA int gen = 0 while gen < @max x = 0 while x < @size y = 0 while y < @size int l = (x + @size - 1) % @size int r = (x + 1) % @size int u = (y + @size - 1) % @size int d = (y + 1) % @size int nt = oc[x, u] int st = oc[x, d] int et = oc[l, y] int wt = oc[r, y] int ne = oc[r, u] int nw = oc[l, u] int se = oc[r, d] int sw = oc[l, d] int self = oc[x, y] int av = trunc((nt + st + et + wt + ne + nw + se + sw) / 8) float j = (@states - 1) / 6 float t = 0 if (self == (@states - 1)) t = 0 elseif (self == 0) if (av == 0) t = 0 elseif (av <= j) t = (j / 2) + 1 elseif (av <= (2 * j)) t = j elseif (av > (2 * j)) t = (j / 2) + 1 endif elseif ((self > 0) && (self < (@states - 1))) t = av + j; endif if (t > (@states - 1)) int new = (@states - 1); else int new = trunc(t); endif c[x, y] = new y = y + 1 endwhile x = x + 1 endwhile oc = c gen = gen + 1 endwhile if @filter ; Average neighbours x = 0 while x < @size y = 0 while y < @size int l = (x + @size - 1) % @size int r = (x + 1) % @size int u = (y + @size - 1) % @size int d = (y + 1) % @size int nt = oc[x, u] int st = oc[x, d] int et = oc[l, y] int wt = oc[r, y] int ne = oc[r, u] int nw = oc[l, u] int se = oc[r, d] int sw = oc[l, d] c[x, y] = round((4 * (nt + et + st + wt) + (ne + nw + se + sw)) / 20) y = y + 1 endwhile x = x + 1 endwhile endif final: float v0, float v1, float v2, float v3 float xx = (real(#z * @scale) % 4096 + 4096) % @size float yy = (imag(#z * @scale) % 4096 + 4096) % @size int bx0 = floor(xx), int bx1 = (bx0 + 1) % @size float rx0 = xx - bx0, int by0 = floor(yy) int by1 = (by0 + 1) % @size, float ry0 = yy - by0 if @interp == "None" #index = c[bx1, by1] / @states elseif @interp == "Linear" float sx = (rx0 * rx0 * (3 - 2 * rx0)) float sy = (ry0 * ry0 * (3 - 2 * ry0)) v0 = c[bx0, by0] + sx * (c[bx1, by0] - c[bx0, by0]) v1 = c[bx0, by1] + sx * (c[bx1, by1] - c[bx0, by1]) #index = (v0 + sy * (v1 - v0)) / @states elseif @interp == "Bilinear" v0 = c[bx0, by0] + rx0 * (c[bx1, by0] - c[bx0, by0]) v1 = c[bx0, by1] + rx0 * (c[bx1, by1] - c[bx0, by1]) #index = (v0 + ry0 * (v1 - v0)) / @states elseif @interp == "Bicubic" int bx2 = (bx0 + 2) % @size int by2 = (by0 + 2) % @size int mx1 = (bx0 - 1 + @size) % @size int my1 = (by0 - 1 + @size) % @size sx = (1 - 2 * rx0^2 + rx0^3) v0 = -rx0 * (1 - rx0)^2 * c[mx1, my1] + sx * c[bx0, my1] + rx0 * \ (1 + rx0 - rx0^2) * c[bx1, my1] - rx0^2 * (1 - rx0) * c[bx2, my1] v1 = -rx0 * (1 - rx0)^2 * c[mx1, by0]+ sx * c[bx0, by0] + rx0 * \ (1 + rx0 - rx0^2) * c[bx1, by0] - rx0^2 * (1 - rx0) * c[bx2, by0] v2 = -rx0 * (1 - rx0)^2 * c[mx1, by1] + sx * c[bx0, by1] + rx0 * \ (1 + rx0 - rx0^2) * c[bx1, by1] - rx0^2 * (1 - rx0) * c[bx2, by1] v3 = -rx0 * (1 - rx0)^2 * c[mx1, by2] + sx * c[bx0, by2] + rx0 * \ (1 + rx0 - rx0^2) * c[bx1, by2] - rx0^2 * (1 - rx0) * c[bx2, by2] #index = (-ry0 * (1 - ry0)^2 * v0 + (1 - 2 * ry0^2 + ry0^3) * v1 + \ ry0 * (1 + ry0 - ry0^2) * v2 + ry0^2 * (ry0 - 1) * v3) / @states endif default: title = "Hodge" int param states caption = "States" default = 32 endparam int param max caption = "Generations" default = 100 min = 1 endparam int param size caption = "World Size" default = 100 min = 10 endparam ; int param scale float param scale caption = "Scale" default = 100 ; min = 1 endparam bool param filter caption = "Soften" default = false endparam param interp caption = "Interpolation" enum = "None" "Linear" "Bilinear" "Bicubic" endparam int param seed caption = "Random Seed" default = 12345678 endparam } mt-vant { ; Mark Townsend, 24 February 2001 global: float c[@size, @size] int rule[@states] int locx = 0, int locy = 0 int dir = 2, int x = 0, int y = 0 int north = 0, int east = 1 int south = 2, int west = 3 int left = 0, int right = 1 int seed = @seed ; Fill rule table with random values while x < @states seed = random(seed) rule[x] = trunc(abs(seed / (#randomrange / 3))) % 2 x = x + 1 endwhile ; Initialize array to zero x = 0 while x < @size y = 0 while y < @size c[x, y] = 0 y = y + 1 endwhile x = x + 1 endwhile ; Run vants int cell = 0 int turn = 0 int gen = 0 while gen < @max ; look at current cell cell = trunc(c[locx, locy] ) ; increment current cell c[locx, locy] = (cell + 1) % @states turn = rule[cell] if dir == north if turn == left dir = west locx = (locx + @size - 1) % @size elseif turn == right dir = east locx = (locx + 1) % @size endif elseif dir == east if turn == left dir = north locy = (locy + @size - 1) % @size elseif turn == right dir = south locy = (locy + 1) % @size endif elseif dir == south if turn == left dir = east locx = (locx + 1) % @size elseif turn == right dir = west locx = (locx + @size - 1) % @size endif elseif dir == west if turn == left dir = south locy = (locy + 1) % @size elseif turn == right dir = north locy = (locy + @size - 1) % @size endif endif gen = gen + 1 endwhile x = 0 while x < @size y = 0 while y < @size c[x, y] = c[x, y] / @states y = y + 1 endwhile x = x + 1 endwhile final: float noise = 0 float v0, float v1, float v2, float v3 int iter = 0, float sum = 0 float amplitude = 1.0 rr = (0,1) ^ (@rot / 90.0) zr = (0,1) ^ (@angle / 90.0) w = #z * @scale * zr + @offset while iter < @octaves float xx = real(w) % 4096 + 4096 int bx0 = floor(xx) % @size int bx1 = (bx0 + 1) % @size float rx0 = xx - floor(xx) float yy = imag(w) % 4096 + 4096 int by0 = floor(yy) % @size int by1 = (by0 + 1) % @size float ry0 = yy - floor(yy) if @interp == "None" noise = c[bx1, by1] elseif @interp == "Linear" float sx = (rx0 * rx0 * (3 - 2 * rx0)) float sy = (ry0 * ry0 * (3 - 2 * ry0)) v0 = c[bx0, by0] + sx * (c[bx1, by0] - c[bx0, by0]) v1 = c[bx0, by1] + sx * (c[bx1, by1] - c[bx0, by1]) noise = (v0 + sy * (v1 - v0)) ;/ @states elseif @interp == "Bilinear" v0 = c[bx0, by0] + rx0 * (c[bx1, by0] - c[bx0, by0]) v1 = c[bx0, by1] + rx0 * (c[bx1, by1] - c[bx0, by1]) noise = (v0 + ry0 * (v1 - v0)) ;/ @states elseif @interp == "Bicubic" int bx2 = (bx0 + 2) % @size int by2 = (by0 + 2) % @size int mx1 = (bx0 - 1 + @size) % @size int my1 = (by0 - 1 + @size) % @size sx = (1 - 2 * rx0^2 + rx0^3) v0 = -rx0 * (1 - rx0)^2 * c[mx1, my1] + sx * c[bx0, my1] + rx0 * \ (1 + rx0 - rx0^2) * c[bx1, my1] - rx0^2 * (1 - rx0) * c[bx2, my1] v1 = -rx0 * (1 - rx0)^2 * c[mx1, by0]+ sx * c[bx0, by0] + rx0 * \ (1 + rx0 - rx0^2) * c[bx1, by0] - rx0^2 * (1 - rx0) * c[bx2, by0] v2 = -rx0 * (1 - rx0)^2 * c[mx1, by1] + sx * c[bx0, by1] + rx0 * \ (1 + rx0 - rx0^2) * c[bx1, by1] - rx0^2 * (1 - rx0) * c[bx2, by1] v3 = -rx0 * (1 - rx0)^2 * c[mx1, by2] + sx * c[bx0, by2] + rx0 * \ (1 + rx0 - rx0^2) * c[bx1, by2] - rx0^2 * (1 - rx0) * c[bx2, by2] noise = ((-ry0 * (1 - ry0)^2 * v0 + (1 - 2 * ry0^2 + ry0^3) * v1 + \ ry0 * (1 + ry0 - ry0^2) * v2 + ry0^2 * (ry0 - 1) * v3)) ;/ @states endif sum = sum + noise * amplitude w = w * rr / 0.5 amplitude = amplitude * @persistence iter = iter + 1 endwhile #index = (sum + 1) * 0.5 default: title = "Vant fBm" param octaves caption = "Octaves" default = 1 min = 1 endparam param persistence caption = "Persistence" default = 0.5 endparam param scale caption = "Scale" default = 50 endparam int param states caption = "States" default = 2 endparam int param max caption = "Generations" default = 19000 min = 1 endparam int param size caption = "Tile Size" default = 256 min = 10 endparam param offset caption = "Offset" default = (0,0) endparam float param angle caption = "Rotation" default = 0 endparam float param rot caption = "Rotation Step" default = 0 endparam param interp caption = "Interpolation" enum = "None" "Linear" "Bilinear" "Bicubic" default = 0 endparam param @seed caption = "Random Seed" default = 12345 endparam } mt-aurora { ; Mark Townsend, 2 Nov 2000 global: int c[@length, @gen] int t = 0, int s = 0 int seed = @seed while t < @length seed = random(seed) c[t, 0] = seed % @states t = t + 1 endwhile t = 1 while t < @gen s = 0 while s < @length int l = c[(s + @length - 1) % @length,t - 1] int r = c[(s + 1) % @length, t - 1] int self = c[s, t - 1] c[s, t] = round((l + self + r) / 3.0 + 1) % @states s = s + 1 endwhile t = t + 1 endwhile if @filter ; Average neighbours s = 0 while s < @length t = 0 while t < @gen int ll = (s + @length - 1) % @length int rr = (s + 1) % @length int u = (t + @gen - 1) % @gen int d = (t + 1) % @gen int nt = c[s, u] int st = c[s, d] int et = c[ll, t] int wt = c[rr, t] int ne = c[rr, u] int nw = c[ll, u] int se = c[rr, d] int sw = c[ll, d] c[s, t] = round((4 * (nt + et + st + wt) + (ne + nw + se + sw)) / 20) t = t + 1 endwhile s = s + 1 endwhile endif final: float v0, float v1, float v2, float v3 float xx = (real(#z * @scale) % 4096 + 4096) % @length float yy = (imag(#z * @scale) % 4096 + 4096) % @gen int bx0 = floor(xx), int bx1 = (bx0 + 1) % @length float rx0 = xx - bx0, int by0 = floor(yy) int by1 = (by0 + 1) % @gen, float ry0 = yy - by0 if @interp == "None" #index = c[bx1, by1] / @states elseif @interp == "Bilinear" v0 = c[bx0, by0] + rx0 * (c[bx1, by0] - c[bx0, by0]) v1 = c[bx0, by1] + rx0 * (c[bx1, by1] - c[bx0, by1]) #index = (v0 + ry0 * (v1 - v0)) / @states elseif @interp == "Bicubic" int bx2 = (bx0 + 2) % @length int by2 = (by0 + 2) % @gen int mx1 = (bx0 - 1 + @length) % @length int my1 = (by0 - 1 + @gen) % @gen float sx = (1 - 2 * rx0^2 + rx0^3) v0 = -rx0 * (1 - rx0)^2 * c[mx1, my1] + sx * c[bx0, my1] + rx0 * \ (1 + rx0 - rx0^2) * c[bx1, my1] - rx0^2 * (1 - rx0) * c[bx2, my1] v1 = -rx0 * (1 - rx0)^2 * c[mx1, by0]+ sx * c[bx0, by0] + rx0 * \ (1 + rx0 - rx0^2) * c[bx1, by0] - rx0^2 * (1 - rx0) * c[bx2, by0] v2 = -rx0 * (1 - rx0)^2 * c[mx1, by1] + sx * c[bx0, by1] + rx0 * \ (1 + rx0 - rx0^2) * c[bx1, by1] - rx0^2 * (1 - rx0) * c[bx2, by1] v3 = -rx0 * (1 - rx0)^2 * c[mx1, by2] + sx * c[bx0, by2] + rx0 * \ (1 + rx0 - rx0^2) * c[bx1, by2] - rx0^2 * (1 - rx0) * c[bx2, by2] #index = (-ry0 * (1 - ry0)^2 * v0 + (1 - 2 * ry0^2 + ry0^3) * v1 + \ ry0 * (1 + ry0 - ry0^2) * v2 + ry0^2 * (ry0 - 1) * v3) / @states endif default: title = "Aurora" int param @states caption = "States" default = 256 endparam int param @gen caption = "Generations" default = 1000 endparam int param @length caption = "Line Length" default = 100 endparam float param scale caption = "Scale" default = 10 endparam bool param filter caption = "Soften" default = false endparam param interp caption = "Interpolation" enum = "None" "Bilinear" "Bicubic" endparam int param @seed caption = "Random Seed" default = 12345678 endparam } mt-reaction-diffusion { ; Mark Townsend, 17 January 2014 ; Activator-inhibitor type reaction-diffusion system ; from Meinhardt's "The Algorithmic Beauty of Shells" ; as simulated on continuous-valued cellular automata ; by Rudy Rucker for his program Capow! global: float func clamp(const float a, const float l, const float h) if a > h return h elseif a < l return l else return a endif endfunc float a[@xsize, @ysize], float olda[@xsize, @ysize] float b[@xsize, @ysize], float oldb[@xsize, @ysize] int x = 0, int y = 0, int seed = @seed while x < @xsize y = 0 while y < @ysize seed = random(seed) olda[x, y] = abs(seed) / #randomrange seed = random(seed) oldb[x, y] = abs(seed) / #randomrange y = y + 1 endwhile x = x + 1 endwhile int gen = 0 while gen < @max x = 0 while x < @xsize y = 0 while y < @ysize int l = (x + @xsize - 1) % @xsize int r = (x + 1) % @xsize int u = (y + @ysize - 1) % @ysize int d = (y + 1) % @ysize float na = olda[x, u] float sa = olda[x, d] float ea = olda[l, y] float wa = olda[r, y] float nea = olda[r, u] float nwa = olda[l, u] float sea = olda[r, d] float swa = olda[l, d] float ca = olda[x, y] float suma = na + sa + ea + wa + 0.75 * (nea + nwa + sea + swa); float nb = oldb[x, u] float sb = oldb[x, d] float eb = oldb[l, y] float wb = oldb[r, y] float neb = oldb[r, u] float nwb = oldb[l, u] float seb = oldb[r, d] float swb = oldb[l, d] float cb = oldb[x, y] float sumb = nb + sb + eb + wb + 0.75 * (neb + nwb + seb + swb); float inhibitor = cb if inhibitor < @Min_b inhibitor = @Min_b endif float newa = ca + @Da * (suma - 7.0 * ca) + @s * (@ba + ca^2 / inhibitor)- @ra * ca float newb = cb + @Db *(sumb - 7.0 * cb) + @bb + @s * ca^2 - @rb * cb a[x, y] = clamp(newa, 0, 1) b[x, y] = clamp(newb, 0, 1) y = y + 1 endwhile x = x + 1 endwhile olda = a oldb = b gen = gen + 1 endwhile final: float xx = (real(#z * @scale) % 4096 + 4096) % @xsize float yy = (imag(#z * @scale) % 4096 + 4096) % @ysize int bx0 = floor(xx), int bx1 = (bx0 + 1) % @xsize int by0 = floor(yy), int by1 = (by0 + 1) % @ysize float rx0 = xx - floor(xx) float ry0 = yy - floor(yy) if @vc == "a" float v0 = a[bx0, by0] + rx0 * (a[bx1, by0] - a[bx0, by0]) float v1 = a[bx0, by1] + rx0 * (a[bx1, by1] - a[bx0, by1]) else float v0 = b[bx0, by0] + rx0 * (b[bx1, by0] - b[bx0, by0]) float v1 = b[bx0, by1] + rx0 * (b[bx1, by1] - b[bx0, by1]) endif #index = (v0 + ry0 * (v1 - v0)) default: title = "Reaction Diffusion" render = false heading caption = "System Parameters" endheading float param Da caption = "Activator Diffusion Rate" default = 0.0227 min = 0.0001 max = 1 endparam float param Db caption = "Inhibitor Diffusion Rate" default = 0.1787 min = 0.0001 max = 1 endparam float param ba caption = "Activator Production" default = 0.0670 min = 0.0001 max = 1 endparam float param bb caption = "Inhibitor Production" default = 0.0139 min = 0.0001 max = 1 endparam float param ra caption = "Activator Decay Rate" default = 0.0893 min = 0.0001 max = 1 endparam float param rb caption = "Inhibitor Decay Rate" default = 0.0754 min = 0.0001 max = 1 endparam float param s caption = "Source Density" default = 0.0810 min = 0.0001 max = 1 endparam float param Min_b caption = "Minimum Inhibitor" default = 0.0392 min = 0.0001 max = 1 endparam heading Caption = "General" endheading param vc caption = "Show Chemical" enum = "a" "b" default = 0 endparam int param max caption = "Generations" default = 400 min = 1 endparam int param xsize caption = "Width" default = 250 min = 10 endparam int param ysize caption = "Height" default = 250 min = 10 endparam float param scale caption = "Scale" default = 100 endparam int param seed caption = "Random Seed" default = 12345678 endparam } mt-meinhardt-noise { ; Mark Townsend, 18 January 2014 ; Activator-inhibitor type reaction-diffusion system ; from Meinhardt's "The Algorithmic Beauty of Shells" ; as simulated on continuous-valued cellular automata ; by Rudy Rucker for his program Capow! global: float func clamp(const float a, const float l, const float h) if a > h return h elseif a < l return l else return a endif endfunc float a[@size, @size], float olda[@size, @size] float b[@size, @size], float oldb[@size, @size] int x = 0, int y = 0, int seed = @seed while x < @size y = 0 while y < @size seed = random(seed) olda[x, y] = abs(seed) / #randomrange seed = random(seed) oldb[x, y] = abs(seed) / #randomrange y = y + 1 endwhile x = x + 1 endwhile int gen = 0 while gen < @max x = 0 while x < @size y = 0 while y < @size int l = (x + @size - 1) % @size int r = (x + 1) % @size int u = (y + @size - 1) % @size int d = (y + 1) % @size float na = olda[x, u] float sa = olda[x, d] float ea = olda[l, y] float wa = olda[r, y] float nea = olda[r, u] float nwa = olda[l, u] float sea = olda[r, d] float swa = olda[l, d] float ca = olda[x, y] float suma = na + sa + ea + wa + 0.75 * (nea + nwa + sea + swa); float nb = oldb[x, u] float sb = oldb[x, d] float eb = oldb[l, y] float wb = oldb[r, y] float neb = oldb[r, u] float nwb = oldb[l, u] float seb = oldb[r, d] float swb = oldb[l, d] float cb = oldb[x, y] float sumb = nb + sb + eb + wb + 0.75 * (neb + nwb + seb + swb); float inhibitor = cb if inhibitor < @Min_b inhibitor = @Min_b endif float newa = ca + @Da * (suma - 7.0 * ca) + @s * (@ba + ca^2 / inhibitor)- @ra * ca float newb = cb + @Db *(sumb - 7.0 * cb) + @bb + @s * ca^2 - @rb * cb a[x, y] = clamp(newa, 0, 1) b[x, y] = clamp(newb, 0, 1) y = y + 1 endwhile x = x + 1 endwhile olda = a oldb = b gen = gen + 1 endwhile final: float noise = 0 float v0, float v1 int iter = 0, float sum = 0 float amplitude = 1.0 rr = (0,1) ^ (@rot / 90.0) w = #z * @scale while iter < @octaves float xx = real(w) % 4096 + 4096 int bx0 = floor(xx) % @size int bx1 = (bx0 + 1) % @size float rx0 = xx - floor(xx) float yy = imag(w) % 4096 + 4096 int by0 = floor(yy) % @size int by1 = (by0 + 1) % @size float ry0 = yy - floor(yy) v0 = a[bx0, by0] + rx0 * (a[bx1, by0] - a[bx0, by0]) v1 = a[bx0, by1] + rx0 * (a[bx1, by1] - a[bx0, by1]) noise = (v0 + ry0 * (v1 - v0)) sum = sum + noise * amplitude w = w * rr / 0.5 amplitude = amplitude * @persistence iter = iter + 1 endwhile #index = (sum + 1) * 0.5 default: title = "Meinhardt Noise" render = false heading caption = "System Parameters" endheading float param Da caption = "Activator Diffusion Rate" default = 0.0227 min = 0.0001 max = 1 endparam float param Db caption = "Inhibitor Diffusion Rate" default = 0.1787 min = 0.0001 max = 1 endparam float param ba caption = "Activator Production" default = 0.0670 min = 0.0001 max = 1 endparam float param bb caption = "Inhibitor Production" default = 0.0139 min = 0.0001 max = 1 endparam float param ra caption = "Activator Decay Rate" default = 0.0893 min = 0.0001 max = 1 endparam float param rb caption = "Inhibitor Decay Rate" default = 0.0754 min = 0.0001 max = 1 endparam float param s caption = "Source Density" default = 0.0810 min = 0.0001 max = 1 endparam float param Min_b caption = "Minimum Inhibitor" default = 0.0392 min = 0.0001 max = 1 endparam heading Caption = "General" endheading int param max caption = "Generations" default = 400 min = 1 endparam param octaves caption = "Octaves" default = 1 min = 1 endparam param persistence caption = "Persistence" default = 0.5 endparam param scale caption = "Scale" default = 50 endparam int param size caption = "Grid Size" default = 256 min = 10 endparam float param rot caption = "Rotation Step" default = 0 endparam param seed caption = "Random Seed" default = 12345 endparam }