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_TOorMOVE_TO_NEXT. - A segment containing only
CONTROLpoints (0, 1, or 2) must end with either aSEG_ENDor aCLOSEpoint. 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_ENDorSEG_END_PREV. - An open spline segment starts with either the end of another
segment or a point whose type is either
MOVE_TOorMOVE_TO_NEXT. An open spline ends with a point whose type isSEG_ENDorSEG_END_PREV, and contains points (at least one) whose types are eitherSPLINEorSPLINE_FUNCTION. The sequence ofSPLINEand/orSPLINE_FUNCTIONpoints may be followed by aCONTROLor preceded by aCONTROLin order to set the first and last control point on the segment to specific values. - A closed subpath is indicated by a point whose type is
CLOSE. If this point is preceded by a point of typeSEG_ENDorSEG_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_TOorMOVE_TO_NEXT. If a sequence ofSPLINEorSPLINE_FUNCTIONpoints is terminated by aCLOSEpoint, there are two cases:- If the point before the sequence of
SPLINEorSPLINE_FUNCTIONpoints has a type ofCLOSE,MOVE_TOorMOVE_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
SPLINEorSPLINE_FUNCTIONpoints has a type ofSEG_ENDorSEG_END_PREV, aMOVE_TOpoint 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","MOVE_TO_NEXT","SEG_END","SEG_END_PREV","SEG_END_NEXT","CONTROL", or"SPLINE","SPLINE_FUNCTION". 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 classControl Point specification for SplinePathBuilder.static enumType of a point along a path.static enumEnum 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
Modifier and TypeMethodDescriptionstatic NamedFunctionOpsConvert a RealFunctionOps to a NamedFunctionOps if necessary.getPath()Get the path that was build.Methods inherited from class org.bzdev.geom.AbstractSplinePathBuilder
append, append, append, configure, configure, constantCLOSE, constantCONTROL, constantMOVE_TO, constantMOVE_TO_NEXT, constantSEG_END, constantSEG_END_NEXT, constantSEG_END_PREV, constantSPLINE, constantSPLINE_FUNCTION, constantWIND_EVEN_ODD, constantWIND_NON_ZERO, createCPointClose, createCPointControl, createCPointMoveTo, createCPointMoveToNext, createCPointSegEnd, createCPointSegEndNext, createCPointSegEndPrev, createCPointSpline, createCPointSplineFunction, getCPoints, getNumericalLimit, initPath, initPath, initPath, initPath, modifyCPoints, modifyCPoints, setNumericalLimitMethods 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
-
asNamedFunctionOps
Convert a RealFunctionOps to a NamedFunctionOps if necessary.- Parameters:
f- the function- Returns:
- either f, when f is an instance of NamedFunctionOps, or a newly created NamedFunctionOps implemented by f
-
getPath
Get the path that was build.- Overrides:
getPathin classAbstractSplinePathBuilder<SplinePath2D>- Returns:
- the path
-