kcc5
Class KCC_PetalsTrap

Object
  extended by common:Generic
      extended by common:TrapShape
          extended by kcc5:KCC_PetalsTrap

class 
TrapShape:KCC_PetalsTrap

The Petals trap.

When this trap is used with the Orbit Traps Direct (UF5) coloring in dmj5.ucl, the Trap Threshold value needs to be greater than or equal to the Petal Size parameter to produce a result similar to the Petals mode in Carlson Orbit Traps in kcc3.ucl.

For an example of what this trap looks like, click here.


Ultra Fractal Source

Toggle UF Source Code Display

 class KCC_PetalsTrap( common.ulb:TrapShape ) {
 ; The Petals trap.
 ; <p>
 ; When this trap is used with the <em>Orbit Traps Direct (UF5)</em>
 ; coloring in dmj5.ucl, the Trap Threshold value needs to be greater
 ; than or equal to the Petal Size parameter to produce a result similar
 ; to the Petals mode in <em>Carlson Orbit Traps</em> in kcc3.ucl.
 ; <p>
 ; For an example of what this trap looks like,
 ; <a href="../additional/kcc5/images/Petals Trap.jpg">click here</a>.
 ;
 public:
   import "common.ulb"
 
   ; constructor
   func KCC_PetalsTrap( Generic pparent )
     TrapShape.TrapShape( pparent )
   endfunc
 
   ; call this before each sequence of values to be trapped
   func Init( complex pz )
     TrapShape.Init( pz )
 
     r = @petalSize
     ro = r + r * @petalOffset
     r2 = r * r
     f = 1 - 2 * @petalOffset - @petalOffset * @petalOffset
     k = @petalOffset * r + r * sqrt (f)
     plsqd = 2 * r2 * f
   endfunc
 
   ; call this for each iteration being trapped
   float func Iterate( complex pz )
     TrapShape.Iterate( pz )
 
     trapped = false
 
     float d = 0.0
     float zr = real( pz )
     float zi = imag( pz )
     bool c1 = (((zr - ro) * (zr - ro) + zi * zi) < r2)
     bool c2 = ((zr * zr + (zi + ro) * (zi + ro)) < r2)
     bool c3 = (((zr + ro) * (zr + ro) + zi * zi) < r2)
     bool c4 = ((zr * zr + (zi - ro) * (zi - ro)) < r2)
     if( c1 && c4 )
       trapped = true
       d = (zr - k) * (zr - k) + (zi - k) * (zi - k)
     elseif( c1 && c2 )
       trapped = true
       d = (zr - k) * (zr - k) + (zi + k) * (zi + k)
     elseif( c2 && c3 )
       trapped = true
       d = (zr + k) * (zr + k) + (zi + k) * (zi + k)
     elseif( c3 && c4 )
       trapped = true
       d = (zr + k) * (zr + k) + (zi - k) * (zi - k)
     endif
     
     if( trapped )
       m_LastChannel = m_Iterations
       if( @petalColoring == "3D" )
         float colorPos = d / plsqd
         if( colorPos > 0.5 )
           m_Texture = (d / plsqd - 0.5) / 0.5
         else
           m_Texture = 1.0 - (d / plsqd / 0.5)
         endif
       else
         m_Texture = d / plsqd
       endif
       
       return d
     endif
 
     return 1e20
   endfunc
 
   float func GetTextureValue()
     return m_Texture
   endfunc
 
 protected:
   bool trapped
   float r
   float ro
   float r2
   float f
   float k
   float plsqd
   float m_Texture
 
 default:
   title = "Petals Trap"
 
   int param v_KCC_PetalsTrap
     caption = "Version (KCC_PetalsTrap)"
     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_KCC_PetalsTrap < 100
   endparam
 
   heading
     caption = "Information"
     text = "When this trap is used with the Orbit Traps Direct (UF5) \
             coloring in dmj5.ucl, the Trap Threshold value needs to be \
             greater than or equal to the Petal Size parameter to produce \
             a result similar to the Petals mode in Carlson Orbit Traps \
             in kcc3.ucl."
   endheading
 
   float param petalSize
     caption = "Petal Size"
     default = 0.1
     hint = "The size of the petals.  Suggested range (0.01 to 2.0)."
   endparam
 
   float param petalOffset
     caption = "Petal Offset"
     default = 0.1
     hint = "The offset of the petals.  Suggested range (0.0 to 0.2)."
   endparam
 
   param petalColoring
     caption = "Petal Coloring"
     default = 0
     enum = "3D" "Flat"
   endparam
 }
 


Constructor Summary
KCC_PetalsTrap()
           
KCC_PetalsTrap(Generic pparent)
          constructor
 
Method Summary
 float GetTextureValue()
          Get texture value.
 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, GetTransformedPoint, IterateSilent, SetThreshold
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

KCC_PetalsTrap

public KCC_PetalsTrap(Generic pparent)
constructor


KCC_PetalsTrap

public KCC_PetalsTrap()
Method Detail

Init

public void Init(complex pz)
call this before each sequence of values to be trapped

Overrides:
Init in class TrapShape

Iterate

public float Iterate(complex pz)
call this for each iteration being trapped

Overrides:
Iterate in class TrapShape

GetTextureValue

public float GetTextureValue()
Description copied from class: TrapShape
Get texture value.

Ordinarily, a trap shape does not have a native texture (it is flat). Some formulas may pair trap shapes with trap textures, and may need more information about trap textures when trap shapes are nested via TrapShapeMerge. This function provides support for accessing texture information.

Overrides:
GetTextureValue in class TrapShape
Returns:
the texture value for the last point used (i.e. call GetTextureValue() after calling Iterate(), not before)