|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object common:Generic common:Transform common:UserTransform dmj5:DMJ_FollowCurve
class
Distort to follow an arbitrary curve. (BETA, SUBJECT TO CHANGE)
You can use this transform to make a fractal shape follow a
curve that you define.
class DMJ_FollowCurve(common.ulb:UserTransform) { ; Distort to follow an arbitrary curve. (BETA, SUBJECT TO CHANGE) ; You can use this transform to make a fractal shape follow a ; curve that you define. public: import "common.ulb" ; $define debug func DMJ_FollowCurve(Generic pparent) UserTransform.UserTransform(pparent) m_PolyCurve = new DMJ_PolyCurve() m_Selector = new @f_selector(pparent) m_Selector.SetCurve(m_PolyCurve) m_PolyCurve.SetExtensionMode(@p_endpoints) m_PolyCurve.Rasterize(1) ; note that we enable arc lengths (makes Rasterize() slower) m_Handles = new @f_handles(pparent) ; create handle object m_Selector.SetHandles(m_Handles) ; note we're not allowing screen-relative here endfunc func Init(complex pz) UserTransform.Init(pz) m_Handles.Init(pz) endfunc complex func Iterate(complex pz) complex point float segment = 0 float segmentoffset = 0 float distancesquared = 0 float isleft = 0.0 complex oz = pz ; the assignment here seems to be required point = \ m_PolyCurve.ClosestPoint(pz, segment, segmentoffset, distancesquared) isleft = m_PolyCurve.IsLeft(pz, floor(segment)) pz = m_PolyCurve.DistanceAlongCurve(segment, true) ; should be a parameter here instead of true pz = pz + segmentoffset ; if we have a linear offset (extended segment), include it if (isleft > 0) isleft = 1 elseif (isleft < 0) isleft = -1 endif $ifdef debug int testx = 700 int testy = 400 if (#x == testx && #y == testy) print("FollowCurve.Iterate() trace") print("ClosestPoint: ", point) print("segment: ", segment) print("segmentoffset: ", segmentoffset) print("IsLeft: ", isleft) print("IsLeft1: ", m_PolyCurve.IsLeftLine(oz, (-1.5,0), (1.5,0))) print("IsLeft2: ", m_PolyCurve.IsLeftLine(oz, (1.5,0), (0,-1))) print("IsLeft3: ", m_PolyCurve.IsLeftLine(oz, (0,-1), (-1.5,0))) print("IsLeft4: ", m_PolyCurve.IsLeftQuadraticCore(oz, (-1.5,0), (0,-1), (1.5,0))) print("IsLeft5: ", m_PolyCurve.IsLeftLine((0,-1), (-1.5,0), (1.5,0))) print("DistanceAlongCurve: ", pz-segmentoffset) endif $endif pz = (real(pz)+real(@p_offset))*real(@p_scale) + flip(-sqrt(distancesquared)*isleft+imag(@p_offset))*imag(@p_scale) $ifdef debug if (#x == testx && #y == testy) print("final pz: ", pz) endif $endif m_Handles.Iterate(pz) m_Solid = m_Handles.IsSolid() point = point + 1 ; **** silences compiler warning return pz endfunc protected: DMJ_PolyCurve m_PolyCurve Handles m_Handles DMJ_PolyCurveSelector m_Selector default: title = "Follow Curve (BETA)" rating = notRecommended int param v_dmj_followcurve caption = "Version (DMJ_FollowCurve)" 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_dmj_followcurve < 100 endparam complex param p_offset caption = "Origin" default = (0,0) hint = "Sets the origin for transformed pixels. This is the point that will be used at the starting point of the curve. The easiest way to set this is to disable the transform, then use the eyedropper." endparam complex param p_scale caption = "Scale" default = (1,1) hint = "Sets the scale of the transform around the shape (real) and out from the shape (imaginary)." endparam int param p_endpoints caption = "Endpoints" default = 1 enum = "stop at ends" "extend lines" hint = "Sets how the transform will behave near unclosed curve endpoints. 'Stop at ends' will cause the transform to curve inward at the ends. 'Extend lines' will act as though the curve has been extended in infinite lines from the endpoints. This parameter has no effect if your curve is completely closed." endparam int param p_method caption = "Mapping Method" default = 0 enum = "closest point" "closest curve" visible = false hint = "Sets the method the transform will use to warp the complex plane to follow your curve. 'Closest point' is fast and works reasonably well, but in tight corners or at large distances from the curve it may show unwanted bunching. 'Closest curve' is slower but handles tight corners better." endparam heading caption = "Handle Options" expanded = false endheading Handles param f_handles caption = "Handle Options" selectable = false endparam heading caption = "Curve Options" expanded = true endheading DMJ_PolyCurveSelector param f_selector caption = "Curve Definition" default = DMJ_SelectorArbitraryPolygon hint = "Sets the method by which you will define your curve or polygon." endparam }
Constructor Summary | |
---|---|
DMJ_FollowCurve()
|
|
DMJ_FollowCurve(Generic pparent)
$define debug |
Method Summary | |
---|---|
void |
Init(complex pz)
Set up for a sequence of values |
complex |
Iterate(complex pz)
Transform a single point within a sequence |
Methods inherited from class common:Transform |
---|
IsSolid, IterateSilent |
Methods inherited from class common:Generic |
---|
GetParent |
Methods inherited from class Object |
---|
|
Constructor Detail |
---|
public DMJ_FollowCurve(Generic pparent)
public DMJ_FollowCurve()
Method Detail |
---|
public void Init(complex pz)
Transform
This function will be called at the beginning of each sequence of values (e.g. at the beginning of each fractal orbit). It will be called even if only one value is being transformed (e.g. a normal transformation formula). Use this to perform any setup that is exactly the same for each value in the sequence being transformed.
Init
in class Transform
pz
- the value representing the sequence; for a normal transformation formula use, this will be #pixel. In some cases this may differ from the first value passed to Iterate() if the calling code applies some other transformations.public complex Iterate(complex pz)
Transform
After a sequence has been set up with Init(), this function will be called once for each value in the sequence. Note that all values in the sequence must be processed in order (they cannot be processed out of order). If the sequence contains only one value, Init() will still be called and then Iterate() will be called just once.
Iterate
in class Transform
pz
- the complex value to be transformed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |