# Fractals/ultrafractal

UltraFractal is a program by Frederik Slijkerman. This is unofficial wiki about it.

use wine

# Help

• file types[1]
• Fractal Forum [2]

# formula

## outside coloring

• Average Colorings

### TwinLamps or Standart Exp smoothing

```TwinLamps {
; Standart Exp smoothing (invented by Ron Barnet code taken from Damien M. Jones)
; divided by fractal dimension statistics (from Kerry Mitchell).
; Tried to make universal algorithm and  showing features
; of fractal and not of colour method. Goes with mandelbrots,
; patterns and julias, but not so with newton fractals.
; by Edgars Malinovskis 17.01.2012
; Removed bug creating no colour spots. 23.02.1012

init:
float sum = 0.0
float zmin=1e20
float zmax=-1
float cabsz=0.0
float lnz=0.0

loop:

cabsz= cabs(#z+@posneg)

lnz=exp(-cabsz)

;finding min and max z.
IF (lnz < zmin)
zmin = lnz
ENDIF
IF (lnz > zmax)
zmax = lnz
ENDIF

;exp smoothing
sum= sum + lnz

final:
;dividing exponent smooth value by fractal dimension value

#index=sqrt(sum)/(1+zmax-zmin)

default:
title = "TwinLamps"

param posneg
caption = "Add to pixel value"
default =  (0.0, 0.0)
hint = "The same as trap center.\
Adding number diverses negative Z areas\
and marks -n with dots."
endparam

}
```

### DEM

```DistanceEstimator(OUTSIDE) {
;
; Distance-estimator coloring algorithm for Mandelbrot and
; other z^n fractal types (Phoenix, Julia). This coloring
; algorithm estimates the distance to the boundary of the
; fractal (for example the Mandelbrot set) and colors points
; accordingly.
;
; Written by Damien M. Jones
;
init:
complex dz = (0,0)
loop:
dz = @power * #z^(@power-1) * dz + 1
final:
#index = (@power*log(cabs(#z)) * cabs(#z) / cabs(dz))^(1/@power)
default:
title = "Distance Estimator"
helpfile = "Uf*.chm"
helptopic = "Html/coloring/standard/distanceestimator.html"
param power
caption = "Exponent"
default = 2.0
hint = "This should be set to match the exponent of the \
formula you are using. For Mandelbrot, this is usually 2."
endparam
}
```

### ExponentialSmoothing

```

ExponentialSmoothing {
; from Standard.ucl
; This coloring method provides smooth iteration
; colors for all fractal types, convergent or
; divergent (or both).  It combines the two methods
; developed by Ron Barnett.  It doesn't map
; precisely to iterations, but it's close.
;
; Written by Damien M. Jones
;
init:
float sum = 0.0
float sum2 = 0.0
complex zold = (0,0)

loop:
IF (@diverge)
sum = sum + exp(-cabs(#z))
ENDIF
IF (@converge)
sum2 = sum2 + exp(-1/cabs(zold-#z))
ENDIF
zold = #z

final:
IF (|#z - zold| < 0.5)	; convergent bailout.
IF (@converge)
#index = sum2
ELSE
#index = 0
ENDIF

ELSE				; divergent bailout.
IF (@diverge)
#index = sum * @divergescale
ELSE
#index = 0
ENDIF
ENDIF

default:
title = "Exponential Smoothing"
helpfile = "Uf*.chm"
helptopic = "Html/coloring/standard/exponentialsmoothing.html"
\$IFDEF VER50
rating = recommended
\$ENDIF

param diverge
caption = "Color Divergent"
default = FALSE
hint = "If checked, points which escape to infinity will be \
colored."
endparam
param converge
caption = "Color Convergent"
default = TRUE
hint = "If checked, points which collapse to one value will be \
colored."
endparam
param divergescale
caption = "Divergent Density"
default = 1.0
\$IFDEF VER40
exponential = true
\$ENDIF
hint = "Sets the divergent coloring density, relative to the \
convergent coloring. If set to 1.0, they will use \
the same color density."
endparam
}
```

### smooth

```Smooth(OUTSIDE) {
; from Standard.ucl
; This coloring method provides smooth iteration
; colors for Mandelbrot and other z^2 formula types
; (Phoenix, Julia).  Results on other types may be
; unpredictable, but might be interesting.
;
; Thanks to F. Slijkerman for some tweaks.
; Thanks to Linas Vepstas for the math.
;
; Written by Damien M. Jones
;
init:
complex il = 1/log(@power)		; Inverse log (power).
float lp = log(log(@bailout))		; log(log bailout).

final:
#index = 0.05 * real(#numiter + il*lp - il*log(log(cabs(#z))))

default:
title = "Smooth (Mandelbrot)"
helpfile = "Uf*.chm"
helptopic = "Html/coloring/standard/smooth.html"
\$IFDEF VER50
rating = recommended
\$ENDIF

param power
caption = "Exponent"
default = (2,0)
hint = "This should be set to match the exponent of the \
formula you are using. For Mandelbrot, this is usually 2."
endparam
param bailout
caption = "Bail-out value"
default = 128.0
min = 1
hint = "This should be set to match the bail-out value in \
the Formula tab. This formula works best with bail-out \
values higher than 100."
endparam
}
```

### binary decomposition

```comment {

This file contains standard coloring algorithms for Ultra Fractal 3.
Many of the coloring algorithms here were written by other formula
authors, as noted in the comments with each formula. All formulas
have been edited and simplified by Frederik Slijkerman.

}

BinaryDecomposition {
; from standard.ucl
; Classic binary decomposition. Can give quite abstract effects.
; Use low bail-out values in the fractal formula (if possible) for
; best effects. This coloring algorithm uses just two colors from
; the gradient: one from the left end and one from the middle.
;
final:
if @type == "Type 1"
if real(#z) * imag(#z) >= 0
#index = 0.5
else
#index = 0
endif
else
if atan2(#z) > 0
#index = 0.5
else
#index = 0
endif
endif
default:
title = "Binary Decomposition"
helpfile = "Uf3.chm"
helptopic = "Html/coloring/standard/binarydecomposition.html"
param type
caption = "Decomposition Type"
enum = "Type 1" "Type 2"
default = 0
hint = "Toggles between two types of binary decomposition. Type 2 \
reproduces the coloring used with many images in the classic \
Beauty of Fractals book."
endparam
}

```

### slope

```// http://www.fractalforums.com/mandel-machine/maybe-perturbation-could-go-with-a-slope/

mbrot2_slope {
fractal:
title="mbrot2_slope" width=1024 height=400 layers=1
credits="Alef;12/4/2014;Frederik;7/23/2010"
layer:
caption="Background" opacity=100
mapping:
center=-0.61777095064903/0.6790465094562 magn=19180.711
angle=156.5545
formula:
maxiter=1000 filename="Standard.ufm" entry="SlopeMandel" p_start=0/0
p_power=2/0 p_bailout=1.0E20 p_offset=0.000000000000001
p_zmode=potential p_xfer=linear p_zscale=1.0 p_zscale2=0.005
p_everyiter=no
inside:
transfer=none
outside:
transfer=linear filename="Standard.ucl" entry="Decomposition"
comments="slightly changed standart. IMHO good sky." smooth=no
rotation=1 index=0 color=6303744 index=64 color=12085789 index=168
color=16777197 index=257 color=33023 index=343 color=512
opacity:
smooth=no index=0 opacity=255
}

mbrot3_slope {
;
; sample image to illustrate
; embossing effect
fractal:
title="mbrot3_slope" width=1024 height=512 layers=1
credits="Alef;12/4/2014;Kerry Mitchell;9/15/1998"
layer:
caption="Layer 1" opacity=100 method=linear
mapping:
center=-0.81810721128409/0.19884197484006 magn=4118.0018
angle=34.1619
formula:
maxiter=1000 percheck=off filename="Standard.ufm"
entry="SlopeMandel" p_start=0/0 p_power=2/0 p_bailout=1.0E20
p_offset=0.000000000000001 p_zmode="distance estimator"
p_xfer=linear p_zscale=1.0 p_zscale2=0.005 p_everyiter=no
inside:
transfer=none
outside:
transfer=linear filename="Standard.ucl" entry="Decomposition"
comments="slightly changed standart. IMHO good sky." smooth=no
rotation=1 index=0 color=6303744 index=64 color=12085789 index=168
color=16777197 index=257 color=33023 index=343 color=512
opacity:
smooth=no index=0 opacity=255
}
```

### field lines

"There's a later version of my formula for field lines - though somewhat extended to include smooth iteration, distance estimation and distance estimation angles in my class formulas for UF - mmf.ulb called "MMF Field Estimator" It's a UF class formula so not quite so easy to follow but I think it should be clear enough. I boiled down "corrections" to field lines that work in most places but at the moment require manual adjustment to work properly - these are the two parameters that can be modified by the user to fix errors in the field lines, unfortunately you can't always fix them everywhere in view even then but this is about as close as you can get I think. I tried including the MMF Field Lines code here but unfortunately it's too long, it's in mmf.ulb in te Ultra Fractal Formula database at: http://formulas.ultrafractal.com/ " David Makin

```MMF3-FieldLines {
;
; This version of calculating field lines will work reasonably well with both
; Mandelbrot and Julia Sets for divergent fractals with a divergence that is
; close to being a positive integer >=2 but can also produce quite interesting
; results with fractals that do not fit that criteria - just not rendering the
; field lines correctly in other cases :-)
;
; Thanks to Chris Hayton for showing me how to fix the "off-by-one" problems.
;  http://www.fractalforums.com/programming/smooth-external-angle-of-mandelbrot-set/
; David Makin
; Here's my code from mmf3.ucl for Ultra Fractal:
;
global:
float twopi = 2.0*#pi
float dtwopi = 0.5/#pi
float dp = 1.0/@power
float m = @power*dtwopi
float dp2 = 1.0/(2.0+@power) ; Changed from originally trying 1/power
init:
complex zv[#maxiter]
int i = 0
float a = 0.0
float b = 0.0
float c = 0.0
float s = 0.0
if @julia
zv[i] = #z
i = i + 1
endif
loop:
zv[i] = #z
i = i + 1
final:
if (s = atan2(#z))<0
s = s + twopi
endif
while i > @skipiter
i = i - 1
if @version==0
b = (@power*atan2(zv[i]))%twopi
else
b = atan2(zv[i]^@power)
endif
if b < 0.0
b = b + twopi
endif
c = c + b - s
if c >= #pi
s = s + twopi
if @fixit || @accident
c = c - twopi
endif
elseif c < -#pi
s = s - twopi
if @fixit || @accident
c = c + twopi
endif
endif
if @fixit
c = dp2*c
elseif !@accident
c = 0.0
endif
if (a = atan2(zv[i])) < 0.0
a = a + twopi
endif
s = dp*(s + twopi*floor(a*m))
endwhile
s = s*dtwopi
if @fixskip
while s<0.0
s = s + 1.0
endwhile
while s>=1.0
s = s - 1.0
endwhile
endif
#index = s
default:
title = "MMF3 Field Lines (use high bailouts)"
caption = "Information"
;    text = "This colouring is a little touchy around certain values, if you \
;            get obvious lines or dots that shouldn't be there but the 'Degree \
;            of Divergence' is set properly for the main formula and you are \
;            using a high bailout of say 1e20 or higher then try \
;            adjusting the location very slightly. For example if vertical \
;            lines appear on an unrotated fractal then try changing the x \
;            (real) location very slightly, if horizontal lines appear then try \
;            changing the y (imag) location very slightly."
param version
caption = "Version"
enum = "Original" "Alternative"
default = 1
hint = "Allows you to modify one of the calculations in the formula that \
is particularly sensitive to small errors. Ideally both methods \
should produce identical results but they don't, so if you get \
visible errors using one method then try the other (assuming you \
have the divergence set correctly and are using a high bailout)."
endparam
param power
caption = "Degree of divergence"
default = 2.0
hint = "This is an estimate of the divergence of the main formula, e.g. 2 \
for z^2+c, 3 for z^3+c etc."
endparam
param julia
caption = "Julia ?"
default = false
hint = "Enable for correct rendering of Julia Sets."
endparam
param skipiter
caption = "'Start' iteration"
default = 0
min = 0
hint = "You can use this to attempt to get better detail at higher \
iteration depths, note that it only works as intended with 'Color \
Density' as a whole integer >=1."
endparam
param fixskip
caption = "Fix 'Start' iteration"
default = false
hint = "Fixes a problem when the start iteration is non-zero and maybe in \
other cases - specifically if you get solid areas of palette \
colour zero when the Transfer Function is Linear this may fix the \
problem."
endparam
param fixit
caption = "Fix Field Lines"
default = false
hint = "Enable this to make the formula much more accurate at rendering \
the field lines correctly. It's a fudge produced after trial and \
error but is quite effective at correcting some areas."
endparam
param accident
caption = "Happy Accident"
default = false
hint = "You may find the colouring useful when this is enabled. This \
is available as I found the results when initially adding the \
'Fix it' option quite interesting."
visible = !@fixit
endparam
}
```

### multiwave

```MandelMultiwave {
global:
color c2x0 = hsl(0,0.5,0.5 + @lmag/2)
color c2x1 = hsl(0,0.5,0.5)
color c2x2 = hsl(0,0.5,0.5 - @lmag/2)
color c2x3 = hsl(0,0.5,0.5)
color c3x0 = hsl(0,0.5,0.5 + @lmag2/2)
color c3x1 = hsl(0,0.5,0.5)
color c3x2 = hsl(0,0.5,0.5 - @lmag2/2)
color c3x3 = hsl(0,0.5,0.5)
color c4x0 = hsl(0,0.5,0.5 + @lmag3/2)
color c4x1 = hsl(0,0.5,0.5)
color c4x2 = hsl(0,0.5,0.5 - @lmag3/2)
color c4x3 = hsl(0,0.5,0.5)
color c5x0 = hsl(0,0.5,0.5)
color c5x1 = hsl(0,0.5,0.5 - @lmag4/2)
color c5x2 = hsl(0,0.5,0.5)
color c5x3 = hsl(0,0.5,0.5 + @lmag4/2)
init:
complex il = 1/log(@power)		; Inverse log (power).
float lp = log(log(@bailout))		; log(log bailout).
final:
float i = real(#numiter + il*lp - il*log(log(cabs(#z)))) + @displacement
IF (i < 1)
i = 1
ENDIF
i = (i - 1)*@rescale + 1
float ix = (i - 1)/@hfreq2
ix = ix - trunc(ix)
color c1a
color c1b
color c1c
color c1d
color c2a
color c2b
color c2c
color c2d
color c3a
color c3b
color c3c
color c3d
color c4a
color c4b
color c4c
color c4d
IF (ix < 1/5)
ix = ix*5
c1a = @c1e
c1b = @c1a
c1c = @c1b
c1d = @c1c
c2a = @c2e
c2b = @c2a
c2c = @c2b
c2d = @c2c
c3a = @c3e
c3b = @c3a
c3c = @c3b
c3d = @c3c
c4a = @c4e
c4b = @c4a
c4c = @c4b
c4d = @c4c
ELSEIF (ix < 2/5)
ix = (ix - 1/5)*5
c1a = @c1a
c1b = @c1b
c1c = @c1c
c1d = @c1d
c2a = @c2a
c2b = @c2b
c2c = @c2c
c2d = @c2d
c3a = @c3a
c3b = @c3b
c3c = @c3c
c3d = @c3d
c4a = @c4a
c4b = @c4b
c4c = @c4c
c4d = @c4d
ELSEIF (ix < 3/5)
ix = (ix - 2/5)*5
c1a = @c1b
c1b = @c1c
c1c = @c1d
c1d = @c1e
c2a = @c2b
c2b = @c2c
c2c = @c2d
c2d = @c2e
c3a = @c3b
c3b = @c3c
c3c = @c3d
c3d = @c3e
c4a = @c4b
c4b = @c4c
c4c = @c4d
c4d = @c4e
ELSEIF (ix < 4/5)
ix = (ix - 3/5)*5
c1a = @c1c
c1b = @c1d
c1c = @c1e
c1d = @c1a
c2a = @c2c
c2b = @c2d
c2c = @c2e
c2d = @c2a
c3a = @c3c
c3b = @c3d
c3c = @c3e
c3d = @c3a
c4a = @c4c
c4b = @c4d
c4c = @c4e
c4d = @c4a
ELSE
ix = (ix - 4/5)*5
c1a = @c1d
c1b = @c1e
c1c = @c1a
c1d = @c1b
c2a = @c2d
c2b = @c2e
c2c = @c2a
c2d = @c2b
c3a = @c3d
c3b = @c3e
c3c = @c3a
c3d = @c3b
c4a = @c4d
c4b = @c4e
c4c = @c4a
c4d = @c4b
ENDIF
float rp0 = red(c1b)
float gp0 = green(c1b)
float bp0 = blue(c1b)
float rm0 = (red(c1c) - red(c1a))/2
float gm0 = (green(c1c) - green(c1a))/2
float bm0 = (blue(c1c) - blue(c1a))/2
float rp1 = red(c1c)
float gp1 = green(c1c)
float bp1 = blue(c1c)
float rm1 = (red(c1d) - red(c1b))/2
float gm1 = (green(c1d) - green(c1b))/2
float bm1 = (blue(c1d) - blue(c1b))/2
float ixt2 = ix^2
float ixt3 = ix^3
float ixa = 2*ixt3 - 3*ixt2 + 1
float ixb = ixt3 - 2*ixt2 + ix
float ixc = -2*ixt3 + 3*ixt2
float ixd = ixt3 - ixt2
float rrr = ixa*rp0 + ixb*rm0 + ixc*rp1 + ixd*rm1
float ggg = ixa*gp0 + ixb*gm0 + ixc*gp1 + ixd*gm1
float bbb = ixa*bp0 + ixb*bm0 + ixc*bp1 + ixd*bm1
IF (rrr < 0.0)
rrr = 0.0
ELSEIF (rrr > 1.0)
rrr = 1.0
ENDIF
IF (ggg < 0.0)
ggg = 0.0
ELSEIF (ggg > 1.0)
ggg = 1.0
ENDIF
IF (bbb < 0.0)
bbb = 0.0
ELSEIF (bbb > 1.0)
bbb = 1.0
ENDIF
color c1 = rgb(rrr,ggg,bbb)
rp0 = red(c2b)
gp0 = green(c2b)
bp0 = blue(c2b)
rm0 = (red(c2c) - red(c2a))/2
gm0 = (green(c2c) - green(c2a))/2
bm0 = (blue(c2c) - blue(c2a))/2
rp1 = red(c2c)
gp1 = green(c2c)
bp1 = blue(c2c)
rm1 = (red(c2d) - red(c2b))/2
gm1 = (green(c2d) - green(c2b))/2
bm1 = (blue(c2d) - blue(c2b))/2
ixt2 = ix^2
ixt3 = ix^3
ixa = 2*ixt3 - 3*ixt2 + 1
ixb = ixt3 - 2*ixt2 + ix
ixc = -2*ixt3 + 3*ixt2
ixd = ixt3 - ixt2
rrr = ixa*rp0 + ixb*rm0 + ixc*rp1 + ixd*rm1
ggg = ixa*gp0 + ixb*gm0 + ixc*gp1 + ixd*gm1
bbb = ixa*bp0 + ixb*bm0 + ixc*bp1 + ixd*bm1
IF (rrr < 0.0)
rrr = 0.0
ELSEIF (rrr > 1.0)
rrr = 1.0
ENDIF
IF (ggg < 0.0)
ggg = 0.0
ELSEIF (ggg > 1.0)
ggg = 1.0
ENDIF
IF (bbb < 0.0)
bbb = 0.0
ELSEIF (bbb > 1.0)
bbb = 1.0
ENDIF
color c2 = rgb(rrr,ggg,bbb)
rp0 = red(c3b)
gp0 = green(c3b)
bp0 = blue(c3b)
rm0 = (red(c3c) - red(c3a))/2
gm0 = (green(c3c) - green(c3a))/2
bm0 = (blue(c3c) - blue(c3a))/2
rp1 = red(c3c)
gp1 = green(c3c)
bp1 = blue(c3c)
rm1 = (red(c3d) - red(c3b))/2
gm1 = (green(c3d) - green(c3b))/2
bm1 = (blue(c3d) - blue(c3b))/2
ixt2 = ix^2
ixt3 = ix^3
ixa = 2*ixt3 - 3*ixt2 + 1
ixb = ixt3 - 2*ixt2 + ix
ixc = -2*ixt3 + 3*ixt2
ixd = ixt3 - ixt2
rrr = ixa*rp0 + ixb*rm0 + ixc*rp1 + ixd*rm1
ggg = ixa*gp0 + ixb*gm0 + ixc*gp1 + ixd*gm1
bbb = ixa*bp0 + ixb*bm0 + ixc*bp1 + ixd*bm1
IF (rrr < 0.0)
rrr = 0.0
ELSEIF (rrr > 1.0)
rrr = 1.0
ENDIF
IF (ggg < 0.0)
ggg = 0.0
ELSEIF (ggg > 1.0)
ggg = 1.0
ENDIF
IF (bbb < 0.0)
bbb = 0.0
ELSEIF (bbb > 1.0)
bbb = 1.0
ENDIF
color c3 = rgb(rrr,ggg,bbb)
rp0 = red(c4b)
gp0 = green(c4b)
bp0 = blue(c4b)
rm0 = (red(c4c) - red(c4a))/2
gm0 = (green(c4c) - green(c4a))/2
bm0 = (blue(c4c) - blue(c4a))/2
rp1 = red(c4c)
gp1 = green(c4c)
bp1 = blue(c4c)
rm1 = (red(c4d) - red(c4b))/2
gm1 = (green(c4d) - green(c4b))/2
bm1 = (blue(c4d) - blue(c4b))/2
ixt2 = ix^2
ixt3 = ix^3
ixa = 2*ixt3 - 3*ixt2 + 1
ixb = ixt3 - 2*ixt2 + ix
ixc = -2*ixt3 + 3*ixt2
ixd = ixt3 - ixt2
rrr = ixa*rp0 + ixb*rm0 + ixc*rp1 + ixd*rm1
ggg = ixa*gp0 + ixb*gm0 + ixc*gp1 + ixd*gm1
bbb = ixa*bp0 + ixb*bm0 + ixc*bp1 + ixd*bm1
IF (rrr < 0.0)
rrr = 0.0
ELSEIF (rrr > 1.0)
rrr = 1.0
ENDIF
IF (ggg < 0.0)
ggg = 0.0
ELSEIF (ggg > 1.0)
ggg = 1.0
ENDIF
IF (bbb < 0.0)
bbb = 0.0
ELSEIF (bbb > 1.0)
bbb = 1.0
ENDIF
color c4 = rgb(rrr,ggg,bbb)
ix = (i - 1)/@hfreq1
ix = ix - trunc(ix)
color ca
color cb
color cc
color cd
IF (ix < 1/4)
ix = ix*4
ca = c4
cb = c1
cc = c2
cd = c3
ELSEIF (ix < 1/2)
ix = (ix - 1/4)*4
ca = c1
cb = c2
cc = c3
cd = c4
ELSEIF (ix < 3/4)
ix = (ix - 1/2)*4
ca = c2
cb = c3
cc = c4
cd = c1
ELSE
ix = (ix - 3/4)*4
ca = c3
cb = c4
cc = c1
cd = c2
ENDIF
rp0 = red(cb)
gp0 = green(cb)
bp0 = blue(cb)
rm0 = (red(cc) - red(ca))/2
gm0 = (green(cc) - green(ca))/2
bm0 = (blue(cc) - blue(ca))/2
rp1 = red(cc)
gp1 = green(cc)
bp1 = blue(cc)
rm1 = (red(cd) - red(cb))/2
gm1 = (green(cd) - green(cb))/2
bm1 = (blue(cd) - blue(cb))/2
ixt2 = ix^2
ixt3 = ix^3
ixa = 2*ixt3 - 3*ixt2 + 1
ixb = ixt3 - 2*ixt2 + ix
ixc = -2*ixt3 + 3*ixt2
ixd = ixt3 - ixt2
rrr = ixa*rp0 + ixb*rm0 + ixc*rp1 + ixd*rm1
ggg = ixa*gp0 + ixb*gm0 + ixc*gp1 + ixd*gm1
bbb = ixa*bp0 + ixb*bm0 + ixc*bp1 + ixd*bm1
IF (rrr < 0.0)
rrr = 0.0
ELSEIF (rrr > 1.0)
rrr = 1.0
ENDIF
IF (ggg < 0.0)
ggg = 0.0
ELSEIF (ggg > 1.0)
ggg = 1.0
ENDIF
IF (bbb < 0.0)
bbb = 0.0
ELSEIF (bbb > 1.0)
bbb = 1.0
ENDIF
c2 = rgb(rrr,ggg,bbb)
ix = (i - 1)/@sfreq
ix = ix - trunc(ix)
IF (ix < 1/3)
ix = ix*3
ca = @cz
cb = @cx
cc = @cy
cd = @cz
ELSEIF (ix < 2/3)
ix = (ix - 1/3)*3
ca = @cx
cb = @cy
cc = @cz
cd = @cx
ELSE
ix = (ix - 2/3)*3
ca = @cy
cb = @cz
cc = @cx
cd = @cy
ENDIF
rp0 = red(cb)
gp0 = green(cb)
bp0 = blue(cb)
rm0 = (red(cc) - red(ca))/2
gm0 = (green(cc) - green(ca))/2
bm0 = (blue(cc) - blue(ca))/2
rp1 = red(cc)
gp1 = green(cc)
bp1 = blue(cc)
rm1 = (red(cd) - red(cb))/2
gm1 = (green(cd) - green(cb))/2
bm1 = (blue(cd) - blue(cb))/2
ixt2 = ix^2
ixt3 = ix^3
ixa = 2*ixt3 - 3*ixt2 + 1
ixb = ixt3 - 2*ixt2 + ix
ixc = -2*ixt3 + 3*ixt2
ixd = ixt3 - ixt2
rrr = ixa*rp0 + ixb*rm0 + ixc*rp1 + ixd*rm1
ggg = ixa*gp0 + ixb*gm0 + ixc*gp1 + ixd*gm1
bbb = ixa*bp0 + ixb*bm0 + ixc*bp1 + ixd*bm1
IF (rrr < 0.0)
rrr = 0.0
ELSEIF (rrr > 1.0)
rrr = 1.0
ENDIF
IF (ggg < 0.0)
ggg = 0.0
ELSEIF (ggg > 1.0)
ggg = 1.0
ENDIF
IF (bbb < 0.0)
bbb = 0.0
ELSEIF (bbb > 1.0)
bbb = 1.0
ENDIF
c3 = rgb(rrr,ggg,bbb)
float hh = hue(c2)
float ss = sat(c2)
float ll = lum(c2)
IF (ll != 1.0 && lum(c3) != 1.0)
ll = 1 - 1/((1/(1 - ll) - 1)*(1/(1 - lum(c3)) - 1) + 1)
ENDIF
IF (@smode == 0)
ss = ss*(1 - sat(c3)*(((1 - cos((hh - hue(c3))*#pi/3))/2)^@spow))
ELSE
hh = (hh + hue(c3))%6
IF (ss != 1.0 && sat(c3) != 1.0)
ss = 1 - 1/((1/(1 - ss) - 1)*(1/(1 - sat(c3)) - 1) + 1)
ENDIF
ENDIF
c1 = hsl(hh,ss,ll)
ix = (i - 1)/@lfreq
ix = ix - trunc(ix)
IF (ix < 1/4)
ix = ix*4
ca = c2x3
cb = c2x0
cc = c2x1
cd = c2x2
ELSEIF (ix < 1/2)
ix = (ix - 1/4)*4
ca = c2x0
cb = c2x1
cc = c2x2
cd = c2x3
ELSEIF (ix < 3/4)
ix = (ix - 1/2)*4
ca = c2x1
cb = c2x2
cc = c2x3
cd = c2x0
ELSE
ix = (ix - 3/4)*4
ca = c2x2
cb = c2x3
cc = c2x0
cd = c2x1
ENDIF
rp0 = red(cb)
gp0 = green(cb)
bp0 = blue(cb)
rm0 = (red(cc) - red(ca))/2
gm0 = (green(cc) - green(ca))/2
bm0 = (blue(cc) - blue(ca))/2
rp1 = red(cc)
gp1 = green(cc)
bp1 = blue(cc)
rm1 = (red(cd) - red(cb))/2
gm1 = (green(cd) - green(cb))/2
bm1 = (blue(cd) - blue(cb))/2
ixt2 = ix^2
ixt3 = ix^3
ixa = 2*ixt3 - 3*ixt2 + 1
ixb = ixt3 - 2*ixt2 + ix
ixc = -2*ixt3 + 3*ixt2
ixd = ixt3 - ixt2
rrr = ixa*rp0 + ixb*rm0 + ixc*rp1 + ixd*rm1
ggg = ixa*gp0 + ixb*gm0 + ixc*gp1 + ixd*gm1
bbb = ixa*bp0 + ixb*bm0 + ixc*bp1 + ixd*bm1
IF (rrr < 0.0)
rrr = 0.0
ELSEIF (rrr > 1.0)
rrr = 1.0
ENDIF
IF (ggg < 0.0)
ggg = 0.0
ELSEIF (ggg > 1.0)
ggg = 1.0
ENDIF
IF (bbb < 0.0)
bbb = 0.0
ELSEIF (bbb > 1.0)
bbb = 1.0
ENDIF
c2 = rgb(rrr,ggg,bbb)
ix = (i - 1)/@lfreq2
ix = ix - trunc(ix)
IF (ix < 1/4)
ix = ix*4
ca = c3x3
cb = c3x0
cc = c3x1
cd = c3x2
ELSEIF (ix < 1/2)
ix = (ix - 1/4)*4
ca = c3x0
cb = c3x1
cc = c3x2
cd = c3x3
ELSEIF (ix < 3/4)
ix = (ix - 1/2)*4
ca = c3x1
cb = c3x2
cc = c3x3
cd = c3x0
ELSE
ix = (ix - 3/4)*4
ca = c3x2
cb = c3x3
cc = c3x0
cd = c3x1
ENDIF
rp0 = red(cb)
gp0 = green(cb)
bp0 = blue(cb)
rm0 = (red(cc) - red(ca))/2
gm0 = (green(cc) - green(ca))/2
bm0 = (blue(cc) - blue(ca))/2
rp1 = red(cc)
gp1 = green(cc)
bp1 = blue(cc)
rm1 = (red(cd) - red(cb))/2
gm1 = (green(cd) - green(cb))/2
bm1 = (blue(cd) - blue(cb))/2
ixt2 = ix^2
ixt3 = ix^3
ixa = 2*ixt3 - 3*ixt2 + 1
ixb = ixt3 - 2*ixt2 + ix
ixc = -2*ixt3 + 3*ixt2
ixd = ixt3 - ixt2
rrr = ixa*rp0 + ixb*rm0 + ixc*rp1 + ixd*rm1
ggg = ixa*gp0 + ixb*gm0 + ixc*gp1 + ixd*gm1
bbb = ixa*bp0 + ixb*bm0 + ixc*bp1 + ixd*bm1
IF (rrr < 0.0)
rrr = 0.0
ELSEIF (rrr > 1.0)
rrr = 1.0
ENDIF
IF (ggg < 0.0)
ggg = 0.0
ELSEIF (ggg > 1.0)
ggg = 1.0
ENDIF
IF (bbb < 0.0)
bbb = 0.0
ELSEIF (bbb > 1.0)
bbb = 1.0
ENDIF
c3 = rgb(rrr,ggg,bbb)
ix = (i - 1)/@lfreq3
ix = ix - trunc(ix)
IF (ix < 1/4)
ix = ix*4
ca = c4x3
cb = c4x0
cc = c4x1
cd = c4x2
ELSEIF (ix < 1/2)
ix = (ix - 1/4)*4
ca = c4x0
cb = c4x1
cc = c4x2
cd = c4x3
ELSEIF (ix < 3/4)
ix = (ix - 1/2)*4
ca = c4x1
cb = c4x2
cc = c4x3
cd = c4x0
ELSE
ix = (ix - 3/4)*4
ca = c4x2
cb = c4x3
cc = c4x0
cd = c4x1
ENDIF
rp0 = red(cb)
gp0 = green(cb)
bp0 = blue(cb)
rm0 = (red(cc) - red(ca))/2
gm0 = (green(cc) - green(ca))/2
bm0 = (blue(cc) - blue(ca))/2
rp1 = red(cc)
gp1 = green(cc)
bp1 = blue(cc)
rm1 = (red(cd) - red(cb))/2
gm1 = (green(cd) - green(cb))/2
bm1 = (blue(cd) - blue(cb))/2
ixt2 = ix^2
ixt3 = ix^3
ixa = 2*ixt3 - 3*ixt2 + 1
ixb = ixt3 - 2*ixt2 + ix
ixc = -2*ixt3 + 3*ixt2
ixd = ixt3 - ixt2
rrr = ixa*rp0 + ixb*rm0 + ixc*rp1 + ixd*rm1
ggg = ixa*gp0 + ixb*gm0 + ixc*gp1 + ixd*gm1
bbb = ixa*bp0 + ixb*bm0 + ixc*bp1 + ixd*bm1
IF (rrr < 0.0)
rrr = 0.0
ELSEIF (rrr > 1.0)
rrr = 1.0
ENDIF
IF (ggg < 0.0)
ggg = 0.0
ELSEIF (ggg > 1.0)
ggg = 1.0
ENDIF
IF (bbb < 0.0)
bbb = 0.0
ELSEIF (bbb > 1.0)
bbb = 1.0
ENDIF
c4 = rgb(rrr,ggg,bbb)
ix = (i - 1)/@lfreq4
ix = ix - trunc(ix)
IF (ix < 1/4)
ix = ix*4
ca = c5x3
cb = c5x0
cc = c5x1
cd = c5x2
ELSEIF (ix < 1/2)
ix = (ix - 1/4)*4
ca = c5x0
cb = c5x1
cc = c5x2
cd = c5x3
ELSEIF (ix < 3/4)
ix = (ix - 1/2)*4
ca = c5x1
cb = c5x2
cc = c5x3
cd = c5x0
ELSE
ix = (ix - 3/4)*4
ca = c5x2
cb = c5x3
cc = c5x0
cd = c5x1
ENDIF
rp0 = red(cb)
gp0 = green(cb)
bp0 = blue(cb)
rm0 = (red(cc) - red(ca))/2
gm0 = (green(cc) - green(ca))/2
bm0 = (blue(cc) - blue(ca))/2
rp1 = red(cc)
gp1 = green(cc)
bp1 = blue(cc)
rm1 = (red(cd) - red(cb))/2
gm1 = (green(cd) - green(cb))/2
bm1 = (blue(cd) - blue(cb))/2
ixt2 = ix^2
ixt3 = ix^3
ixa = 2*ixt3 - 3*ixt2 + 1
ixb = ixt3 - 2*ixt2 + ix
ixc = -2*ixt3 + 3*ixt2
ixd = ixt3 - ixt2
rrr = ixa*rp0 + ixb*rm0 + ixc*rp1 + ixd*rm1
ggg = ixa*gp0 + ixb*gm0 + ixc*gp1 + ixd*gm1
bbb = ixa*bp0 + ixb*bm0 + ixc*bp1 + ixd*bm1
IF (rrr < 0.0)
rrr = 0.0
ELSEIF (rrr > 1.0)
rrr = 1.0
ENDIF
IF (ggg < 0.0)
ggg = 0.0
ELSEIF (ggg > 1.0)
ggg = 1.0
ENDIF
IF (bbb < 0.0)
bbb = 0.0
ELSEIF (bbb > 1.0)
bbb = 1.0
ENDIF
color c5 = rgb(rrr,ggg,bbb)
float mn = @fitminit
float mx = @fitmaxit
ix = i
IF (@transfer == 1)
ix = ix^(1/@transpower)
mn = mn^(1/@transpower)
mx = mx^(1/@transpower)
ELSEIF (@transfer == 2)
ix = log(ix)
mn = log(mn)
mx = log(mx)
ENDIF
IF (@fit)
IF (ix < mn)
ix = 0
ELSE
ix = (ix - mn)/(mx - mn)
ENDIF
ix = ix * @fittimes
ELSE
ix = 0.05*ix
ENDIF
IF (@mmode == 1)
hh = (hue(c1)+hue(c6))%6
float sc1 = sat(c1)
float sc6 = sat(c6)
IF (sc1 > 0.99)
sc1 = 0.99
ENDIF
IF (sc6 > 0.99)
sc6 = 0.99
ENDIF
sc1 = 1/(1 - sc1) - 1
sc6 = 1/(1 - sc6) - 1
ss = sc1*sc6
ss = 1 - 1/(ss + 1)
float ll1 = lum(c1)
float ll2 = lum(c2)
float ll3 = lum(c3)
float ll4 = lum(c4)
float ll5 = lum(c5)
float ll6 = lum(c6)
IF (ll1 == 1.0 || ll2 == 1.0 || ll3 == 1.0 || ll4 == 1.0 || ll5 == 1.0 || ll6 == 1.0)
ll = 1.0
ELSE
ll1 = 1/(1 - ll1) - 1
ll2 = 1/(1 - ll2) - 1
ll3 = 1/(1 - ll3) - 1
ll4 = 1/(1 - ll4) - 1
ll5 = 1/(1 - ll5) - 1
ll6 = 1/(1 - ll6) - 1
ll = ll1*ll2*ll3*ll4*ll5*ll6
ll = 1 - 1/(ll + 1)
ENDIF
IF (ss < 0)
ss = 0
ELSEIF (ss > 1)
ss = 1
ENDIF
IF (ll < 0)
ll = 0
ELSEIF (ll > 1)
ll = 1
ENDIF
#color = hsl(hh,ss,ll)
ELSE
hh = hue(c1)
ss = sat(c1)
float ll1 = lum(c1)
float ll2 = lum(c2)
float ll3 = lum(c3)
float ll4 = lum(c4)
float ll5 = lum(c5)
IF (ll1 == 1.0 || ll2 == 1.0 || ll3 == 1.0 || ll4 == 1.0 || ll5 == 1.0)
ll = 1.0
ELSE
ll1 = 1/(1 - ll1) - 1
ll2 = 1/(1 - ll2) - 1
ll3 = 1/(1 - ll3) - 1
ll4 = 1/(1 - ll4) - 1
ll5 = 1/(1 - ll5) - 1
ll = ll1*ll2*ll3*ll4*ll5
ll = 1 - 1/(ll + 1)
ENDIF
IF (ll < 0)
ll = 0
ELSEIF (ll > 1)
ll = 1
ENDIF
IF (@mmode == 0)
c1 = hsl(hh,ss,ll)
float rr6 = red(c6)
float gg6 = green(c6)
float bb6 = blue(c6)
IF (rr6 > 0.99)
rr6 = 0.99
ENDIF
IF (gg6 > 0.99)
gg6 = 0.99
ENDIF
IF (bb6 > 0.99)
bb6 = 0.99
ENDIF
float rr1 = red(c1)
float gg1 = green(c1)
float bb1 = blue(c1)
IF (rr1 > 0.99)
rr1 = 0.99
ENDIF
IF (gg1 > 0.99)
gg1 = 0.99
ENDIF
IF (bb1 > 0.99)
bb1 = 0.99
ENDIF
rr6 = 1/(1 - rr6) - 1
gg6 = 1/(1 - gg6) - 1
bb6 = 1/(1 - bb6) - 1
rr1 = 1/(1 - rr1) - 1
gg1 = 1/(1 - gg1) - 1
bb1 = 1/(1 - bb1) - 1
float rrr = 1 - 1/(rr6*rr1 + 1)
float ggg = 1 - 1/(gg6*gg1 + 1)
float bbb = 1 - 1/(bb6*bb1 + 1)
#color = rgb(rrr,ggg,bbb)
ELSE
float aa = alpha(c5)
float omaa = 1 - aa
IF (@mmode == 2)
c1 = hsl(hh,ss,ll)
float rrr = red(c6)*aa + red(c1)*omaa
float ggg = green(c6)*aa + green(c1)*omaa
float bbb = blue(c6)*aa + blue(c1)*omaa
#color = rgb(rrr,ggg,bbb)
ELSE
hh = (hue(c6)+hh)%6
ss = sat(c6)*aa + ss*omaa
ll = lum(c6)*aa + ll*omaa
#color = hsl(hh,ss,ll)
ENDIF
ENDIF
ENDIF
default:
title = "Mandelbrot Multiwave Coloring"
param power
caption = "Exponent"
default = (2,0)
hint = "This should be set to match the exponent of the \
formula you are using. For Mandelbrot, this is 2. \
Only needed when coloring divergent points."
endparam
color param c1a
caption = "Hue 1A"
default = rgb(130/255,91/255,40/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c2a
caption = "Hue 2A"
default = rgb(186/255,153/255,102/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c3a
caption = "Hue 3A"
default = rgb(248/255,114/255,12/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c4a
caption = "Hue 4A"
default = rgb(74/255,0,0)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
param hfreq1
caption = "Short hue shift period (iters)"
default = 530.0
hint = "Changes the period of the short hue modification cycle. Early in the long cycle it will cycle among the four colors above."
endparam
color param c1b
caption = "Hue 1B"
default = rgb(77/255,49/255,19/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c2b
caption = "Hue 2B"
default = rgb(195/255,179/255,131/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c3b
caption = "Hue 3B"
default = rgb(231/255,227/255,23/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c4b
caption = "Hue 4B"
default = rgb(240/255,164/255,0)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c1c
caption = "Hue 1C"
default = rgb(0,72/255,16/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c2c
caption = "Hue 2C"
default = rgb(133/255,146/255,128/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c3c
caption = "Hue 3C"
default = rgb(179/255,220/255,72/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c4c
caption = "Hue 4C"
default = rgb(243/255,224/255,83/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c1d
caption = "Hue 1D"
default = rgb(24/255,23/255,103/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c2d
caption = "Hue 2D"
default = rgb(144/255,143/255,163/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c3d
caption = "Hue 3D"
default = rgb(64/255,153/255,192/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c4d
caption = "Hue 4D"
default = rgb(31/255,173/255,131/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c1e
caption = "Hue 1E"
default = rgb(120/255,22/255,22/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c2e
caption = "Hue 2E"
default = rgb(177/255,129/255,130/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c3e
caption = "Hue 3E"
default = rgb(189/255,65/255,68/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param c4e
caption = "Hue 4E"
default = rgb(33/255,31/255,79/255)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
param hfreq2
caption = "Long hue shift period (iters)"
default = 5147.0
hint = "Changes the period of the long hue modification cycle."
endparam
color param cx
caption = "Superslow bias color 1"
default = rgb(0.5,0.5,0.5)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param cy
caption = "Superslow bias color 2"
default = hsl(0,0.5,0.7)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
color param cz
caption = "Superslow bias color 3"
default = hsl(5,1.0,0.3)
hint = "Altering these hues will alter the way the gradient is modified."
endparam
param sfreq
caption = "Superslow bias period (iters)"
default = 82117.0
hint = "Changes the period of the superslow bias cycle."
endparam
param smode
caption = "Superslow bias mode"
enum = "saturation bias" "hsl bias"
default = 1
hint = "Luminances adjust luminance of colors above; in saturation bias mode hue/saturation adjusts saturation. Hues matching this hue are unchanged, hues opposite have their saturation reduced the higher this color's saturation. The effect is to suppress opposite hues; set this to saturated red to suppress cyan for example. Neutral gray has no effect. In hsl bias mode hsl addition is used instead."
endparam
param spow
caption = "Superslow bias sensitivity"
default = 4.0
min = 0.01
hint = "Higher values narrow the range of hues desaturated; lower ones widen the range. 2 and 0.5 have opposite effects."
endparam
param lfreq
caption = "First luminance shift period (iters)"
default = 17.0
hint = "Changes the period of the first luminance modification cycle. The four colors of the short cycle will change gradually to the second set of four, then the third, then the fourth, before returning."
endparam
param lmag
caption = "First luminance shift amplitude"
default = 0.2
min = 0.0
max = 1.0
hint = "Changes the amplitude of the first luminance modification cycle."
endparam
param lfreq2
caption = "Second luminance shift period (iters)"
default = 94.0
hint = "Changes the period of the second luminance modification cycle."
endparam
param lmag2
caption = "Second luminance shift amplitude"
default = 0.4
min = 0.0
max = 1.0
hint = "Changes the amplitude of the second luminance modification cycle."
endparam
param lfreq3
caption = "Third luminance shift period (iters)"
default = 2544.0
hint = "Changes the period of the third luminance modification cycle."
endparam
param lmag3
caption = "Third luminance shift amplitude"
default = 0.6
min = 0.0
max = 1.0
hint = "Changes the amplitude of the third luminance modification cycle."
endparam
param lfreq4
caption = "Fourth luminance shift period (iters)"
default = 18544.0
hint = "Changes the period of the fourth luminance modification cycle."
endparam
param lmag4
caption = "Fourth luminance shift amplitude"
default = 0.6
min = 0.0
max = 1.0
hint = "Changes the amplitude of the fourth luminance modification cycle."
endparam
param mmode
caption = "Primary gradient merge mode"
enum = "rgb bias" "hsl bias" "rgb blend" "hsl blend"
default = 1
hint = "Affects how the gradient is applied to the color ripples; the blend options use the gradient's alpha"
endparam
param fit
caption = "Fit Gradient to Range"
default = true
hint = "Check this to spread the gradient out over the range of iteration values."
endparam
param fittimes
caption = "Number of repetitions"
default = 1.0
min = 1.0
hint = "Repeats gradient the specified number of times over the range of iteration values."
endparam
param fitminit
caption = "Start iteration"
default = 1.0
min = 1.0
hint = "Gradient begins at this iteration number. It is best if it's approximately the lowest \
actual number of iterations in the image. You can find the exact number by looking at \
Statistics after generating the image once."
endparam
param fitmaxit
caption = "End iteration"
default = 1000.0
min = 1.0
hint = "Gradient fitting is based on this range of iterations. Can be profitably made lower than \
maxiter -- try reducing it by factors of 10 until the gradient doesn't fit well, then raise \
it by a factor of 10 once."
endparam
param transfer
caption = "Super transfer function"
enum = "Linear" "Power" "Log"
default = 2
hint = "Linear distributes gradient evenly over iterations. \
Power weights gradient towards lower iterations for powers > 1. \
Log weights gradient towards lower iterations."
endparam
param transpower
caption = "Transfer power"
default = 3.0
hint = "Larger values weight gradient more towards low iterations. \
3.0 with a regular transfer function of Linear and a super transfer \
function of Linear with a regular transfer function of CubeRoot \
produce the same results."
visible = (@transfer == 1)
endparam
param bailout
caption = "Bail-out value"
default = 100000.0
hint = "Larger gives smoother coloring, up to a point."
min = 1
endparam
param displacement
caption = "Displacement"
default = 0.0
hint = "Skips the first N iterations of the color gradient, effectively shifting the whole color scheme to lower iterations as a block. Use this for testing."
min = 0.0
endparam
param rescale
caption = "Rescaling"
default = 1.0
hint = "Compresses the entire color gradient by this factor, after application of displacement. Use this for testing."
min = 1.0
endparam
}
```

# transformations (*.uxf)

## equirectangular

equirectangular project by pauldelbrot[4]

```float lon = real(#pixel)
float lat = imag(#pixel)
IF ((|lon| > 4) || (|lat| > 1))
#solid = true
ELSE
lon = lon * 0.5 * #pi
lat = (lat * 0.25 + 0.25) * #pi
float r = tan(lat)
#pixel = r*(cos(lon) + (0,1)*sin(lon))
ENDIF

```

Description

• Outside the rectangle will be black (or whatever the transform solid color is set to).
• The rectangle will be in -2 to 2 horizontally and -1 to 1 vertically, so with magnification 1 and center 0 and a 2:1 image aspect ratio it will exactly fill the image rect.
• Inside the rectangle will be an equirectangular projection of the Riemann sphere.
• The #pixel= assignment actually does the transform. The RHS of that assignment is just a final polar-to-cartesian conversion.
• The (0,1) constant is i, the square root of minus one.

## exponential

```ExponentialMap {
; https://fractalforums.org/ultrafractal/59/exponential-map-transform/1697
; Vertical exponential transform.
; Make narrow high window (say 100X800), zoom, put point of interest at bottom.
; Turn on. Tweak with the 2 controls, and select appropriate width (depends on image,
; narrower for deeper zooms).
;
global:
if (4 * #height < 3 * #width)
pixeldim = 3/#magn/#height
else
pixeldim = 4/#magn/#width
endif
w = #width * pixeldim
h = #height * pixeldim
cc = #center
c0 = cc - 1i/2 * h +0i*w -w/4 * @sh
b = w/h*log(#magn) *@b
a = 1i*w/b
transform:
if @ison
c = #pixel
dc = a*(exp(-1i*b/w*(c-c0)))
#pixel = c0+dc
endif
default:
title = "Exponential map"
param ison
caption = "On"
default = false
endparam
float param b
caption = "vert. control"
default = 1.2
endparam
float param sh
caption = "hor. shift"
default = 0
endparam
}
```

# files

• ufr : Fractal Files *.ufr
• upr : Displays parameter files (*.upr) : additional parameters specific to the selected fractal formula
• par : Older Fractint parameter files (*.par)
• ugr : Displays gradient files (*.ugr)
• ual : Older gradient files (*.ual)
• map : Fractint palette files (*.map)
• uxf : Displays transformation files (*.uxf)
• ufm : Displays fractal formula files (*.ufm). Fractal formula files contain multiple fractal formulas. Older Fractint formula files (*.frm) are also shown. See Fractal formulas.
• ucl : Displays coloring algorithm files (*.ucl). See also writing coloring algorithm
• ulb : Displays plug-in library files (*.ulb)

## upr

troubledTree4 by pauldelbrotfractalforums.org: ultrafractal histogram-de-coloring

```a very dense location in the Mandelbrot set, which I have used as a test for various DE methods in the past. This method has given the overall best result here, with one caveat: the spiral centers are too dark, losing detail of  the very center of each one, likely because the sampling grid misses points this close and they are not included in the histogram. With the default settings, this image is computed at 200 megapixels in a day and a half on decent modern hardware; with a higher sampling density it would be significantly slower still.
```
```troubledTree4 {
fractal:
title="troubled tree 4" width=960 height=540 layers=1
credits="Owner;9/9/2023" antialiasing=yes
layer:
caption="Background" opacity=100 method=linear transparent=yes
mapping:
center=-1.1454771035128796953843/0.26992867352137579904915
magn=1.1827E13
formula:
maxiter=1000000 percheck=off filename="Standard.ufm"
entry="FastMandel" p_start=0/0 p_bailout=4.0
inside:
transfer=none
outside:
transfer=linear filename="pgd_DE_histogram.ucl"
entry="pgd_MandelbrotDEH" p_seed=-1/0 p_mand=yes p_swidth=100
p_sheight=100 p_finalheight=1080
smooth=yes index=0 color=8716288 index=100 color=16121855 index=200
color=46591 index=300 color=156
opacity:
smooth=no index=0 opacity=255
}

```

Julia set Dragon for Deh Test ( Distance Estimation Histogram)

```juliaDragonDehTest {
fractal:
title="julia dragon deh test" width=960 height=540 layers=1
credits="Owner;9/10/2023" antialiasing=yes
layer:
caption="Background" opacity=100 method=linear transparent=yes
mapping:
center=0/0 magn=1.6666667
formula:
maxiter=1000000 percheck=off filename="Standard.ufm" entry="Julia"
p_seed=-0.747/0.08 p_power=2/0 p_bailout=1.0E70
inside:
transfer=none
outside:
transfer=linear filename="pgd_DE_histogram.ucl"
entry="pgd_MandelbrotDEH" p_seed=-0.747/0.08 p_mand=no p_swidth=100
p_sheight=100 p_finalheight=1080
smooth=yes index=0 color=8716288 index=100 color=16121855 index=200
color=46591 index=300 color=156
opacity:
smooth=no index=0 opacity=255
}
```

Lichtenberg upr with dense fragment of parameter plane by pauldelbrot[5]

```Lichtenberg {
fractal:
title="Lichtenberg" width=960 height=540 layers=1
credits="Owner;7/1/2020" antialiasing=yes
layer:
caption="Background" opacity=100 method=linear
mapping:
center=-1.1477908048866525/0.2752899772141804 magn=17309286
formula:
maxiter=10000000 filename="Standard.ufm" entry="FastMandel"
p_start=0/0 p_bailout=4.0
inside:
transfer=none
outside:
transfer=linear filename="pgd.ucl" entry="pgd_MSetBoundary4"
p_bwidth=1.0 p_pow=0.5 p_power=2/0 p_mandel=yes p_convergent=no
p_preit=100 p_bailout=100000.0
comments="Use with Lighting coloring algorithm." smooth=yes index=0
color=16777215 index=399 color=0
opacity:
smooth=no index=0 opacity=255
}

pgd.ucl:pgd_MSetBoundary4 {
; A superior distance estimator boundary render that colors
; the boundary using a gradient. Works well with the
; "lighting" gradient. Points not near the boundary get
; solid colored; pixels that contain M-set boundary get
; to approximate the fractal dimension of the boundary, with
; earlier colors indicating D near 1 and later ones
; indicating D close to 2.
;
; It should also work for Julia sets.
;
; Non-z^n + c fractals will not generally give accurate
; results.
;
; Tip: Turn off "repeat gradient" when coloring non-convergent
; points (so, on the Outside tab).
;
; Uses a different algorithm to map distances to grey shades
; than the first two Mandelbrot Boundaries.
;
init:
complex der = 1
complex dc = 0
complex dzz = 0
complex dcz = 0
int i = 0
complex t = 0
bool done = false
bool edge = false
float pixsize = 4*@bwidth/(#magn*#width)
loop:
IF (@convergent && !done)
IF (i == @preit)
t = #z
ELSEIF (i > @preit)
IF (@power != 2)
dzz = @power*(sqr(der)*(@power - 1)*(#z)^(@power - 2) + dzz*(#z)^(@power - 1))
dcz = @power*(der*dc*(@power - 1)*(#z)^(@power - 2) + dcz*(#z)^(@power - 1))
der = @power*der*(#z)^(@power - 1)
dc = @power*dc*(#z)^(@power - 1)
; Generalized from below to z^n + c.
ELSE
dzz = 2*(sqr(der) + #z*dzz)
dcz = 2*(der*dc + #z*dcz)
der = 2*der*#z
dc = 2*dc*#z + 1
; From TSOFI D.2 "Finding Disks in the Interior of M".
ENDIF
IF (|#z - t| < (1/@bailout))
done = true
IF (|der| >= 1)
edge = true ; Misiurewicz point or component boundary
ENDIF
ENDIF
ENDIF
i = i + 1
ELSEIF (!done)
IF (@power != 2)
der = @power*der*(#z)^(@power - 1)
; Generalized from below to z^n + c.
ELSE
der = 2*der*#z
; From TSOFI D.1 "Bounding the Distance to M"
ENDIF
IF (@mandel)
der = der + 1
ENDIF
ENDIF
final:
float dist = 0
IF (@convergent)
complex cc = 1 - der
complex dd = dc*conj(cc)/|cc|
complex ee = dcz + dzz*dd
dist = 0.25*(1.0 - |der|)/cabs(ee)
ELSE
float d = cabs(#z)
dist = real(d*log(d)*0.5/cabs(der))
ENDIF
IF (edge)
dist = 1.0
ENDIF
IF ((dist < pixsize) && (done || (!@convergent)))
; Pixel contains boundary points.
dist = dist / pixsize
IF (@pow < 0)
dist = 1 - dist ^ (1/@pow)
ELSE
dist = dist ^ (1/@pow)
ENDIF
#index = 4*atan(log(1/dist))/#pi - 1
ELSEIF (@convergent && (!done))
; Probably right on the edge.
#index = 1.0
ELSE
; Pixel does not contain boundary points.
#solid = true
ENDIF
default:
title = "Mandelbrot Boundary 4"
caption = "Coloring settings"
param bwidth
caption = "Border width (pix)"
default = 1.0
min = 0.0
hint = "Border width in pixels. You may want to reduce \
this for antialiased renders."
endparam
param pow
caption = "Curve Power"
default = 1.0
hint = "Adjusting this affects how fast the gradient changes in denser \
parts of the m-set boundary. Try adjusting it if filaments are \
too dark or seahorse centers are washed out."
endparam
caption = "Formula settings"
param power
caption = "Exponent"
default = (2,0)
hint = "This should match the power used in the Mandelbrot \
or Julia formula parameters."
endparam
param mandel
caption = "Mandelbrot"
default = true
hint = "Uncheck this for Julia fractals."
endparam
param convergent
caption = "Convergent"
default = false
visible = (@mandel)
hint = "Check this to color Mandelbrot interior points \
close to the boundary."
endparam
caption = "Cycle-detection tuning"
visible = (@mandel && @convergent)
param preit
caption = "Preiterations"
default = 100
min = 0
visible = (@mandel && @convergent)
hint = "Iterations to calculate before looking for a cycle \
when estimating interior distances. Larger values \
make cycle detection more accurate."
endparam
param bailout
caption = "Bailout"
default = 100000.0
min = 0.0
hint = "Larger values make cycle detection more accurate, \
but more preiterations are needed."
visible = (@mandel && @convergent)
endparam
}
```

## ucl

Coloring algorithms:

• are stored in coloring algorithm files (*.ucl). Each file can contain multiple coloring algorithms.
• define how fractals are colored. The fractal formula creates the basic shape of the fractal, and coloring algorithms provide ways to color that shape. This gives you the flexibility to freely combine coloring algorithms with any fractal formula.

Examples:

```Mu-Ency(OUTSIDE) {
;
; Hybrid direct colouring scheme combining dwell, binary decomposition and distance estimator.
;
; Written by Aleph0, based on an algorithm designed by Robert Munafo and documented here:
;
;	http://mrob.com/pub/muency/color.html
;
;
;	http://mrob.com/pub/muency/demdwellhybrid.html
;	http://mrob.com/pub/muency/binarydecomposition.html
;
; The above pages are part of Robert's Mu-Ency Encyclopedia of the Mandelbrot Set web site:
;
;	http://mrob.com/pub/muency.html
;
; This is a good colouring scheme to use when exploring and studying the structure of the Mandelbrot Set at deep zoom levels, as the distance
; estimator scales automatically to reflect the zoom level and the colouring effects are subtle enough to not detract from the filament detail.
; Conventional colouring approaches that use dwell and a wide colour pallette can be problematic at deep zoom levels, as they introduce excessive
; noise that tends to obscure the structure of the set's connecting filaments.
;
; I have followed Robert's general design, but implemented the following user-configurable settings for individual elements of the scheme. The
; default settings match the style used for most of the images hosted at the Mu-Ency web site.
;
;	- Binary decomposition (checker-board) effect can be switched on or off (default = on).
;	- Dwell band lightening can selected for either odd or even numbered stripes (default = odd).
;	- Rainbow effect can be switched on or off (default = off).
;	- Distance estimator filament widths can be scaled (multiplier values 0.01-100, default = 1).
;	- Dwell colour slope is adjustable (log base selectable 2.0-1000000.0, default 80).
;	- Dwell colour pallette starting point can be rotated (range 0.0-6.0, default 0).
;
; NOTE: Set Inside Solid Colour = White to match the style used for most of the images hosted at the Mu-Ency web site.
;
global:
\$define DEBUG
float pixel_spacing = 4 / (#magn * #width)		; Unzoomed Mandelbrot set width = 4.0.
init:
float angle = 0
complex dz = (0,0)
float distance_estimate = 0
float dscale = 0
int dwell = 0
float D = 0
;  float finalang = 0
float hue = 0
float P = 0
float saturation = 0
float value = 0
float z = 0
loop:
dz = @power * #z^(@power-1) * dz + 1
final:
z = cabs(#z)		; Reordered relative to Robert's description, for substitution into D formula, hence avoiding repetition of cabs calculation.
D = #numiter + log(log(z)/log(2))/log(2) - log(log(128)/log(2))/log(2)
dwell = floor(D)
;  finalang = atan(imag(#z)/real(#z))
distance_estimate = (log(z*z) * z)/cabs(dz)
dscale = log(distance_estimate/(10 * @DE_width * pixel_spacing))/log(2)
; Convert scaled distance estimate to value (luminance in HSL colour space) from 0.0 to 1.0 in 8 bands.
if dscale > 0
value = 1.0
elseif dscale > -8
value = (8 + dscale)/8
else
value = 0
endif
; Scale value downwards, as 1.0 results in colour white. Spec may be wrong - washes out colours with that range.
value = value*0.65
; Apply logarithmic scaling to dwell.
P = log(dwell)/log(@C_slope)		; Mu-Ency algorithm specifies 100000, but that makes colours change too slowly.
;  P = dwell
; Map scaled dwell to an angle and radius on the colour wheel.
if P < 0.5
P = 1.0 - 1.5*P
angle = 1 - P
else
P = 1.5*P - 0.5
angle = P
endif
; Make every even or odd numbered stripe a bit lighter, dependent on setting of stripe_phase parameter.
if (dwell + @stripe_phase) % 2 == 1
value = 0.85 * value
endif
; Break the stripes into squares to make the external angles evident. In combination with the stripes, produces a checkerboard appearance.
;  if finalang > #pi	; Mu-Ency algorithm specifies > pi, but that's impossible. However, page http://mrob.com/pub/muency/binarydecomposition.html
; specifies testing for positive imaginary component of final iteration.
if @binary == 1 && imag(#z) < 0
angle = angle + 0.1	; Mu-Ency algorithm specifies 0.02, but that's not generally enough.
endif
if @rainbow == 1
angle = angle + 0.2 * finalrad	; Mu-Ency algorithm specifies 0.0001, but effect is then invisible.
endif
; Set up the hue.
;  hue = angle * 10.0				; I think multiplier 10 in spec may be wrong; band colours change too rapidly?
hue = angle
hue = (hue - floor(hue))*6		; Hue is in range 0-6 for Ultra Fractal, scale up from 0-1.
hue = (hue + @C_rotation) % 6				; Hue starts at red in UF, rotate by 3 to start at cyan.
; Set up the saturation.
;  saturation = radius - floor(radius)					; This wraps to zero saturation (flat grey) when radius reaches a new integer!
saturation = 0.7 + 0.3 * (radius - floor(radius))		; This wraps to 0.7 saturation.
;  if real(#screenpixel) == 0 && imag(#screenpixel) == 0
;    int i = #numiter
;	print("-----")
;    print("screenpixel = ", #screenpixel, " ... finaliter = ", i)
;	print("#z = ", #z, " ... z = ", z)
;	print("D = ", D, " ... dwell = ", dwell, " ... finalrad = ", finalrad)
;	print("dscale = ", dscale, " ... value = ", value)
;	print("P = ", P, " ... angle = ", angle, " ... radius = ", radius)
;	print("hue = ", hue, " ... saturation = ", saturation)
;  endif
; Set pixel colour using HSL colour model (hue, saturation, luminance).
;  #color = hsl(hue, 1.0, 1.0)
#color = hsl(hue, saturation, value)
default:
title = "Mu-Ency"
float param power
caption = "Exponent"
default = 2.0
hint = "This should be set to match the exponent of the \
formula you are using. For Mandelbrot, this is usually 2."
endparam
int param binary
caption = "Binary decomposition"
enum = "Off" "On"
default = 1
hint = "Set on to enable binary decomposition, off to disable."
endparam
int param stripe_phase
caption = "Dwell stripe phase"
enum = "Even" "Odd"
default = 1
hint = "Selects whether to lighten odd or even dwell stripes."
endparam
int param rainbow
caption = "Rainbow effect"
enum = "Off" "On"
default = 0
hint = "Set on to enable rainbow effect, off to disable."
endparam
float param DE_width
caption = "DE width"
default = 1.0
min = 0.01
Max = 100
hint = "Width multiplier for filaments rendered by distance estimator."
endparam
float param C_slope
caption = "Colour slope."
default = 80.0
min = 2.0
Max = 1000000.0
hint = "Rate at which dwell colouring changes; lower values = faster changes, higher = slower."
endparam
float param C_rotation
caption = "Colour rotation."
default = 5.0
min = 0.0
Max = 6.0
hint = "Rotates starting point of dwell colour pallette; adjust to obtain desired colours."
endparam
}

Monochrome DE(OUTSIDE) {
;
; Monochrome distance estimator colouring scheme with configurable colours for outside set and near to set. Inside set colour can also
; be configured using Ultra Fractal's Inside layer properties.
;
; Written by Aleph0, based on a distance estimator algorithm designed by Robert Munafo and documented here:
;
;	http://mrob.com/pub/muency/color.html
;
; The above page is part of Robert's Mu-Ency Encyclopedia of the Mandelbrot Set web site:
;
;	http://mrob.com/pub/muency.html
;
; This is a good colouring scheme to use when exploring and studying the structure of the Mandelbrot Set at deep zoom levels, as the distance
; estimator scales automatically to reflect the zoom level. Conventional colouring approaches that use dwell and a wide colour pallette can be
; problematic at deep zoom levels, as they introduce excessive noise that tends to obscure the structure of the set's connecting filaments.
;
; The following user-configurable settings are available:
;
;	- Near colour can be selected (selects colour of points near the set, i.e. the filaments, colour darkens progressively to black based on
;	proximity to the set, default = black giving a grey scale transition to black).
;	- Blend outside and near colours. On = blend, off = use near colour directly. Both effects can be useful, dependent on the colour
;	combinations selected.
;	- Distance estimator filament widths can be scaled (multiplier values 0.01-100, default = 1).
;
; NOTE: Use Solid Colour setting in the Inside and Outside layer property pages to set the fill colour for inside and outside the set,
; respectively. Select same colour for inside set and near set for monochrome renderings, e.g. to .
;
global:
\$define DEBUG
float pixel_spacing = 4 / (#magn * #width)		; Unzoomed Mandelbrot set width = 4.0.
init:
complex dz = (0,0)
float distance_estimate = 0
float dscale = 0
float value = 0
float z = 0
loop:
dz = @power * #z^(@power-1) * dz + 1
final:
;  #solid = false
z = cabs(#z)
distance_estimate = (log(z*z) * z)/cabs(dz)
dscale = log(distance_estimate/(10 * @DE_width * pixel_spacing))/log(2)
; Convert scaled distance estimate to value (outside/DE blend if blend on, luminance if blend off) from 0.0 to 1.0 in 8 bands.
if dscale > 0
#color = hsl(hue(@outside_colour), sat(@outside_colour), lum(@outside_colour))
else
if @DE_smooth == 0
if dscale > -1
#color = hsl(hue(@outside_colour), sat(@outside_colour), lum(@outside_colour))
else
#color = hsl(hue(@DE_colour), sat(@DE_colour), lum(@DE_colour))
endif
else
if dscale > -8
value = (8 + dscale)/8
else
value = 0
endif
value = value ^ @DE_slope
;      print("dscale = ", dscale, "... value = ", value)
#color = blend(@DE_colour, @outside_colour, value)
endif
endif
;  if real(#screenpixel) == 0 && imag(#screenpixel) == 0
;    int i = #numiter
;	print("-----")
;    print("screenpixel = ", #screenpixel, " ... finaliter = ", i)
;	print("#z = ", #z, " ... z = ", z)
;	print("dscale = ", dscale, " ... value = ", value)
;  endif
default:
title = "Monochrome DE"
float param power
caption = "Exponent"
default = 2.0
hint = "This should be set to match the exponent of the \
formula you are using. For Mandelbrot, this is usually 2."
endparam
color param outside_colour
caption = "Outside colour"
default = rgb(255,255,255)
hint = "Colour to be used for points outside set."
endparam
color param DE_colour
caption = "DE colour"
default = rgb(0,0,0)
hint = "Colour to be used for distance estimator filaments."
endparam
int param DE_smooth
caption = "DE smoothing"
enum = "Off" "On"
default = 1
hint = "On = use filament smoothing, off = no filament smoothing."
endparam
float param DE_width
caption = "DE width"
default = 1.0
min = 0.00001
Max = 100
hint = "Width multiplier for filaments rendered by distance estimator."
endparam
float param DE_slope
caption = "DE slope"
default = 1.0
min = 0.01
Max = 100.0
hint = "Slope for transition to DE colour: 1.0 = linear from threshold to set; \
< 1.0 = slow change near threshold accelerating to rapid change near set; \
> 1.0 = rapid change at threshold decelerating to slow change near set."
endparam
}

DistanceEstimatorScaled(OUTSIDE) {
;
; Distance-estimator coloring algorithm for Mandelbrot and
; other z^n fractal types (Phoenix, Julia). This coloring
; algorithm estimates the distance to the boundary of the
; fractal (for example the Mandelbrot set) and colors points
; accordingly.
;
; Written by Damien M. Jones.
; Modified by Aleph0 to scale the distance estimate with zoom.
;
global:
\$define DEBUG
float pixel_spacing = 4 / (#magn * #width)		; Unzoomed Mandelbrot set width = 4.0.
init:
complex dz = (0,0)
loop:
dz = @power * #z^(@power-1) * dz + 1
final:
#index = (@power*log(cabs(#z)) * (cabs(#z)) / (cabs(dz) * 100000 * @DE_width * pixel_spacing))^(1/@power)
default:
title = "Distance Estimator Scaled"
helpfile = "Uf*.chm"
helptopic = "Html/coloring/standard/distanceestimator.html"
param power
caption = "Exponent"
default = 2.0
hint = "This should be set to match the exponent of the \
formula you are using. For Mandelbrot, this is usually 2."
endparam
float param DE_width
caption = "DE width"
default = 1.0
min = 0.00001
Max = 10000000
hint = "Width multiplier for filaments rendered by distance estimator."
endparam
}
```

### uxf

Transformations globally transform and warp the shape of a fractal. You can combine various transformations to create complex effects.