reb
Class ColorTrapShapeBlock

Object
  extended by common:Generic
      extended by common:ColorTrap
          extended by reb:ColorTrapShapeBlock

class 
ColorTrap:ColorTrapShapeBlock

This is essentially a wrapper around a transformation, a trap shape, and a transfer function. It returns a color, either from the gradient, or from an internal color array.


Ultra Fractal Source

Toggle UF Source Code Display

 class ColorTrapShapeBlock(common.ulb:ColorTrap) {
   ; This is essentially a wrapper around a transformation, a trap shape,
   ; and a transfer function. It returns a color, either from the gradient,
   ; or from an internal color array.
   
 public:
   func ColorTrapShapeBlock(Generic pparent)
     ColorTrap.ColorTrap(pparent)
 
     m_TrapTransform = new @f_traptransform(this)
     m_TrapShape = new @f_trapshape(this)
     m_TrapTransfer = new @f_traptransfer(this)
     m_DirColor = new @f_dircolor(this)
   endfunc
 
   func Init(complex pz)
     ColorTrap.Init(pz)
     
     m_TrapTransform.Init(pz)
     m_TrapShape.Init(pz)
     m_TrapTransfer.Init(pz)
     m_dircolor.Init()
   endfunc
 
   color func Iterate(complex pz)
     complex zt = m_TrapTransform.Iterate(pz)
     float distance = m_TrapShape.Iterate(zt)
     distance = m_TrapTransfer.Iterate(distance)
     color pat = rgba(0,0,0,0)
     pz = exp(flip(2 * #pi * sqrt(2) * distance))
     float cindex = 0
     if @flavorp == 0
       if @cfun == "Linear"
         cindex =  (@cscale*(cabs((real(pz)/cabs(pz))))+ @rot) % 1
       elseif @cfun == "Sqr"
         cindex =  (@cscale*(cabs(sqr(real(pz)/cabs(pz))))+ @rot) % 1
       elseif @cfun == "Sqrt"
         cindex =  (@cscale*(cabs(sqrt(real(pz)/cabs(pz))))+ @rot) % 1
       elseif @cfun == "Cube"
         cindex =  (@cscale*(cabs((real(pz)/cabs(pz))^3))+ @rot) % 1
       elseif @cfun == "Cuberoot"
         cindex =  (@cscale*(cabs((real(pz)/cabs(pz))^(1/3)))+ @rot) % 1
       elseif @cfun == "Log"
         cindex =  (@cscale*(cabs(log(real(pz)/cabs(pz))))+ @rot) % 1
       elseif @cfun == "Exp"
         cindex =  (@cscale*(cabs(exp(real(pz)/cabs(pz))))+ @rot) % 1
       elseif @cfun == "Sin"
         cindex =  (@cscale*(cabs(sin(real(pz)/cabs(pz))))+ @rot) % 1
       elseif @cfun == "ArcTan"
         cindex =  (@cscale*(cabs(atan(real(pz)/cabs(pz))))+ @rot) % 1
       endif
       if cindex >= 0 && cindex < 0.125
         pat = blend(m_dircolor.direct[0],m_dircolor.direct[1],cindex/0.125)
       elseif cindex >= 0.125 &&  cindex < 0.25
         pat = blend(m_dircolor.direct[1],m_dircolor.direct[2],(cindex-0.125)/0.125)
       elseif cindex >= 0.25 &&  cindex < 0.375
         pat = blend(m_dircolor.direct[2],m_dircolor.direct[3],(cindex-0.25)/0.125)
       elseif cindex >= 0.375 &&  cindex < 0.5
         pat = blend(m_dircolor.direct[3],m_dircolor.direct[4],(cindex-0.375)/0.125)
       elseif cindex >= 0.5 &&  cindex < 0.625
         pat = blend(m_dircolor.direct[4],m_dircolor.direct[5],(cindex-0.5)/0.125)
       elseif cindex >= 0.625 &&  cindex < 0.75
         pat = blend(m_dircolor.direct[5],m_dircolor.direct[6],(cindex-0.625)/0.125)
       elseif cindex >= 0.75 &&  cindex < 0.875
         pat = blend(m_dircolor.direct[6],m_dircolor.direct[7],(cindex-0.75)/0.125)
       elseif cindex >= 0.875 && cindex < 1.0
         pat = blend(m_dircolor.direct[7],m_dircolor.direct[0],(cindex-0.875)/0.125)
       endif
     elseif @flavorp == 1
       if @cfun == "Linear"
         cindex =  (@cscale*(cabs((distance))) + @rot)%1
       elseif @cfun == "Sqr"
         cindex =  (@cscale*(cabs(sqr(distance))) + @rot)%1
       elseif @cfun == "Sqrt"
         cindex =  (@cscale*(cabs(sqrt(distance))) + @rot)%1
       elseif @cfun == "Cube"
         cindex =  (@cscale*(cabs((distance)^3)) + @rot)%1
       elseif @cfun == "Cuberoot"
         cindex =  (@cscale*(cabs((distance)^(1/3))) + @rot)%1
       elseif @cfun == "Log"
         cindex =  (@cscale*(cabs(log(distance))) + @rot)%1
       elseif @cfun == "Exp"
         cindex =  (@cscale*(cabs(exp(distance))) + @rot)%1
       elseif @cfun == "Sin"
         cindex =  (@cscale*(cabs(sin(distance))) + @rot)%1
       elseif @cfun == "ArcTan"
         cindex =  (@cscale*(cabs(atan(distance))) + @rot)%1
       endif
       if cindex >= 0 && cindex < 0.125
         pat = blend(m_dircolor.direct[0],m_dircolor.direct[1],cindex/0.125)
       elseif cindex >= 0.125 &&  cindex < 0.25
         pat = blend(m_dircolor.direct[1],m_dircolor.direct[2],(cindex-0.125)/0.125)
       elseif cindex >= 0.25 &&  cindex < 0.375
         pat = blend(m_dircolor.direct[2],m_dircolor.direct[3],(cindex-0.25)/0.125)
       elseif cindex >= 0.375 &&  cindex < 0.5
         pat = blend(m_dircolor.direct[3],m_dircolor.direct[4],(cindex-0.375)/0.125)
       elseif cindex >= 0.5 &&  cindex < 0.625
         pat = blend(m_dircolor.direct[4],m_dircolor.direct[5],(cindex-0.5)/0.125)
       elseif cindex >= 0.625 &&  cindex < 0.75
         pat = blend(m_dircolor.direct[5],m_dircolor.direct[6],(cindex-0.625)/0.125)
       elseif cindex >= 0.75 &&  cindex < 0.875
         pat = blend(m_dircolor.direct[6],m_dircolor.direct[7],(cindex-0.75)/0.125)
       elseif cindex >= 0.875 && cindex < 1.0
         pat = blend(m_dircolor.direct[7],m_dircolor.direct[0],(cindex-0.875)/0.125)
       endif
     elseif @flavorp == 2
       if @cfun == "Linear"
         cindex =  (@cscale*(cabs((distance))) + @rot)%1
       elseif @cfun == "Sqr"
         cindex =  (@cscale*(cabs(sqr(distance))) + @rot)%1
       elseif @cfun == "Sqrt"
         cindex =  (@cscale*(cabs(sqrt(distance))) + @rot)%1
       elseif @cfun == "Cube"
         cindex =  (@cscale*(cabs((distance)^3)) + @rot)%1
       elseif @cfun == "Cuberoot"
         cindex =  (@cscale*(cabs((distance)^(1/3))) + @rot)%1
       elseif @cfun == "Log"
         cindex =  (@cscale*(cabs(log(distance))) + @rot)%1
       elseif @cfun == "Exp"
         cindex =  (@cscale*(cabs(exp(distance))) + @rot)%1
       elseif @cfun == "Sin"
         cindex =  (@cscale*(cabs(sin(distance))) + @rot)%1
       elseif @cfun == "ArcTan"
         cindex =  (@cscale*(cabs(atan(distance))) + @rot)%1
       endif
       pat = gradient(cindex)
     endif
     return pat
   endfunc
     
 protected:
   UserTransform m_TrapTransform
   TrapShape m_TrapShape
   Transfer m_TrapTransfer
   REB_DirectColorHelper m_dircolor
 
 default:
   title = "ColorTrapShape Block"
 
   int param v_colortrapshapeblock
     caption = "Version (ColorTrapShapeBlock)"
     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_colortrapshapeblock < 101
   endparam
 
   UserTransform param f_traptransform
     caption = "Trap Position"
     default = TrapTransform
     expanded = false
   endparam
   TrapShape param f_trapshape
     caption = "Trap Shape"
     default = TrapShapePoint
   endparam
   Transfer param f_traptransfer
     caption = "Trap Transfer"
     default = NullTransfer
   endparam
   heading
     caption = "Coloring parameters and Flavors"
   endheading
   REB_DirectColorHelper param f_dircolor
     caption = "Direct color array"
     default = REB_Default
     visible = @flavorp != "gradient"
   endparam
   param flavorp
     caption = "Coloring flavor"
     default = 0
     enum = "direct color1" "direct color2" "gradient"
   endparam
   float param cscale
     caption = "Color scale"
     default = 1.0
   endparam
   float param rot
     caption = "Color rotation"
     default = 0
     min = 0
     max = 1
   endparam
   param cfun
     caption = "Color Function"
     default = 0
     enum = "Linear" "Sqr" "Sqrt" "Cube" "Cuberoot" "Log" "Exp" "Sin" "ArcTan"
   endparam
 }
 


Constructor Summary
ColorTrapShapeBlock()
           
ColorTrapShapeBlock(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

ColorTrapShapeBlock

public ColorTrapShapeBlock(Generic pparent)

ColorTrapShapeBlock

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