|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Objectcommon:Generic
common:Coloring
common:GradientColoring
jlb:JLB_RangeColoring
class
JLB_Range Coloring. Mostly adapted from dmj5.ulb:OrbitTrapsColoring.
Select shapes whose distance is within a range of distances from a curve.
Can mimic Rose Range Lite.
class JLB_RangeColoring(common.ulb:GradientColoring) {
; JLB_Range Coloring. Mostly adapted from dmj5.ulb:OrbitTrapsColoring. <br>
; Select shapes whose distance is within a range of distances from a curve.
; Can mimic Rose Range Lite.
;
public:
import "common.ulb"
import "dmj5.ulb"
func JLB_RangeColoring(Generic pparent)
GradientColoring.GradientColoring(pparent)
m_TrapSelect = new @f_trapselect(this)
m_TrapMode = new @f_trapmode(this)
m_TrapShape = new @f_TrapShape(this)
endfunc
func Init(complex pz, complex ppixel)
GradientColoring.Init(pz, ppixel)
m_TrapSelectSequence = m_TrapSelect.InitDefault()
m_TrapMode.Init(pz)
m_RangeLow = @p_scale*(1.0-0.5*@p_width)
m_RangeHigh = @p_scale*(1.0+0.5*@p_width)
float ang = -@p_rot*#pi/180
m_Rotate = cos(ang) + flip(sin(ang))
endfunc
func Iterate(complex pz)
GradientColoring.Iterate(pz)
; Maybe use only some iterations
m_TrapSelectSequence = m_TrapSelect.Iterate(m_TrapSelectSequence)
if ((@f_trapselect == DMJ_TrapSelect && m_TrapSelectSequence > 0.5) || \
m_TrapSelectSequence > @p_trapselectthreshold)
complex zt = pz * m_Rotate
float dist = m_TrapShape.Iterate(zt)
float dmin = dist*m_RangeLow
float dmax = dist*m_RangeHigh
dist = cabs(pz - @p_Center)
if((dist >= dmin) && (dist <= dmax)) ; in the range
if (@p_coloring == "magnitude")
dist = (dist-dmin)/(dmax-dmin) ; 0 <= dist <= 1
else ;if (@p_coloring == "angle")
dist = atan2(zt)
if (dist < 0)
dist = dist + (2*#pi)
endif
dist = dist / (2*#pi) ; 0 <= dist <= 1
endif
m_TrapMode.Iterate(pz, zt, dist, 0.0)
else
m_TrapMode.IterateSilent()
endif
endif
endfunc
float func ResultIndex(complex pz)
GradientColoring.ResultIndex(pz)
float index = m_TrapMode.GetDistance(0)
m_Solid = @p_usesolid && m_TrapMode.IsSolid()
return index
endfunc
protected:
Generator m_TrapSelect
TrapMode m_TrapMode
TrapShape m_TrapShape
float m_TrapSelectSequence
float m_RangeLow
float m_RangeHigh
complex m_Rotate
default:
title = "Range Gradient"
int param v_jlb_rangecoloring
caption = "Version (JLB_RangeColoring)"
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_jlb_rangecoloring < 100
endparam
Generator param f_trapselect
caption = "Trap Iteration"
default = DMJ_TrapSelect
expanded = false
endparam
heading
caption = "Range Coloring Parameters"
endheading
float param p_trapselectthreshold
caption = "Threshold"
default = 0.5
hint = "When using a Generator other than a TrapSelect type, values could range anywhere from 0 to 1. This threshold sets which values will be interpreted as 'do not trap' and which will be interpreted as 'trap'."
visible = (@f_trapselect != DMJ_TrapSelect)
endparam
param p_scale
caption = "Range scale"
default = 1.0
endparam
param p_width
caption = "Range width"
default = 0.1
endparam
complex param p_Center
caption = "Curve center"
default = (0.0,0.0)
endparam
float param p_rot
caption = "Rotation angle"
default = 0.0
hint = "degrees"
endparam
param p_coloring
caption = "Color by"
enum = "magnitude" "angle"
default = 0
endparam
bool param p_usesolid
caption = "Use Solid Color"
default = true
hint = "If checked, any areas not inside any trap shape will be colored \
the solid color."
endparam
TrapShape param f_TrapShape
caption = "TrapShape function"
default = JLB_TrapShapeRRL
endparam
TrapMode param f_trapmode
caption = "Trap Mode"
default = DMJ_TrapModeLast
endparam
}
| Constructor Summary | |
|---|---|
JLB_RangeColoring()
|
|
JLB_RangeColoring(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 |
float |
ResultIndex(complex pz)
Produce a resulting color index after a sequence is finished |
| Methods inherited from class common:GradientColoring |
|---|
IsGradient, IsSolid, Result |
| Methods inherited from class common:Coloring |
|---|
GetPixel |
| Methods inherited from class common:Generic |
|---|
GetParent |
| Methods inherited from class Object |
|---|
|
| Constructor Detail |
|---|
public JLB_RangeColoring(Generic pparent)
public JLB_RangeColoring()
| 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 GradientColoring
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||