common
Class TrapShapeMerge

Object
  extended by common:Generic
      extended by common:TrapShape
          extended by common:TrapShapeMerge

class 
TrapShape:TrapShapeMerge

This is a wrappoer transform which allows you to use multiple trap shapes (up to 10) wherever a single trap shape is allowed. If you need more than ten trap shapes, put a TrapShapeMerge object in one or more of the slots.


Ultra Fractal Source

Toggle UF Source Code Display

 class TrapShapeMerge(TrapShape) {
   ; This is a wrappoer transform which allows you to use multiple
   ; trap shapes (up to 10) wherever a single trap shape is allowed.
   ; If you need more than ten trap shapes, put a TrapShapeMerge
   ; object in one or more of the slots.
   
 public:
   func TrapShapeMerge(Generic pparent)
     TrapShape.TrapShape(pparent)
 
     m_Enables[0] = @p_trapshape1enable    
     m_Enables[1] = @p_trapshape2enable    
     m_Enables[2] = @p_trapshape3enable    
     m_Enables[3] = @p_trapshape4enable    
     m_Enables[4] = @p_trapshape5enable    
     m_Enables[5] = @p_trapshape6enable    
     m_Enables[6] = @p_trapshape7enable    
     m_Enables[7] = @p_trapshape8enable    
     m_Enables[8] = @p_trapshape9enable    
     m_Enables[9] = @p_trapshape10enable    
     m_Elements[0] = new @f_trapshape1(this)
     m_Elements[1] = new @f_trapshape2(this)
     m_Elements[2] = new @f_trapshape3(this)
     m_Elements[3] = new @f_trapshape4(this)
     m_Elements[4] = new @f_trapshape5(this)
     m_Elements[5] = new @f_trapshape6(this)
     m_Elements[6] = new @f_trapshape7(this)
     m_Elements[7] = new @f_trapshape8(this)
     m_Elements[8] = new @f_trapshape9(this)
     m_Elements[9] = new @f_trapshape10(this)
   endfunc
   
   func Init(complex pz)
     TrapShape.Init(pz)
 
     m_TextureValue = 0
     
     int j = 0
     while (j < 10)
       if (m_Enables[j])
         m_Elements[j].Init(pz)
       endif
       j = j + 1
     endwhile
   endfunc
   
   float func Iterate(complex pz)
     TrapShape.Iterate(pz)
 
     if (@p_mergemode == 0)    ; minimum
       float dmin = 1e50
       float distance = 0
       int j = 0
       while (j < 10)
         if (m_Enables[j])
           distance = m_Elements[j].Iterate(pz)
           if (distance < dmin)
             dmin = distance
             if (@p_mergesource == 0)
               m_LastZ = m_Elements[j].GetTransformedPoint()
               m_LastChannel = m_Elements[j].GetColorChannel()
             endif
             if (@p_texturesource == 0)
               m_TextureValue = m_Elements[j].GetTextureValue()
             endif
           endif
         endif
         j = j + 1
       endwhile
       return dmin
       
     elseif (@p_mergemode == 1)  ; maximum
       float dmax = -1e50
       float distance = 0
       int j = 0
       while (j < 10)
         if (m_Enables[j])
           distance = m_Elements[j].Iterate(pz)
           if (distance > dmax)
             dmax = distance
             if (@p_mergesource == 0)
               m_LastZ = m_Elements[j].GetTransformedPoint()
               m_LastChannel = m_Elements[j].GetColorChannel()
             endif
             if (@p_texturesource == 0)
               m_TextureValue = m_Elements[j].GetTextureValue()
             endif
           endif
         endif
         j = j + 1
       endwhile
       return dmax
       
     elseif (@p_mergemode == 2)  ; add
       m_LastZ = (0,0)
       m_TextureValue = 0
       int count = 0
       float dtotal = 0
       float distance = 0
       int j = 0
       while (j < 10)
         if (m_Enables[j])
           distance = m_Elements[j].Iterate(pz)
           dtotal = dtotal + distance
           count = count + 1
           if (@p_mergesource == 0)
             m_LastZ = m_LastZ + m_Elements[j].GetTransformedPoint()
             m_LastChannel = m_Elements[j].GetColorChannel()
           endif
           if (@p_texturesource == 0)
             m_TextureValue = m_TextureValue + m_Elements[j].GetTextureValue()
           endif
         endif
         j = j + 1
       endwhile
       if (@p_mergesource == 0)
         m_LastZ = m_LastZ / count
       endif
       if (@p_texturesource == 0)
         m_TextureValue = m_TextureValue / count
       endif
       return dtotal
       
     elseif (@p_mergemode == 3)  ; multiply
       m_LastZ = (1,0)
       m_TextureValue = 1
       float dtotal = 1
       float distance = 0
       int j = 0
       while (j < 10)
         if (m_Enables[j])
           distance = m_Elements[j].Iterate(pz)
           dtotal = dtotal * distance
           if (@p_mergesource == 0)
             m_LastZ = m_LastZ * m_Elements[j].GetTransformedPoint()
             m_LastChannel = m_Elements[j].GetColorChannel()
           endif
           if (@p_texturesource == 0)
             m_TextureValue = m_TextureValue * m_Elements[j].GetTextureValue()
           endif
         endif
         j = j + 1
       endwhile
       return dtotal
       
     elseif (@p_mergemode == 4)  ; exponentiate
       int count = 0
       float dtotal = 1
       float distance = 0
       int j = 0
       while (j < 10)
         if (m_Enables[j])
           distance = m_Elements[j].Iterate(pz)
           count = count + 1
           if (count == 1)
             dtotal = distance
           else
             dtotal = dtotal ^ distance
           endif
           if (@p_mergesource == 0)
             m_LastZ = m_LastZ ^ m_Elements[j].GetTransformedPoint()
             m_LastChannel = m_Elements[j].GetColorChannel()
           endif
           if (@p_texturesource == 0)
             if (count == 1)
               m_TextureValue = m_Elements[j].GetTextureValue()
             else
               m_TextureValue = m_TextureValue * m_Elements[j].GetTextureValue()
             endif
           endif
         endif
         j = j + 1
       endwhile
       return dtotal
 
     ; 5: AND
     ; 6: OR
     ; 7: XOR
 
     endif
     return 0
     
   endfunc
   
   func SetThreshold(float pthreshold)
     int j = 0
     while (j < 10)
       if (m_Enables[j])
         m_Elements[j].SetThreshold(pthreshold)
       endif
       j = j + 1
     endwhile
   endfunc
 
   complex func GetTransformedPoint()
     if (@p_mergesource == 0)
       return m_LastZ
     else
       return m_Elements[@p_mergesource-1].GetTransformedPoint()
     endif
   endfunc
 
   float func GetTextureValue()
     if (@p_texturesource == 0)
       return m_TextureValue
     else
       return m_Elements[@p_texturesource-1].GetTextureValue()
     endif
   endfunc
   
   int func GetColorChannel()
     if (@p_mergesource == 0)
       return m_LastChannel
     else
       return m_Elements[@p_mergesource-1].GetColorChannel()
     endif
   endfunc
   
 protected:
   bool m_Enables[10]
   TrapShape m_Elements[10]
   float m_TextureValue
   
 default:
   title = "TrapShape Merge"
   
   int param v_trapshapemerge
     caption = "Version (TrapShapeMerge)"
     default = 101
     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_trapshapemerge < 100
   endparam
 
   int param p_mergemode
     caption = "Merge Mode"
     enum = "minimum" "maximum" "add" "multiply" "exponentiate" "intersection (AND)" "union (OR)" "exclusion (XOR)"
     default = 0
     hint = "Sets the way the trap shapes will be merged together."
   endparam
   int param p_mergesource
     caption = "Coloring Source"
     enum = "computed" "trap 1" "trap 2" "trap 3" "trap 4" "trap 5" "trap 6" "trap 7" "trap 8" "trap 9" "trap 10"
     default = 0
     hint = "Some textures or colorings depend on a transformed coordinate. This option allows you to specify whether a computed value (derived from your trap merge mode) or a specific trap shape's value should be used."
   endparam
   int param p_texturesource
     caption = "Texture Source"
     enum = "computed" "trap 1" "trap 2" "trap 3" "trap 4" "trap 5" "trap 6" "trap 7" "trap 8" "trap 9" "trap 10"
     default = 0
     hint = "Some formulas that use trap shapes allow texturing. If you have selected texture options with your trap shapes, you may choose from which object to extract texture values."
   endparam
   bool param p_showempty
     caption = "Show all slots"
     default = false
     hint = "Sets whether all slots should be shown, even if they are empty or disabled. Normally, most unused slots will be hidden from you to avoid clutter. By checking this box you can reveal all the slots again, even if they're disabled or not in use."
   endparam
   
   bool param p_trapshape1enable
     caption = "Enable Trap Shape 1"
     default = true
     hint = "Enables this trap shape. You can use this to temporarily disable a trap shape without unloading its parameters."
     visible = (@p_trapshape1enable || @p_showempty)
   endparam
   TrapShape param f_trapshape1
     caption = "Trap Shape"
     default = TrapShapeBlock
     hint = "Sets the trap shape for this slot. Using a TrapShapeBlock in this slot is recommended so that each trap shape can have its own position and transfer settings. If you do not need these, you may load a TrapShape directly into this slot to reduce clutter."
     visible = (@p_trapshape1enable || @p_showempty)
   endparam
   bool param p_trapshape2enable
     caption = "Enable Trap Shape 2"
     default = true
     hint = "Enables this trap shape. You can use this to temporarily disable a trap shape without unloading its parameters."
     visible = (@p_trapshape2enable || @p_showempty || @p_trapshape1enable)
   endparam
   TrapShape param f_trapshape2
     caption = "Trap Shape"
     default = TrapShapeBlock
     hint = "Sets the trap shape for this slot. Using a TrapShapeBlock in this slot is recommended so that each trap shape can have its own position and transfer settings. If you do not need these, you may load a TrapShape directly into this slot to reduce clutter."
     visible = (@p_trapshape2enable || @p_showempty)
   endparam
   bool param p_trapshape3enable
     caption = "Enable Trap Shape 3"
     default = false
     hint = "Enables this trap shape. You can use this to temporarily disable a trap shape without unloading its parameters."
     visible = (@p_trapshape3enable || @p_showempty || @p_trapshape2enable)
   endparam
   TrapShape param f_trapshape3
     caption = "Trap Shape"
     default = TrapShapeBlock
     hint = "Sets the trap shape for this slot. Using a TrapShapeBlock in this slot is recommended so that each trap shape can have its own position and transfer settings. If you do not need these, you may load a TrapShape directly into this slot to reduce clutter."
     visible = (@p_trapshape3enable || @p_showempty)
   endparam
   bool param p_trapshape4enable
     caption = "Enable Trap Shape 4"
     default = false
     hint = "Enables this trap shape. You can use this to temporarily disable a trap shape without unloading its parameters."
     visible = (@p_trapshape4enable || @p_showempty || @p_trapshape3enable)
   endparam
   TrapShape param f_trapshape4
     caption = "Trap Shape"
     default = TrapShapeBlock
     hint = "Sets the trap shape for this slot. Using a TrapShapeBlock in this slot is recommended so that each trap shape can have its own position and transfer settings. If you do not need these, you may load a TrapShape directly into this slot to reduce clutter."
     visible = (@p_trapshape4enable || @p_showempty)
   endparam
   bool param p_trapshape5enable
     caption = "Enable Trap Shape 5"
     default = false
     hint = "Enables this trap shape. You can use this to temporarily disable a trap shape without unloading its parameters."
     visible = (@p_trapshape5enable || @p_showempty || @p_trapshape4enable)
   endparam
   TrapShape param f_trapshape5
     caption = "Trap Shape"
     default = TrapShapeBlock
     hint = "Sets the trap shape for this slot. Using a TrapShapeBlock in this slot is recommended so that each trap shape can have its own position and transfer settings. If you do not need these, you may load a TrapShape directly into this slot to reduce clutter."
     visible = (@p_trapshape5enable || @p_showempty)
   endparam
   bool param p_trapshape6enable
     caption = "Enable Trap Shape 6"
     default = false
     hint = "Enables this trap shape. You can use this to temporarily disable a trap shape without unloading its parameters."
     visible = (@p_trapshape6enable || @p_showempty || @p_trapshape5enable)
   endparam
   TrapShape param f_trapshape6
     caption = "Trap Shape"
     default = TrapShapeBlock
     hint = "Sets the trap shape for this slot. Using a TrapShapeBlock in this slot is recommended so that each trap shape can have its own position and transfer settings. If you do not need these, you may load a TrapShape directly into this slot to reduce clutter."
     visible = (@p_trapshape6enable || @p_showempty)
   endparam
   bool param p_trapshape7enable
     caption = "Enable Trap Shape 7"
     default = false
     hint = "Enables this trap shape. You can use this to temporarily disable a trap shape without unloading its parameters."
     visible = (@p_trapshape7enable || @p_showempty || @p_trapshape6enable)
   endparam
   TrapShape param f_trapshape7
     caption = "Trap Shape"
     default = TrapShapeBlock
     hint = "Sets the trap shape for this slot. Using a TrapShapeBlock in this slot is recommended so that each trap shape can have its own position and transfer settings. If you do not need these, you may load a TrapShape directly into this slot to reduce clutter."
     visible = (@p_trapshape7enable || @p_showempty)
   endparam
   bool param p_trapshape8enable
     caption = "Enable Trap Shape 8"
     default = false
     hint = "Enables this trap shape. You can use this to temporarily disable a trap shape without unloading its parameters."
     visible = (@p_trapshape8enable || @p_showempty || @p_trapshape7enable)
   endparam
   TrapShape param f_trapshape8
     caption = "Trap Shape"
     default = TrapShapeBlock
     hint = "Sets the trap shape for this slot. Using a TrapShapeBlock in this slot is recommended so that each trap shape can have its own position and transfer settings. If you do not need these, you may load a TrapShape directly into this slot to reduce clutter."
     visible = (@p_trapshape8enable || @p_showempty)
   endparam
   bool param p_trapshape9enable
     caption = "Enable Trap Shape 9"
     default = false
     hint = "Enables this trap shape. You can use this to temporarily disable a trap shape without unloading its parameters."
     visible = (@p_trapshape9enable || @p_showempty || @p_trapshape8enable)
   endparam
   TrapShape param f_trapshape9
     caption = "Trap Shape"
     default = TrapShapeBlock
     hint = "Sets the trap shape for this slot. Using a TrapShapeBlock in this slot is recommended so that each trap shape can have its own position and transfer settings. If you do not need these, you may load a TrapShape directly into this slot to reduce clutter."
     visible = (@p_trapshape9enable || @p_showempty)
   endparam
   bool param p_trapshape10enable
     caption = "Enable Trap Shape 10"
     default = false
     hint = "Enables this trap shape. You can use this to temporarily disable a trap shape without unloading its parameters."
     visible = (@p_trapshape10enable || @p_showempty || @p_trapshape9enable)
   endparam
   TrapShape param f_trapshape10
     caption = "Trap Shape"
     default = TrapShapeBlock
     hint = "Sets the trap shape for this slot. Using a TrapShapeBlock in this slot is recommended so that each trap shape can have its own position and transfer settings. If you do not need these, you may load a TrapShape directly into this slot to reduce clutter."
     visible = (@p_trapshape10enable || @p_showempty)
   endparam
 }
 


Constructor Summary
TrapShapeMerge()
           
TrapShapeMerge(Generic pparent)
           
 
Method Summary
 int GetColorChannel()
          Get color channel.
 float GetTextureValue()
          Get texture value.
 complex GetTransformedPoint()
          Get transformed point.
 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
 void SetThreshold(float pthreshold)
          call this to set the threshold selected by the user it's up to the calling code to apply the threshold, but some trap shapes or merges need to know the threshold to work properly
 
Methods inherited from class common:TrapShape
IterateSilent
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

TrapShapeMerge

public TrapShapeMerge(Generic pparent)

TrapShapeMerge

public TrapShapeMerge()
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

SetThreshold

public void SetThreshold(float pthreshold)
Description copied from class: TrapShape
call this to set the threshold selected by the user it's up to the calling code to apply the threshold, but some trap shapes or merges need to know the threshold to work properly

Overrides:
SetThreshold in class TrapShape

GetTransformedPoint

public complex GetTransformedPoint()
Description copied from class: TrapShape
Get transformed point.

Some trap modes and trap coloring modes require access to the "transformed" point. This is the final point that is actually used by the trap shape class to test against the trap. For most trap shape classes this will be exactly the same as the pz passed into Iterate(), and those classes can use this base class functionality. However, some trap shape classes (e.g. TrapShapeMerge, TrapShapeBlock) perform some internal transformations on pz before passing it to the trap shape; this gives them the opportunity to call their trap shape's function to get the final transformed point.

Overrides:
GetTransformedPoint in class TrapShape
Returns:
the last transformed point used (i.e. call GetTransformedPoint() after calling Iterate(), not before)

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)

GetColorChannel

public int GetColorChannel()
Description copied from class: TrapShape
Get color channel.

Some trap shapes may be inherently multi-colored. Such trap shapes may either override this function to return a different color index, or may simply store the index in m_LastChannel and this function will return it. The color index is just an indication of which color channel (in a GradientWrapper object) should be used.

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