## reb Class REB_DistanceEstimateGradient

```Object
common:Generic
common:Coloring
```

`class GradientColoring:REB_DistanceEstimateGradient`

A smoothing algorithm that works for both convergent and divergent fractals.

Ultra Fractal Source
``` class REB_DistanceEstimateGradient(common.ulb:GradientColoring) {
; A smoothing algorithm that works for both convergent and divergent fractals. <br>
public:
import "common.ulb"
import "dmj5.ulb"

; constructor
m_Texture = new @ftexture(this)
endfunc

; initialize the objects
func Init(complex pz, complex ppixel)
m_Texture.Init(pz)
m_iterexp = 0
m_zold = pz
dist = 0
pot = 0
inc = 0
endfunc

; call for each iterated point
func Iterate(complex pz)
m_iterexp = m_iterexp + exp(-cabs(pz)-0.5/(cabs(m_zold - pz)))
inc = exp(-cabs(pz)-0.5/(cabs(m_zold - pz)))
if (@mtile == "Fixed Iteration" && m_iterations == @iternum) || \
(@mtile == "Cabs(z)" && cabs(pz) < @tcabs)|| @mtile == "none"
ptexture = m_Texture.Iterate(pz)
endif
m_zold = pz
endfunc

; override the parent and call in the final section of the coloring formula. <br>
float func ResultIndex(complex pz)
pot = exp(-m_iterexp*log(2))
float returnval = 0
if @showborder
if dist < @border
returnval = ptexture*@txamt
else
m_solid = true
endif
else
returnval = dist + ptexture*@txamt
endif
return returnval
endfunc

protected:
float ptexture
TrapShape m_Texture
float m_iterexp
complex m_zold
float dist
float inc
float pot

default:
title = "Distance Estimate Gradient"
caption = "Version (Distance Estimate Gradient)"
default = 100
hint = "This version parameter is used to detect when a change has been made to the formula that is incompatible with the previous version. When that happens, this field will reflect the old version number to alert you to the fact that an alternate rendering is being used."
visible = @v_distanceestimategrad < 100
endparam
text = "This is a gradient coloring formula with textures which works \
for both convergent and divergent \
fractals. It is highly recommended that the divergent bailout be \
set to at least 1e8 and the convergent bailout be set to no more than \
1e-8. If this is not done then the smoothing may be unsatisfactory. \
It works with fractals that have both divergent and convergent regions, \
such as the Magnet fractals."
caption = "Gradient Correction"
default = 1.0
endparam
bool param showborder
caption = "Show border only"
default = false
endparam
float param border
caption = "borderwidth"
default = 0.01
visible = @showborder
endparam
float param txamt
caption = "Texture amount"
default = 0.0
visible = @fTexture != DMJ_TrapShapeFlat
endparam
text = "Fixed Iteration will give a smoother tiling, while 'Cabs(z)' \
will more consistently follow the fractal shape."
visible = @fTexture != DMJ_TrapShapeFlat
param mtile
caption = "Tile method"
default = 1
enum = "None" "Fixed Iteration" "Cabs(z)"
visible = @fTexture != DMJ_TrapShapeFlat
endparam
int param iternum
caption = "Iter number"
default = 1
hint = "Changes the texture mapping."
visible = @fTexture != DMJ_TrapShapeFlat && \
@mtile == "Fixed iteration"
endparam
float param tcabs
caption = "Cabs limit"
default = 1.0
visible = @mtile == "Cabs(z)"
hint = "Changes the texture/image mapping."
visible = @fTexture != DMJ_TrapShapeFlat
endparam
TrapShape param fTexture
caption = "Texture"
default = DMJ_TrapShapeFlat
hint = "Use TrapShape plugins as textures."
endparam
}
```

Constructor Summary
`REB_DistanceEstimateGradient()`

`REB_DistanceEstimateGradient(Generic pparent)`
constructor

Method Summary
` void` ```Init(complex pz, complex ppixel)```
initialize the objects
` void` `Iterate(complex pz)`
call for each iterated point
` float` `ResultIndex(complex pz)`
override the parent and call in the final section of the coloring formula.

Methods inherited from class common:GradientColoring
`IsGradient, IsSolid, Result`

Methods inherited from class common:Coloring
`GetPixel`

Methods inherited from class common:Generic
`GetParent`

Methods inherited from class Object

Constructor Detail

`public REB_DistanceEstimateGradient(Generic pparent)`
constructor

`public REB_DistanceEstimateGradient()`
Method Detail

### Init

```public void Init(complex pz,
complex ppixel)```
initialize the objects

Overrides:
`Init` in class `GradientColoring`
Parameters:
`pz` - first value for the sequence; for a normal coloring formula, this will be #z
`ppixel` - seed value for the sequence; for a normal coloring formula, this will be #pixel

### Iterate

`public void Iterate(complex pz)`
call for each iterated point

Overrides:
`Iterate` in class `GradientColoring`
Parameters:
`pz` - next value in the sequence; corresponds to #z in a coloring formula

### ResultIndex

`public float ResultIndex(complex pz)`
override the parent and call in the final section of the coloring formula.

Overrides:
`ResultIndex` in class `GradientColoring`
Returns:
the gradient index (corresponding to #index in a coloring formula)