gradient_reference {
fractal:
  title="gradient_linear_smooth" width=800 height=6 layers=1
  credits="steamuser;4/4/2026" antialiasing=yes
layer:
  caption="Background" opacity=100 method=multipass
mapping:
  center=0.5/0 magn=1 stretch=400
formula:
  maxiter=250 percheck=off filename="as.ufm" entry="Pixel"
  p_bailout=999999 p_a=1.0/0.0 p_b=1.0/0.0
inside:
  transfer=linear filename="phs.ucl" entry="GnarlAlgo" p_density=1
  p_colorBy="real(end)"
outside:
  transfer=linear filename="Standard.ucl" entry="Smooth" p_power=2/0
  p_bailout=128.0
gradient:
  smooth=yes rotation=1 index=0 color=6555392 index=64 color=13331232
  index=168 color=16777197 index=257 color=43775 index=343 color=512
opacity:
  smooth=no index=0 opacity=255
}

as.ufm:Pixel {
;Use inside color.
;Andrea Spinozzi

Init:

z=#pixel

Loop:

 z=#pixel^(@a*@b)

Bailout:

 |z|<@bailout


Default:

 title="Pixel"
 maxiter=250
 method=multipass
 periodicity=0


param bailout
 caption="Bailout"
 default=10.0
 min=0.0
endparam

param a
 caption="Parameter 1"
 default=(1.0,0.0)
endparam

param b
 caption="Parameter 2"
 default=(1.0,0.0)
endparam

}

phs.ucl:GnarlAlgo {
init:
  float path = 0.
  complex zold = #pixel
  float twoPi = 2. * #pi
  float invTwoPi = 1. / twoPi
  float max_step = 0.
  float step = 0.
  float tca = 0.
loop:
  step = cabs(#z - zold)
  if max_step < step
    max_step = step
  endif
  if @colorBy == "total change in angle"
    tca = tca + atan2(#z - zold + 6 * #pi)
  endif
  path = path + step
  zold = #z
final:
  if @colorBy == "Total Path Length"
    #index = @density * path
  elseif @colorby == "Angle of End"
    #index = @density * invTwoPi *(#pi + atan2(#z))
  elseif @colorby == "Total Path * Angle of End"
    #index = @density * invTwoPi *(#pi + atan2(#z)) * path
  elseif @colorBy == "cabs(end - start)"
    #index = cabs(#z - #pixel)
  elseif @colorBy == "cabs(end)"
    #index = cabs(#z)
  elseif @colorBy == "cabs(end) - cabs(start)"
    #index = cabs(cabs(#z) - cabs(#pixel))
  elseif @colorBy == "Change in Angle"
    #index = cabs(invTwoPi *(#pi + atan2(#z)) - invTwoPi *(#pi + atan2(#pixel)))
  elseif @colorBy ==  "Radius * Change in Angle"
    #index = cabs(#z) * (cabs(invTwoPi *(#pi + atan2(#z)) - invTwoPi *(#pi + atan2(#pixel))))
  elseif @colorBy == "Argument of end - start"
    #index = invTwoPi * (#pi + atan2(#z - #pixel))
  elseif @colorBy == "Arg of end - Arg of start"
    #index = invTwoPi * (#pi + atan2(#z) - atan2(#pixel))
  elseif @colorBy == "Largest Single Step"
    #index = max_step
  elseif @colorBy == "log(log(cabs(end)))"
    #index = log(1. + log(1. + cabs(#z)))
  elseif @colorBy == "total change in angle"
    #index = abs(tca)
  elseif @colorBy == "length of last step"
    #index = step
  elseif @colorBy == "Abs(end - start) / Total Path Length"
    #index = cabs(#z - #pixel) / path
  elseif @colorBy == "real(end)"
    #index = abs(real(#z))
  elseif @colorBy == "imag(end)"
    #index = abs(imag(#z))
  elseif @colorBy == "sin(imag(end))"
    #index = 0.5 + 0.5 * sin(@density * imag(#z))
  endif
default:
  title = "Gnarl Coloring"
  float param density
    default = 1.
  endparam
  param colorBy
    default = 0
    enum = "Total Path Length" "Angle of End" "cabs(end)" "Total Path * Angle of End" "cabs(end - start)" \
           "Arg of end - Arg of start" "cabs(end) - cabs(start)" "Change in Angle" "Radius * Change in Angle" \
           "Argument of end - start" "Largest Single Step" "log(log(cabs(end)))" "total change in angle" \
           "length of last step" "Abs(end - start) / Total Path Length" "real(end)" "imag(end)" \
           "sin(imag(end))"
  endparam

}

