mmf
Class MMF_TrapColoring

Object
  extended by common:Generic
      extended by common:TrapColoring
          extended by mmf:MMF_TrapColoring

class 
TrapColoring:MMF_TrapColoring

Some extensions to the standard trap colouring.


Ultra Fractal Source

Toggle UF Source Code Display

 class MMF_TrapColoring(common.ulb:TrapColoring) {
 ; Some extensions to the standard trap colouring.<br>
 public:
   import "common.ulb"
 
   ; <p>
   ; @param pparent the parent, generally "this" for the parent, or zero<br>
   func MMF_TrapColoring(Generic pparent)
     TrapColoring.TrapColoring(pparent)
     m_ColorTransfer = new @f_colortransfer(this)
     m_TextureTransfer = new @f_texturetransfer(this)
     m_ColorTransfer.Init(0)
     m_TextureTransfer.Init(0)
     m_TextureFlag = true
     if @colourby>7
       m_Image = new @f_image(this)
     endif
     if @colourby=="Image All"
       m_Merge = new @f_merge(this)
       if @adjustlayer
         m_Adjust = new @f_adjust(this)
       endif
     endif
   endfunc
 
   ; <p>
   ; @return the colouring value for the trap<br>
   float func Result(TrapMode ptrapmode)
     complex v = (0,0)
     float f = 0.0
     if @colourby=="Distance"
       f = ptrapmode.GetDistance(0)
     elseif @colourby=="Iteration"
       f = 0.05*ptrapmode.GetIteration(0)
     else
       if @usetrap=="Original Z value"
         v = ptrapmode.GetUntransformedPoint(0)
       elseif @usetrap=="Trapped Z value"
         v = ptrapmode.GetTransformedPoint(0)
       endif
       if @colourby=="Angle" || @colourby=="Sine"
         if (f = atan2(v))<0.0
           f = 2.0*#pi + f
         endif
         if @colourby=="Angle"
           f = f/(2.0*#pi)
         else
           f = abs(1.0 + sin(f))
         endif
       elseif @colourby=="Magnitude"
         f = cabs(v)
       elseif @colourby=="Real"
         f = real(v)
       elseif @colourby=="Imaginary"
         f = imag(v)
       elseif @colourby!="Texture Only"
         color clr = m_Image.GetColor(v)
         if @colourby=="Image All"
           f = 0.299*red(clr) + 0.587*green(clr) + 0.114*blue(clr)
         elseif @colourby=="Image Red"
           f = red(clr)
         elseif @colourby=="Image Green"
           f = green(clr)
         elseif @colourby=="Image Blue"
           f = blue(clr)
         elseif @colourby=="Image Alpha"
           f = alpha(clr)
         elseif @colourby=="Image Hue"
           f = hue(clr)/6.0
         elseif @colourby=="Image Saturation"
           f = sat(clr)
         elseif @colourby=="Image Luminance"
           f = lum(clr)
         endif
       endif
     endif
     if @colourby!="Texture Only" && m_TextureFlag
       return m_ColorTransfer.Iterate(f) \
              + m_TextureTransfer.Iterate(ptrapmode.GetTexture(0))
     elseif m_TextureFlag
       return m_TextureTransfer.Iterate(ptrapmode.GetTexture(0))
     else
       return m_ColorTransfer.Iterate(f)
     endif
   endfunc
 
   ; <p>
   ; @return flag for using "image all"<br>
   bool func UseColor()
     if @colourby=="Image All"
       return true
     endif
     return false
   endfunc
 
   ; <p>
   ; @param ptrapmode the trapmode<br>
   ; @return texture value<br>
   float func ResultTexture(TrapMode ptrapmode)
     return m_TextureTransfer.Iterate(ptrapmode.GetTexture(0))
   endfunc
 
   ; <p>
   ; @param ptrapmode the trapmode<br>
   ; @return the colour<br>
   color func ResultColor(TrapMode ptrapmode)
     complex v
     if @usetrap=="Original Z value"
       v = ptrapmode.GetUntransformedPoint(0)
     else;if @usetrap=="Trapped Z value"
       v = ptrapmode.GetTransformedPoint(0)
     endif
     return m_Image.GetColor(v)
   endfunc
 
   ; <p>
   ; @param clr image colour<br>
   ; @param tex texture index<br>
   ; @return merged colour<br>
   color func MergeResult(color clr, float tex)
     if @adjustlayer
       if m_TextureFlag
         clr = m_Merge.GradientMerge(clr, tex)
       endif
       color c = @f_adjustcolour
       if @adjusttype==0
          c = RGB(@adjred, @adjgreen, @adjblue)
       endif
       c = compose(clr, m_Adjust.Merge(clr, c), @f_opacity)
       return RGBA(red(c), green(c), blue(c), alpha(clr))
     endif
     if m_TextureFlag
       return m_Merge.GradientMerge(clr, tex)
     endif
     return clr
   endfunc
 
   ; @param flag indicates whether texturing is used or not<br>
   func SetTextureFlag(bool flag)
     m_TextureFlag = flag
   endfunc
   
 protected:
   Transfer m_ColorTransfer
   Transfer m_TextureTransfer
   ImageWrapper m_Image
   GradientLayer m_Merge
   ColorMerge m_Adjust
   BOOL m_TextureFlag
 
 default:
   title = "MMF Colour Selector"
   int param v_mmf_trapcoloring
     caption = "Version (MMF_TrapColoring)"
     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_mmf_trapcoloring < 100
   endparam
   int param colourby
    caption = "Colour By"
    enum = "Distance" "Iteration" "Angle" "Magnitude" "Real" "Imaginary" \
           "Sine" "Texture Only" "Image All""Image Red" "Image Green" \
           "Image Blue" "Image Alpha" "Image Hue" "Image Saturation" \
           "Image Luminance"
    default = 0
    hint = "Note that 'Texture Only' will only produce colouring if \
            you're using a texture other than dmj5->Flat Texture. \
            'Image All' maps the image brightness (Yiq) to UF's gradient \
            if the colouring is being used as a gradient colouring or uses \
            the image colours if the colouring is being used as a direct \
            colouring. 'Image Red' maps the image red to a gradient, \
            'Image Green' the green, 'Image Blue' the blue, 'Image Hue' \
            the hue, 'Image Saturation' the saturation and 'Image Luminance' \
            the luminance."
   endparam
   ImageWrapper param f_image
     caption = "Image Object"
     default = MMF_ImageImport
     hint = "This is the image object to use for your trap colouring."
     visible = @colourby>7
   endparam
   int param usetrap
     caption = "Z value"
     enum = "Original Z value" "Trapped Z value"
     default = 0
     hint = "When using 'Angle' as the value to colour by 'Original \
             Z value' gives 'Angle' or 'Angle of Z' and 'Trapped \
             Z value' gives 'Angle to Trap'."
     visible = @colourby>1
   endparam
   Transfer param f_colortransfer
     caption = "Colour Transfer"
     default = NullTransfer
     hint = "Allows you to manipulate the colour value from the trap \
             before combining with any texture. Does not apply to 'Image All' \
             if the main colouring is in direct mode."
     visible = @colourby!=7
   endparam
   Transfer param f_texturetransfer
     caption = "Texture Transfer"
     default = NullTransfer
     hint = "Allows you to manipulate any texture value before \
             combining with the colour value from the trap."
   endparam
   GradientLayer param f_merge
     caption = "Texture/Iteration Merge"
     default = MMF_GradientLayer
     hint = "Only used if the main colouring is being used in direct colouring \
             mode and texturing and/or adding the smooth iteration count \
             is/are in use. Use to merge the texture/iteration value with the \
             image. Note that the gradient you choose controls the colour of \
             the texture/iteration layer which is normally treated as the top \
             layer."
     visible = @colourby=="Image All"
     expanded = false
   endparam
   bool param adjustlayer
     caption = "Add Adjust layer"
     default = false
     hint = "Allows you to add an adjustment layer in a given colour to merge \
             on top of the image/texture. Only active if the main colouring \
             is in direct mode."
     visible = @colourby=="Image All"
   endparam
   int param adjusttype
     caption = "Colour or RGB"
     enum = "RGB values" "Colour Parameter"
     default = 1
     hint = "This option is specifically added so that if you choose \
             'RGB values' you can 'explore' them and see changes to the image \
             as you change the RGB. The option may become redundant in a \
             future version of UF."
     visible = @colourby=="Image All" && @adjustlayer
   endparam
   float param adjred
     caption = "Red Value"
     default = 1.0
     hint = "The red part of the adjust colour (0 to 1)."
     visible = @colourby=="Image All" && @adjustlayer && @adjusttype==0
   endparam
   float param adjgreen
     caption = "Green Value"
     default = 1.0
     hint = "The green part of the adjust colour (0 to 1)."
     visible = @colourby=="Image All" && @adjustlayer && @adjusttype==0
   endparam
   float param adjblue
     caption = "Blue Value"
     default = 1.0
     hint = "The blue part of the adjust colour (0 to 1)."
     visible = @colourby=="Image All" && @adjustlayer && @adjusttype==0
   endparam
   color param f_adjustcolour
     caption = "Adjust Layer Colour"
     default = RGB(1,1,1)
     hint = "Allows you to apply overall adjustments to your colouring."
     visible = @colourby=="Image All" && @adjustlayer && @adjusttype==1
   endparam
   ColorMerge param f_adjust
     caption = "Adjustment Layer Merge"
     default = MMF_ExtendedColorMerge
     visible = @colourby=="Image All" && @adjustlayer
   endparam
   float param f_opacity
     caption = "Adjustment Opacity"
     default = 1.0
     hint = "Use to modify the adjustment opacity, the normal range is from \
             0 to 1."
     visible = @colourby=="Image All" && @adjustlayer
   endparam
 }
 


Constructor Summary
MMF_TrapColoring()
           
MMF_TrapColoring(Generic pparent)
          
 
Method Summary
 color MergeResult(color clr, float tex)
          
 float Result(TrapMode ptrapmode)
          
 color ResultColor(TrapMode ptrapmode)
          
 float ResultTexture(TrapMode ptrapmode)
          
 void SetTextureFlag(boolean flag)
           
 boolean UseColor()
          
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

MMF_TrapColoring

public MMF_TrapColoring(Generic pparent)

Parameters:
pparent - the parent, generally "this" for the parent, or zero

MMF_TrapColoring

public MMF_TrapColoring()
Method Detail

Result

public float Result(TrapMode ptrapmode)

Overrides:
Result in class TrapColoring
Returns:
the colouring value for the trap

UseColor

public boolean UseColor()

Returns:
flag for using "image all"

ResultTexture

public float ResultTexture(TrapMode ptrapmode)

Parameters:
ptrapmode - the trapmode
Returns:
texture value

ResultColor

public color ResultColor(TrapMode ptrapmode)

Parameters:
ptrapmode - the trapmode
Returns:
the colour

MergeResult

public color MergeResult(color clr,
                         float tex)

Parameters:
clr - image colour
tex - texture index
Returns:
merged colour

SetTextureFlag

public void SetTextureFlag(boolean flag)
Parameters:
flag - indicates whether texturing is used or not