common
Class TrapShapeFormulaGradientColoring

Object
  extended by common:Generic
      extended by common:TrapShape
          extended by common:TrapShapeFormulaGradientColoring

class 
TrapShape:TrapShapeFormulaGradientColoring

Use any fractal formula and gradient coloring as a trap shape.


Ultra Fractal Source

Toggle UF Source Code Display

 class TrapShapeFormulaGradientColoring(TrapShape) {
   ; Use any fractal formula and gradient coloring as a trap shape.
   
 public:
   import "Standard.ulb"
 
   func TrapShapeFormulaGradientColoring(Generic pparent)
     TrapShape.TrapShape(pparent)
 
     m_Location = new @f_location(this)    
     m_Formula = new @f_formula(this)
     if (@p_samecoloring == 0)
       m_InsideColoring = new @f_insidecoloring(this)
     endif
     m_OutsideColoring = new @f_outsidecoloring(this)
   endfunc
   
   func Init(complex pz)
     TrapShape.Init(pz)
     
     m_StartZ = pz
   endfunc
 
   float func Iterate(complex pz)
     TrapShape.Iterate(pz)
 
     ; determine start value
     complex sz
     if (@p_startz == 0)
       sz = m_StartZ
     else
       sz = pz
     endif
     m_Location.Init(sz)      ; transform according to location
     sz = m_Location.Iterate(sz)
 
     ; initialize formula and colorings
     complex fz = m_Formula.Init(sz)  ; first z value
     if (@p_startz > 0)
       pz = fz
     endif
     
     if (@p_samecoloring == 0)
       m_InsideColoring.Init(pz, sz)
     endif
     m_OutsideColoring.Init(pz, sz)
 
     ; perform iteration loop
     int j = 0
     bool bailed = false
     while (j < @p_maxiter && !bailed)
       pz = m_Formula.Iterate(pz)
       bailed = m_Formula.IsBailedOut(pz)
       if (!bailed)
         if (@p_samecoloring == 0)
           m_InsideColoring.Iterate(pz)
         endif
         m_OutsideColoring.Iterate(pz)
       endif
       j = j + 1
     endwhile
 
     ; determine coloring    
     float c
     if (@p_samecoloring < 2 && !bailed)
       if (@p_samecoloring == 0)
         c = m_InsideColoring.ResultIndex(pz)
         if (m_InsideColoring.IsSolid())
           c = 1e20
         endif
       else
         c = m_OutsideColoring.ResultIndex(pz)
         if (m_OutsideColoring.IsSolid())
           c = 1e20
         endif
       endif
     else
       c = m_OutsideColoring.ResultIndex(pz)
       if (m_OutsideColoring.IsSolid())
         c = 1e20
       endif
     endif
 
     return c
   endfunc
 
 protected:
   Transform m_Location
   Formula m_Formula
   GradientColoring m_InsideColoring
   GradientColoring m_OutsideColoring
   complex m_StartZ
 
 default:
   title = "Formula + Gradient Coloring Trap"
   
   int param v_trapshapeformulagradientcoloring
     caption = "Version (TrapShapeFormulaGradientColoring)"
     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_trapshapeformulagradientcoloring < 100
   endparam
 
   int param p_maxiter
     caption = "Maximum Iterations"
     default = 16
     hint = "Sets the number of iterations of the fractal formula to do. Note that all of these iterations are typically done for EVERY iteration of the main fractal, so setting this number high can slow down rendering substantially."
   endparam
   Transform param f_location
     caption = "Location"
     default = Location
     hint = "Sets the location of the fractal formula. These options are similar to those on the Location tab, but only apply to this interior fractal formula."
   endparam
 
   heading
     caption = "Fractal"
     expanded = true
   endheading
   Formula param f_formula
     caption = "Fractal Formula"
     default = Standard_Mandelbrot
     hint = "Sets the fractal formula to use."
   endparam
   int param p_startz
     caption = "Starting Value"
     default = 1
     enum = "first z" "every z"
     hint = "Sets how the starting value for the fractal formula is chosen. 'First z' uses the first iteration's value for every subsequent iteration (so the fractal formula is started the same way, but the subsequent values are different). 'Every z' uses each iteration's value to start a completely new sequence."
   endparam
 
   heading
     caption = "Inside Coloring"
     expanded = false
   endheading
   int param p_samecoloring
     caption = "Duplicate Outside"
     default = 0
     enum = "none" "coloring algorithm only" "everything"
     hint = "Sets how much of the outside coloring to re-use for the inside. Using this option is more efficient than copying all the settings from the outside coloring to the inside."
   endparam
   GradientColoring param f_insidecoloring
     caption = "Coloring Formula"
     default = Standard_Smooth
     hint = "Sets the coloring formula to use for inside pixels."
     visible = (@p_samecoloring < 1)
   endparam
   
   heading
     caption = "Outside Coloring"
     expanded = true
   endheading
   GradientColoring param f_outsidecoloring
     caption = "Coloring Formula"
     default = Standard_Smooth
     hint = "Sets the coloring formula to use for outside pixels."
   endparam
 }
 


Constructor Summary
TrapShapeFormulaGradientColoring()
           
TrapShapeFormulaGradientColoring(Generic pparent)
           
 
Method Summary
 void Init(complex pz)
          call this before each sequence of values to be trapped
 float Iterate(complex pz)
          call this for each iteration being trapped
 
Methods inherited from class common:TrapShape
GetColorChannel, GetTextureValue, GetTransformedPoint, IterateSilent, SetThreshold
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

TrapShapeFormulaGradientColoring

public TrapShapeFormulaGradientColoring(Generic pparent)

TrapShapeFormulaGradientColoring

public TrapShapeFormulaGradientColoring()
Method Detail

Init

public void Init(complex pz)
Description copied from class: TrapShape
call this before each sequence of values to be trapped

Overrides:
Init in class TrapShape

Iterate

public float Iterate(complex pz)
Description copied from class: TrapShape
call this for each iteration being trapped

Overrides:
Iterate in class TrapShape