Package processing.opengl
Class LinePath
java.lang.Object
processing.opengl.LinePath
The
LinePath
class allows to represent polygonal paths,
potentially composed by several disjoint polygonal segments.
It can be iterated by the LinePath.PathIterator
class including all
of its segment types and winding rules-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Ends unclosed subpaths and dash segments with no added decoration.static final int
Ends unclosed subpaths and dash segments with a round decoration that has a radius equal to half of the width of the pen.static final int
Ends unclosed subpaths and dash segments with a square projection that extends beyond the end of the segment to a distance equal to half of the line width.static final int
Joins path segments by connecting the outer corners of their wide outlines with a straight segment.static final int
Joins path segments by extending their outside edges until they meet.static final int
Joins path segments by rounding off the corner at a radius of half the line width.static final byte
Closes segment at current position.static final byte
Extends segment by adding a line to a given position.static final byte
Starts segment at a given position.static final int
The winding rule constant for specifying an even-odd rule for determining the interior of a path.static final int
The winding rule constant for specifying a non-zero rule for determining the interior of a path. -
Constructor Summary
ConstructorDescriptionLinePath()
Constructs a new empty single precisionLinePath
object with a default winding rule ofWIND_NON_ZERO
.LinePath
(int rule) Constructs a new empty single precisionLinePath
object with the specified winding rule to control operations that require the interior of the path to be defined.LinePath
(int rule, int initialCapacity) Constructs a newLinePath
object from the given specified initial values. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Closes the current subpath by drawing a straight line back to the coordinates of the lastmoveTo
.static byte[]
copyOf
(byte[] source, int length) static float[]
copyOf
(float[] source, int length) static int[]
copyOf
(int[] source, int length) static LinePath
createStrokedPath
(LinePath src, float weight, int caps, int join) static LinePath
createStrokedPath
(LinePath src, float weight, int caps, int join, float miterlimit) static LinePath
createStrokedPath
(LinePath src, float weight, int caps, int join, float miterlimit, PMatrix2D transform) Constructs a solidLinePath
with the specified attributes.The iterator for this class is not multi-threaded safe, which means that theLinePath
class does not guarantee that modifications to the geometry of thisLinePath
object do not affect any iterations of that geometry that are already in process.final int
Returns the fill style winding rule.static double
hypot
(double x, double y) static int
hypot
(int x, int y) static long
hypot
(long x, long y) static int
isqrt
(int x) final void
lineTo
(float x, float y, int c) Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates specified in float precision.static long
lsqrt
(long x) final void
moveTo
(float x, float y, int c) Adds a point to the path by moving to the specified coordinates specified in float precision.final void
reset()
Resets the path to empty.final void
setWindingRule
(int rule) Sets the winding rule for this path to the specified value.
-
Field Details
-
WIND_EVEN_ODD
public static final int WIND_EVEN_ODDThe winding rule constant for specifying an even-odd rule for determining the interior of a path. The even-odd rule specifies that a point lies inside the path if a ray drawn in any direction from that point to infinity is crossed by path segments an odd number of times.- See Also:
-
WIND_NON_ZERO
public static final int WIND_NON_ZEROThe winding rule constant for specifying a non-zero rule for determining the interior of a path. The non-zero rule specifies that a point lies inside the path if a ray drawn in any direction from that point to infinity is crossed by path segments a different number of times in the counter-clockwise direction than the clockwise direction.- See Also:
-
SEG_MOVETO
public static final byte SEG_MOVETOStarts segment at a given position.- See Also:
-
SEG_LINETO
public static final byte SEG_LINETOExtends segment by adding a line to a given position.- See Also:
-
SEG_CLOSE
public static final byte SEG_CLOSECloses segment at current position.- See Also:
-
JOIN_MITER
public static final int JOIN_MITERJoins path segments by extending their outside edges until they meet.- See Also:
-
JOIN_ROUND
public static final int JOIN_ROUNDJoins path segments by rounding off the corner at a radius of half the line width.- See Also:
-
JOIN_BEVEL
public static final int JOIN_BEVELJoins path segments by connecting the outer corners of their wide outlines with a straight segment.- See Also:
-
CAP_BUTT
public static final int CAP_BUTTEnds unclosed subpaths and dash segments with no added decoration.- See Also:
-
CAP_ROUND
public static final int CAP_ROUNDEnds unclosed subpaths and dash segments with a round decoration that has a radius equal to half of the width of the pen.- See Also:
-
CAP_SQUARE
public static final int CAP_SQUAREEnds unclosed subpaths and dash segments with a square projection that extends beyond the end of the segment to a distance equal to half of the line width.- See Also:
-
-
Constructor Details
-
LinePath
public LinePath()Constructs a new empty single precisionLinePath
object with a default winding rule ofWIND_NON_ZERO
. -
LinePath
public LinePath(int rule) Constructs a new empty single precisionLinePath
object with the specified winding rule to control operations that require the interior of the path to be defined.- Parameters:
rule
- the winding rule- See Also:
-
LinePath
public LinePath(int rule, int initialCapacity) Constructs a newLinePath
object from the given specified initial values. This method is only intended for internal use and should not be made public if the other constructors for this class are ever exposed.- Parameters:
rule
- the winding ruleinitialCapacity
- the size to make the initial array to store the path segment types
-
-
Method Details
-
moveTo
public final void moveTo(float x, float y, int c) Adds a point to the path by moving to the specified coordinates specified in float precision.This method provides a single precision variant of the double precision
moveTo()
method on the baseLinePath
class.- Parameters:
x
- the specified X coordinatey
- the specified Y coordinate- See Also:
-
lineTo
public final void lineTo(float x, float y, int c) Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates specified in float precision.This method provides a single precision variant of the double precision
lineTo()
method on the baseLinePath
class.- Parameters:
x
- the specified X coordinatey
- the specified Y coordinate- See Also:
-
getPathIterator
The iterator for this class is not multi-threaded safe, which means that theLinePath
class does not guarantee that modifications to the geometry of thisLinePath
object do not affect any iterations of that geometry that are already in process. -
closePath
public final void closePath()Closes the current subpath by drawing a straight line back to the coordinates of the lastmoveTo
. If the path is already closed then this method has no effect. -
getWindingRule
public final int getWindingRule()Returns the fill style winding rule.- Returns:
- an integer representing the current winding rule.
- See Also:
-
setWindingRule
public final void setWindingRule(int rule) Sets the winding rule for this path to the specified value.- Parameters:
rule
- an integer representing the specified winding rule- Throws:
IllegalArgumentException
- ifrule
is not eitherWIND_EVEN_ODD
orWIND_NON_ZERO
- See Also:
-
reset
public final void reset()Resets the path to empty. The append position is set back to the beginning of the path and all coordinates and point types are forgotten. -
createStrokedPath
-
createStrokedPath
-
createStrokedPath
public static LinePath createStrokedPath(LinePath src, float weight, int caps, int join, float miterlimit, PMatrix2D transform) Constructs a solidLinePath
with the specified attributes.- Parameters:
src
- the original path to be strokedweight
- the weight of the stroked pathcaps
- the decoration of the ends of the segments in the pathjoin
- the decoration applied where path segments meetmiterlimit
-transform
-
-
copyOf
public static float[] copyOf(float[] source, int length) -
copyOf
public static byte[] copyOf(byte[] source, int length) -
copyOf
public static int[] copyOf(int[] source, int length) -
isqrt
public static int isqrt(int x) -
lsqrt
public static long lsqrt(long x) -
hypot
public static double hypot(double x, double y) -
hypot
public static int hypot(int x, int y) -
hypot
public static long hypot(long x, long y)
-