- java.lang.Object
-
- processing.opengl.LinePath
-
public class LinePath extends Object
TheLinePathclass allows to represent polygonal paths, potentially composed by several disjoint polygonal segments. It can be iterated by theLinePath.PathIteratorclass including all of its segment types and winding rules
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLinePath.PathIterator
-
Field Summary
Fields Modifier and Type Field Description static intCAP_BUTTEnds unclosed subpaths and dash segments with no added decoration.static intCAP_ROUNDEnds unclosed subpaths and dash segments with a round decoration that has a radius equal to half of the width of the pen.static intCAP_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.protected float[]floatCoordsstatic intJOIN_BEVELJoins path segments by connecting the outer corners of their wide outlines with a straight segment.static intJOIN_MITERJoins path segments by extending their outside edges until they meet.static intJOIN_ROUNDJoins path segments by rounding off the corner at a radius of half the line width.protected intnumCoordsprotected intnumTypesprotected int[]pointColorsprotected byte[]pointTypesstatic byteSEG_CLOSECloses segment at current position.static byteSEG_LINETOExtends segment by adding a line to a given position.static byteSEG_MOVETOStarts segment at a given position.static intWIND_EVEN_ODDThe winding rule constant for specifying an even-odd rule for determining the interior of a path.static intWIND_NON_ZEROThe winding rule constant for specifying a non-zero rule for determining the interior of a path.protected intwindingRule
-
Constructor Summary
Constructors Constructor Description LinePath()Constructs a new empty single precisionLinePathobject with a default winding rule ofWIND_NON_ZERO.LinePath(int rule)Constructs a new empty single precisionLinePathobject 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 newLinePathobject from the given specified initial values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclosePath()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 LinePathcreateStrokedPath(LinePath src, float weight, int caps, int join)static LinePathcreateStrokedPath(LinePath src, float weight, int caps, int join, float miterlimit)static LinePathcreateStrokedPath(LinePath src, float weight, int caps, int join, float miterlimit, PMatrix2D transform)Constructs a solidLinePathwith the specified attributes.LinePath.PathIteratorgetPathIterator()The iterator for this class is not multi-threaded safe, which means that theLinePathclass does not guarantee that modifications to the geometry of thisLinePathobject do not affect any iterations of that geometry that are already in process.intgetWindingRule()Returns the fill style winding rule.static doublehypot(double x, double y)static inthypot(int x, int y)static longhypot(long x, long y)static intisqrt(int x)voidlineTo(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 longlsqrt(long x)voidmoveTo(float x, float y, int c)Adds a point to the path by moving to the specified coordinates specified in float precision.voidreset()Resets the path to empty.voidsetWindingRule(int rule)Sets the winding rule for this path to the specified value.
-
-
-
Field Detail
-
WIND_EVEN_ODD
public static final int WIND_EVEN_ODD
The 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:
- Constant Field Values
-
WIND_NON_ZERO
public static final int WIND_NON_ZERO
The 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:
- Constant Field Values
-
SEG_MOVETO
public static final byte SEG_MOVETO
Starts segment at a given position.- See Also:
- Constant Field Values
-
SEG_LINETO
public static final byte SEG_LINETO
Extends segment by adding a line to a given position.- See Also:
- Constant Field Values
-
SEG_CLOSE
public static final byte SEG_CLOSE
Closes segment at current position.- See Also:
- Constant Field Values
-
JOIN_MITER
public static final int JOIN_MITER
Joins path segments by extending their outside edges until they meet.- See Also:
- Constant Field Values
-
JOIN_ROUND
public static final int JOIN_ROUND
Joins path segments by rounding off the corner at a radius of half the line width.- See Also:
- Constant Field Values
-
JOIN_BEVEL
public static final int JOIN_BEVEL
Joins path segments by connecting the outer corners of their wide outlines with a straight segment.- See Also:
- Constant Field Values
-
CAP_BUTT
public static final int CAP_BUTT
Ends unclosed subpaths and dash segments with no added decoration.- See Also:
- Constant Field Values
-
CAP_ROUND
public static final int CAP_ROUND
Ends unclosed subpaths and dash segments with a round decoration that has a radius equal to half of the width of the pen.- See Also:
- Constant Field Values
-
CAP_SQUARE
public static final int CAP_SQUARE
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.- See Also:
- Constant Field Values
-
pointTypes
protected byte[] pointTypes
-
floatCoords
protected float[] floatCoords
-
pointColors
protected int[] pointColors
-
numTypes
protected int numTypes
-
numCoords
protected int numCoords
-
windingRule
protected int windingRule
-
-
Constructor Detail
-
LinePath
public LinePath()
Constructs a new empty single precisionLinePathobject with a default winding rule ofWIND_NON_ZERO.
-
LinePath
public LinePath(int rule)
Constructs a new empty single precisionLinePathobject 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:
WIND_EVEN_ODD,WIND_NON_ZERO
-
LinePath
public LinePath(int rule, int initialCapacity)Constructs a newLinePathobject 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 Detail
-
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 baseLinePathclass.- Parameters:
x- the specified X coordinatey- the specified Y coordinate- See Also:
moveTo(float, float, int)
-
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 baseLinePathclass.- Parameters:
x- the specified X coordinatey- the specified Y coordinate- See Also:
lineTo(float, float, int)
-
getPathIterator
public LinePath.PathIterator getPathIterator()
The iterator for this class is not multi-threaded safe, which means that theLinePathclass does not guarantee that modifications to the geometry of thisLinePathobject 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:
WIND_EVEN_ODD,WIND_NON_ZERO,setWindingRule(int)
-
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- ifruleis not eitherWIND_EVEN_ODDorWIND_NON_ZERO- See Also:
getWindingRule()
-
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
public static LinePath createStrokedPath(LinePath src, float weight, int caps, int join)
-
createStrokedPath
public static LinePath createStrokedPath(LinePath src, float weight, int caps, int join, float miterlimit)
-
createStrokedPath
public static LinePath createStrokedPath(LinePath src, float weight, int caps, int join, float miterlimit, PMatrix2D transform)
Constructs a solidLinePathwith 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)
-
-