The line colors are not significant - they are just used to make it obvious that lines cross rather than join. Bidirectional arrows denote pairs of transitions (essentially two unidirectional lines that overlap).
The sequence of allowed transitions and their effects are as follows:
- The first point's type is either
MOVE_TO
orMOVE_TO_NEXT
. - A segment containing only
CONTROL
points (0, 1, or 2) must end with aSEG_END
point. These represent straight lines, quadratic Bézier curves, and cubic Bézier curves respectively. The control points must be preceded by a point whose type isMOVE_TO
,SEG_END
orSEG_END_PREV
. - An open spline segment starts with either the end of another
segment or a point whose type is either
MOVE_TO
orMOVE_TO_NEXT
. An open spline ends with a point whose type isSEG_END
orSEG_END_PREV
, and contains points (at least one) whose types are eitherSPLINE
orSPLINE_FUNCTION
. - A closed subpath is indicated by a point whose type is
CLOSE
. If this point is preceded by a point of typeSEG_END
orSEG_END_PREV
, a straight line (unless the line will have a length of zero) will connect the previous point to the point specified by the last point whose type isMOVE_TO
orMOVE_TO_NEXT
. If a sequence ofSPLINE
orSPLINE_FUNCTION
points is terminated by aCLOSE
point, there are two cases:- If the point before the sequence of
SPLINE
orSPLINE_FUNCTION
points has a type ofCLOSE
,MOVE_TO
orMOVE_TO_NEXT
, a closed spline will be generated consisting of this initial point and the spline points. The closed path will terminate at the initial point. - If the point before the sequence of
SPLINE
orSPLINE_FUNCTION
points has a type ofSEG_END
orSEG_END_PREV
, aMOVE_TO
point at the same location will effectively be inserted, and the behavior will then match that of the previous case.
- If the point before the sequence of
An instance of SplinePathBuilder can be constructed by passing it
an instance of ScriptingContext
such
as the variable scripting
provided by the
scrunner
command. When this is done, one can use
the methods AbstractSplinePathBuilder.configure(Object)
or
AbstractSplinePathBuilder.configure(Object,Object)
to configure a
spline-path builder. For the two-argument case, the first argument
is a winding rule. This can be the string "WIND_EVEN_ODD"
or "WIND_NON_ZERO"
. Alternatively it can be a constant
whose type is SplinePathBuilder.WindingRule
.
The last argument (the only one for the one-argument case) will be
a specification for the path. This specification is an array or list
of objects that have the following attributes:
type
. This can be the string"CLOSE"
,"MOVE_TO"
,"SEG_END"
,"CONTROL"
, or"SPLINE"
. Alternatively it can a constant whose type isSplinePathBuilder.CPointType
.x
. The X coordinate of a control point. This is ignored, and may be omitted, when the type isCLOSE
.y
. The Y coordinate of a control point. This is ignored, and may be omitted, when the type isCLOSE
.
For example, with ECMAScript, scrunner
the following
statements can be used to configure a path:
The programvar path1 = [ {type: "MOVE_TO", x: 20.0, y: 30.0}, {type: "SEG_END", x: 50.0, y: 60.0}]; var path2 = [ {type: "MOVE_TO", x: 120.0, y: 130.0}, {type: "SEG_END", x: 150.0, y: 160.0}]; var pathspec = [path1, path2]; org.bzdev.geom.SplinePathBuilder pb = new org.bzdev.geom.SplinePathBuilder(scripting); pb.configure("WIND_EVEN_ODD", pathspec); var path = pb.getPath();
epts
can generate the path specifications while
providing a graphical user interface to aid in constructing the
paths.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Control Point specification for SplinePathBuilder.static enum
Type of a point along a path.static enum
Enum to define winding rules.Nested classes/interfaces inherited from class org.bzdev.scripting.ScriptingContext
ScriptingContext.BindingSwapper
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor.SplinePathBuilder
(ScriptingContext parent) Constructor providing a scripting context. -
Method Summary
Methods inherited from class org.bzdev.geom.AbstractSplinePathBuilder
append, append, append, configure, configure, constantCLOSE, constantCONTROL, constantMOVE_TO, constantSEG_END, constantSPLINE, constantWIND_EVEN_ODD, constantWIND_NON_ZERO, createCPointClose, createCPointControl, createCPointMoveTo, createCPointSegEnd, createCPointSpline, getCPoints, getNumericalLimit, initPath, initPath, initPath, initPath, modifyCPoints, modifyCPoints, setNumericalLimit
Methods inherited from class org.bzdev.scripting.ScriptingContext
callScriptFunction, callScriptFunction, callScriptMethod, callScriptMethod, containsScriptObject, createBindings, createBindingSwapper, createScriptEngine, doGetDefaultBindings, doGetScriptEngine, doGetScriptLanguage, doScriptPrivileged, evalScript, evalScript, evalScript, evalScript, getErrorWriter, getNames, getReader, getScriptLanguage, getScriptObject, getWriter, hasScriptEngine, invokePrivateFunction, invokePrivateFunction, putScriptObject, setErrorWriter, setReader, setWriter, usingGraalVM
-
Constructor Details
-
SplinePathBuilder
public SplinePathBuilder()Constructor. -
SplinePathBuilder
Constructor providing a scripting context.- Parameters:
parent
- the scripting context used to support scripting
-
-
Method Details
-
getPath
Get the path that was build.- Overrides:
getPath
in classAbstractSplinePathBuilder<SplinePath2D>
- Returns:
- the path
-