common
Class ColorTrapFormulaDirectColoring

Object
  extended by common:Generic
      extended by common:ColorTrap
          extended by common:ColorTrapFormulaDirectColoring

class 
ColorTrap:ColorTrapFormulaDirectColoring

Use any fractal formula and direct coloring as a color trap.


Ultra Fractal Source

Toggle UF Source Code Display

 class ColorTrapFormulaDirectColoring(ColorTrap) {
   ; Use any fractal formula and direct coloring as a color trap.
   
 public:
   import "Standard.ulb"
 
   func ColorTrapFormulaDirectColoring(Generic pparent)
     ColorTrap.ColorTrap(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)
     ColorTrap.Init(pz)
     
     m_StartZ = pz
   endfunc
 
   color func Iterate(complex pz)
     ColorTrap.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    
     color c
     if (@p_samecoloring < 2 && !bailed)
       if (@p_samecoloring == 0)
         c = m_InsideColoring.Result(pz)
         if (m_InsideColoring.IsSolid())
           c = @p_insidesolid
         endif
       else
         c = m_OutsideColoring.Result(pz)
         if (m_OutsideColoring.IsSolid())
           c = @p_insidesolid
         endif
       endif
     else
       c = m_OutsideColoring.Result(pz)
       if (m_OutsideColoring.IsSolid())
         c = @p_outsidesolid
       endif
     endif
 
     return c
   endfunc
 
 protected:
   Transform m_Location
   Formula m_Formula
   Coloring m_InsideColoring
   Coloring m_OutsideColoring
   complex m_StartZ
 
 default:
   title = "Formula + Direct Coloring Trap"
   
   int param v_colortrapformuladirectcoloring
     caption = "Version (ColorTrapFormulaDirectColoring)"
     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_colortrapformuladirectcoloring < 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
   Coloring param f_insidecoloring
     caption = "Coloring Formula"
     default = Standard_Smooth
     hint = "Sets the coloring formula to use for inside pixels."
     visible = (@p_samecoloring < 1)
   endparam
   color param p_insidesolid
     caption = "Solid Color"
     default = rgb(0,0,0)
     hint = "Sets the solid color for inside pixels."
     visible = (@p_samecoloring < 2)
   endparam
   
   heading
     caption = "Outside Coloring"
     expanded = true
   endheading
   Coloring param f_outsidecoloring
     caption = "Coloring Formula"
     default = Standard_Smooth
     hint = "Sets the coloring formula to use for outside pixels."
   endparam
   color param p_outsidesolid
     caption = "Solid Color"
     default = rgb(0,0,0)
     hint = "Sets the solid color for outside pixels."
   endparam
 }
 


Constructor Summary
ColorTrapFormulaDirectColoring()
           
ColorTrapFormulaDirectColoring(Generic pparent)
           
 
Method Summary
 void Init(complex pz)
          call this before each sequence of values to be trapped
 color Iterate(complex pz)
          call this to produce a result you should always override this function
 
Methods inherited from class common:ColorTrap
IterateSilent
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

ColorTrapFormulaDirectColoring

public ColorTrapFormulaDirectColoring(Generic pparent)

ColorTrapFormulaDirectColoring

public ColorTrapFormulaDirectColoring()
Method Detail

Init

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

Overrides:
Init in class ColorTrap

Iterate

public color Iterate(complex pz)
Description copied from class: ColorTrap
call this to produce a result you should always override this function

Overrides:
Iterate in class ColorTrap