|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Objectcommon:Generic
common:Coloring
common:GradientColoring
mmf:MMF_TwoColourings
class
class MMF_TwoColourings(common.ulb:GradientColoring) {
public:
import "Standard.ulb"
func MMF_TwoColourings(Generic pparent)
if @mode!=3
m_Colouring1 = new @f_colouring1(pparent)
if @f_transfer1!=NullTransfer
m_Transfer1 = new @f_transfer1(this)
endif
endif
if @mode!=2
m_Colouring2 = new @f_colouring2(pparent)
if @f_transfer2!=NullTransfer
m_Transfer2 = new @f_transfer2(this)
endif
endif
if @f_transform!=NullTransform && @mode<2
m_Transform = new @f_transform(this)
endif
if @mode=="Image Mapping"
m_Image = new @f_image(this)
if @adjustlayer
m_Adjust = new @f_adjust(this)
endif
endif
if @mode==4 || (@mode<2 && @usetexture)
if @f_transferx!=NullTransform
m_Transferx = new @f_transferx(this)
endif
if @f_transfery!=NullTransform
m_Transfery = new @f_transfery(this)
endif
if @f_textransform!=NullTransform
m_TexTransform = new @f_textransform(this)
endif
if @f_texturescale!=NullTransfer
m_TextureScale = new @f_texturescale(this)
endif
m_Texture = new @f_texture(this)
m_Merge = new @f_merge(this)
endif
endfunc
func Init(complex pz, complex ppixel)
if @mode!=3
m_Colouring1.Init(pz,ppixel)
if @f_transfer1!=NullTransfer
m_Transfer1.Init(0)
endif
endif
if @mode!=2
m_Colouring2.Init(pz,ppixel)
if @f_transfer2!=NullTransfer
m_Transfer2.Init(0)
endif
endif
if @f_transform!=NullTransform && @mode<2
m_Transform.Init(pz)
endif
if @mode==4 || (@mode<2 && @usetexture)
if @f_transferx!=NullTransform
m_Transferx.Init(0)
endif
if @f_transfery!=NullTransform
m_Transfery.Init(0)
endif
if @f_textransform!=NullTransform
m_TexTransform.Init(pz)
endif
if @f_texturescale!=NullTransfer
m_TextureScale.Init(0)
endif
m_Texture.Init(pz)
endif
endfunc
func Iterate(complex pz)
if @mode!=3
m_Colouring1.Iterate(pz)
endif
if @mode!=2
m_Colouring2.Iterate(pz)
endif
endfunc
float func ResultIndex(complex pz)
float s = 0.0
float t = 0.0
float r = 0.0
complex v = (0,0)
u = 0.0
if @mode!=3
r = s = m_Colouring1.ResultIndex(pz)
if (@mode==4 || (@mode<2 && @usetexture)) && @f_transferx!=NullTransfer
r = m_Transferx.Iterate(r)
endif
if @f_transfer1!=NullTransfer
s = m_Transfer1.Iterate(s)
endif
if @mode==2
return s
endif
endif
if @mode!=2
u = t = m_Colouring2.ResultIndex(pz)
if (@mode==4 || (@mode<2 && @usetexture)) && @f_transfery!=NullTransfer
u = m_Transfery.Iterate(u)
endif
if @f_transfer2!=NullTransfer
t = m_Transfer2.Iterate(t)
endif
if @mode==3
return t
endif
endif
if @f_transform!=NullTransform && @mode<4
v = m_Transform.Iterate(s + flip(t))
s = real(v)
t = imag(v)
endif
if (@mode==4 || (@mode<2 && @usetexture)) && @f_textransform!=NullTransform
v = m_TexTransform.Iterate(r + flip(u))
r = real(v)
u = imag(v)
endif
if @mode==4 || (@mode<2 && @usetexture)
if @polartex
r = r*2.0*#pi
if @mode>0
v = 0.5*u*(cos(r)+1.0 - flip(sin(r)-1.0))
else
v = u*(cos(r) - flip(sin(r)))
endif
r = real(v)
u = imag(v)
endif
u = m_Texture.Iterate(r+flip(u))
if @f_texturescale!=NullTransfer
u = m_TextureScale.Iterate(u)
endif
endif
if @polar
s = s*2.0*#pi
if @mode>0
v = 0.5*t*(cos(s)+1.0 - flip(sin(s)-1.0))
else
v = t*(cos(s) - flip(sin(s)))
endif
s = real(v)
t = imag(v)
endif
if @mode==4
return u
elseif @mode==1
if @usetexture
if @mix=="Sum"
return s + t + u
elseif @mix=="Product"
return s*t + u
elseif @mix=="Absolute Difference"
return abs(s - t) + u
elseif @mix=="Quotient 1"
return s/(t + 1) + u
else;if @mix=="Quotient 2"
return t/(s + 1) + u
endif
elseif @mix=="Sum"
return s + t
elseif @mix=="Product"
return s*t
elseif @mix=="Absolute Difference"
return abs(s - t)
elseif @mix=="Quotient 1"
return s/(t + 1)
else;if @mix=="Quotient 2"
return t/(s + 1)
endif
else
if !@polar
s = 2*s - 1.0
t = 2*t - 1.0
endif
clr = m_Image.GetColor(s+flip(t))
if @usetexture
if @mapmethod=="Image All"
return 0.299*red(clr) + 0.587*green(clr) + 0.114*blue(clr) + u
elseif @mapmethod=="Image Red"
return red(clr) + u
elseif @mapmethod=="Image Green"
return green(clr) + u
elseif @mapmethod=="Image Blue"
return blue(clr) + u
elseif @mapmethod=="Image Alpha"
return alpha(clr) + u
elseif @mapmethod=="Image Hue"
return hue(clr)/6.0 + u
elseif @mapmethod=="Image Saturation"
return sat(clr) + u
else;if @mapmethod=="Image Luminance"
return lum(clr) + u
endif
elseif @mapmethod=="Image All"
return 0.299*red(clr) + 0.587*green(clr) + 0.114*blue(clr)
elseif @mapmethod=="Image Red"
return red(clr)
elseif @mapmethod=="Image Green"
return green(clr)
elseif @mapmethod=="Image Blue"
return blue(clr)
elseif @mapmethod=="Image Alpha"
return alpha(clr)
elseif @mapmethod=="Image Hue"
return hue(clr)/6.0
elseif @mapmethod=="Image Saturation"
return sat(clr)
else;if @mapmethod=="Image Luminance"
return lum(clr)
endif
endif
endfunc
color func Result(complex pz)
float v = ResultIndex(pz)
if @mode==0 && @mapmethod=="Image All"
if @usetexture
clr = m_Merge.GradientMerge(clr, u)
endif
if @adjustlayer
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
return clr
endif
return gradient(v)
endfunc
private:
GradientColoring m_Colouring1
GradientColoring m_Colouring2
Transfer m_Transfer1
Transfer m_Transfer2
Transfer m_Transferx
Transfer m_Transfery
Transfer m_TextureScale
Transform m_Transform
Transform m_TexTransform
ImageWrapper m_Image
ColorMerge m_Adjust
TrapShape m_Texture
GradientLayer m_Merge
color clr
float u
default:
title = "MMF Two Colourings"
int param v_mmftwocolourings
caption = "Version (MMF Two Colourings)"
enum = "1.0"
default = 0
hint = "This field is to absolutely ensure backward compatibility, \
the default will always be set to the latest version, but \
there may be some cases where an older effect that you like \
is lost in an update and you could still use it by selecting \
the older version number."
visible = false
endparam
heading
caption = "Main Control"
endheading
int param mode
caption = "Colouring Mode"
enum = "Image Mapping" "Mix" "Colouring 1" "Colouring 2" "Texture Only"
default = 0
endparam
bool param usetexture
caption = "Add Texture"
default = false
hint = "Adds texturing when enabled. Normally this will be mixed in as \
a gradient index but if the colouring is in direct mode and \
you're using 'Image Mapping' then the texturing is applied as \
a colour merge layer."
visible = @mode<2
endparam
bool param polar
caption = "Go Polar"
default = false
hint = "When enabled the angle values are used as angles and the \
distance values as a magnitude, when disabled the angle values \
and distance values are taken as being on perpendicular axes."
visible = @mode<2
endparam
int param mix
caption = "Mix Method"
enum = "Sum" "Product" "Absolute Difference" "Quotient 1" "Quotient 2"
default = 0
visible = @mode==1
endparam
Transform param f_transform
caption = "Colouring Transform"
default = NullTransform
hint = "Use for rotation/scaling/positioning."
visible = @mode<2
endparam
heading
caption = "Colouring 1 Settings"
visible = @mode!=3
endheading
GradientColoring param f_colouring1
caption = "Colouring 1"
default = MMF_SmoothOrbitTraps
visible = @mode!=3
endparam
Transfer param f_transfer1
caption = "Colour Transfer 1"
default = NullTransfer
visible = @mode<3
endparam
heading
caption = "Colouring 2 Settings"
visible = @mode!=2
endheading
GradientColoring param f_colouring2
caption = "Colouring 2"
default = Standard_Smooth
visible = @mode!=2
endparam
Transfer param f_transfer2
caption = "Colour Transfer 2"
default = NullTransfer
visible = @mode!=2 && @mode!=4
endparam
heading
caption = "Image Mapping Settings"
visible = @mode==0
endheading
int param mapmethod
caption = "Image Method"
enum = "Image All" "Image Red" "Image Green" "Image Blue" "Image Alpha" \
"Image Hue" "Image Saturation" "Image Luminance"
hint = "'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."
visible = @mode==0
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 = @mode==0 && @mapmethod=="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 = @mode==0 && @mapmethod=="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 = @mode==0 && @mapmethod=="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 = @mode==0 && @mapmethod=="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 = @mode==0 && @mapmethod=="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 = @mode==0 && @mapmethod=="Image All" && @adjustlayer \
&& @adjusttype==1
endparam
ColorMerge param f_adjust
caption = "Adjustment Layer Merge"
default = MMF_ExtendedColorMerge
visible = @mode==0 && @mapmethod=="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 = @mode==0 && @mapmethod=="Image All" && @adjustlayer
endparam
ImageWrapper param f_image
caption = "Image Object"
default = MMF_ImageImport
hint = "The image to use."
visible = @mode==0
endparam
heading
caption = "Texture Settings"
visible = @mode==4 || (@mode<2 && @usetexture)
endheading
bool param polartex
caption = "Go Polar"
default = false
endparam
Transfer param f_transferx
caption = "Colouring 1 Transfer"
default = NullTransfer
visible = @mode==4 || (@mode<2 && @usetexture)
endparam
Transfer param f_transfery
caption = "Colouring 2 Transfer"
default = NullTransfer
visible = @mode==4 || (@mode<2 && @usetexture)
endparam
Transform param f_textransform
caption = "Texture Transform"
default = NullTransform
visible = @mode==4 || (@mode<2 && @usetexture)
endparam
TrapShape param f_texture
caption = "Texture"
default = MMF_TrapShapefBm
visible = @mode==4 || (@mode<2 && @usetexture)
endparam
Transfer param f_texturescale
caption = "Texture Amplitude"
default = NullTransfer
visible = @mode==4 || (@mode<2 && @usetexture)
endparam
GradientLayer param f_merge
caption = "Texture Merge"
default = MMF_GradientLayer
hint = "Only used if the main colouring is being used in direct colouring \
mode and using 'Image Mapping'. Use to merge the texture 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 = @mode<2 && @usetexture
expanded = false
endparam
}
| Constructor Summary | |
|---|---|
MMF_TwoColourings()
|
|
MMF_TwoColourings(Generic pparent)
|
|
| Method Summary | |
|---|---|
void |
Init(complex pz,
complex ppixel)
Set up for a sequence of values |
void |
Iterate(complex pz)
Process the next value in the sequence |
color |
Result(complex pz)
Produce a resulting color index after a sequence is finished |
float |
ResultIndex(complex pz)
Produce a resulting color index after a sequence is finished |
| Methods inherited from class common:GradientColoring |
|---|
IsGradient, IsSolid |
| Methods inherited from class common:Coloring |
|---|
GetPixel |
| Methods inherited from class common:Generic |
|---|
GetParent |
| Methods inherited from class Object |
|---|
|
| Constructor Detail |
|---|
public MMF_TwoColourings(Generic pparent)
public MMF_TwoColourings()
| Method Detail |
|---|
public void Init(complex pz,
complex ppixel)
GradientColoringThis function will be called at the beginning of each sequence of values (e.g. at the beginning of each fractal orbit).
Init in class GradientColoringpz - first value for the sequence; for a normal coloring formula, this will be #zppixel - seed value for the sequence; for a normal coloring formula, this will be #pixelpublic void Iterate(complex pz)
GradientColoringAs long as the sequence has not bailed out, this function will be continually called to produce sequence values. Note that such processing generally will not know in advance precisely how long the sequence is, and should be prepared to deal with sequences of arbitrary length.
Your coloring may determine at some point that a solid color should be used rather than an index value.
Iterate in class GradientColoringpz - next value in the sequence; corresponds to #z in a coloring formulapublic float ResultIndex(complex pz)
GradientColoringThis corresponds to the final: section in a coloring formula. Once it is called, no further calls to Iterate() should be made without calling Init() first.
ResultIndex in class GradientColoringpublic color Result(complex pz)
GradientColoringThis corresponds to the final: section in a coloring formula. Once it is called, no further calls to Iterate() should be made without calling Init() first.
Result in class GradientColoring
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||