|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Objectcommon:Generic
common:Coloring
common:DirectColoring
mt:MT_SpriteTrap
class
Mark Townsend, May 2008
class MT_SpriteTrap(common.ulb:DirectColoring) {
;
; Mark Townsend, May 2008
;
public:
func MT_SpriteTrap(Generic pparent)
DirectColoring(pparent)
fTrapTransform = new @p_traptransform(this)
fImage = new @p_image(this)
; if !fImage.getEmpty()
; fRatio = fImage.getWidth() / fImage.getHeight()
; else
; fRatio = 1
; endif
endfunc
func Init(complex pz, complex ppixel)
DirectColoring.Init(pz, ppixel)
fTrapTransform.Init(pz)
fTrapZ = 0
fTrapped = false
fTrapIter = 0
fIter = 0
fClr = rgb(0,0,0)
fFirst = @firstiter - 1
fLast = fFirst + @no_iters
endfunc
func Iterate(complex pz)
DirectColoring.Iterate(pz)
if !fTrapped && (fIter >= fFirst) && (fIter < fLast)
complex zt = fTrapTransform.Iterate(pz)
; fClr = fImage.getColor(real(zt) + flip(imag(zt) * fRatio))
fClr = fImage.getColor(real(zt) + flip(imag(zt)))
if alpha(fClr) > @threshold
fTrapped = true
fTrapIter = fIter
fTrapZ = pz
endif
endif
fIter = fIter + 1
endfunc
color func Result(complex pz)
color c = rgb(0,0,0)
if fTrapped
if @color_mode == "Image"
c = rgba(red(fClr), green(fClr),blue(fClr),1)
elseif @color_mode == "Iteration"
c = Gradient(0.1 * fTrapIter)
elseif @color_mode == "Magnitude"
c = Gradient(cabs(fTrapZ))
elseif @color_mode == "Real"
c = Gradient(abs(real(fTrapZ)))
elseif @color_mode == "Imag"
c = Gradient(abs(imag(fTrapZ)))
elseif @color_mode == "Angle"
float bb = atan2(fTrapZ)
if bb < 0
bb = bb + 2 * #pi
endif
bb = 1 / (2 * #pi) * bb
c = Gradient(bb)
elseif @color_mode == "Modulated Iter"
c = Gradient((fTrapIter % 8) / 8)
elseif @color_mode == "Gradient Index"
c = gradient(0.3* red(fClr)+ 0.59 * green(fClr) + 0.11 * blue(fClr))
elseif @color_mode == "Negative"
c = rgba(1-red(fClr),1-green(fClr),1-blue(fClr),1)
elseif @color_mode == "Greyscale"
float y = 0.3* red(fClr)+ 0.59 * green(fClr) + 0.11 * blue(fClr)
c = rgba(y, y, y, 1)
endif
else
m_solid = true
endif
return c
endfunc
private:
UserTransform fTrapTransform
ImageWrapper fImage
complex fTrapZ
bool fTrapped
int fTrapIter
int fIter
color fClr
int fFirst
int fLast
default:
title = "Sprite Trap"
UserTransform param p_traptransform
caption = "Trap Position"
default = TrapTransform
expanded = false
endparam
param color_mode
caption = "Coloring Mode"
enum = "Image" "Negative" "Greyscale" "Gradient Index" "Iteration" "Magnitude" "Real" \
"Imag" "Angle" "Modulated Iter"
hint = "Specifies how the trap will be colored."
endparam
float param threshold
caption = "Alpha Threshold"
default = 0.7
min = 0
max = 1
hint = "Determines what level of opacity in the image will be considered inside the trap."
endparam
int param firstiter
caption = "First Iteration"
default = 1
min = 1
hint = "Sets the first iteration that will be looked at. Raising it will remove larger elements from the foreground."
endparam
int param no_iters
caption = "No. of Iterations"
default = 10000
min = 1
hint = "Sets the number of iterations to look at. Decreasing it can remove smaller elements from the background."
endparam
ImageWrapper param p_image
caption = "Image"
default = ImageImport
endparam
}
| Constructor Summary | |
|---|---|
MT_SpriteTrap()
|
|
MT_SpriteTrap(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 |
| Methods inherited from class common:DirectColoring |
|---|
IsSolid |
| Methods inherited from class common:Coloring |
|---|
GetPixel, IsGradient |
| Methods inherited from class common:Generic |
|---|
GetParent |
| Methods inherited from class Object |
|---|
|
| Constructor Detail |
|---|
public MT_SpriteTrap(Generic pparent)
public MT_SpriteTrap()
| Method Detail |
|---|
public void Init(complex pz,
complex ppixel)
DirectColoringThis function will be called at the beginning of each sequence of values (e.g. at the beginning of each fractal orbit).
Init in class DirectColoringpz - 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)
DirectColoringAs 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 DirectColoringpz - next value in the sequence; corresponds to #z in a coloring formulapublic color Result(complex pz)
DirectColoringThis 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 DirectColoring
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||