Class Path
- java.lang.Object
-
- io.github.humbleui.skija.impl.Native
-
- io.github.humbleui.skija.impl.Managed
-
- io.github.humbleui.skija.Path
-
- All Implemented Interfaces:
java.lang.AutoCloseable,java.lang.Iterable<PathSegment>
public class Path extends Managed implements java.lang.Iterable<PathSegment>
Path contain geometry. Path may be empty, or contain one or more verbs that outline a figure. Path always starts with a move verb to a Cartesian coordinate, and may be followed by additional verbs that add lines or curves.
Adding a close verb makes the geometry into a continuous loop, a closed contour. Path may contain any number of contours, each beginning with a move verb.
Path contours may contain only a move verb, or may also contain lines, quadratic beziers, conics, and cubic beziers. Path contours may be open or closed.
When used to draw a filled area, Path describes whether the fill is inside or outside the geometry. Path also describes the winding rule used to fill overlapping contours.
Internally, Path lazily computes metrics likes bounds and convexity. Call
updateBoundsCache()to make Path thread safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPath._FinalizerHolder-
Nested classes/interfaces inherited from class io.github.humbleui.skija.impl.Managed
Managed.CleanerThunk
-
-
Field Summary
-
Fields inherited from class io.github.humbleui.skija.impl.Managed
_cleanable
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void_nAddArc(long ptr, float l, float t, float r, float b, float startAngle, float sweepAngle)static void_nAddCircle(long ptr, float x, float y, float r, int dir)static void_nAddOval(long ptr, float l, float t, float r, float b, int dir, int start)static void_nAddPath(long ptr, long srcPtr, boolean extend)static void_nAddPathOffset(long ptr, long srcPtr, float dx, float dy, boolean extend)static void_nAddPathTransform(long ptr, long srcPtr, float[] matrix, boolean extend)static void_nAddPoly(long ptr, float[] coords, boolean close)static void_nAddRect(long ptr, float l, float t, float r, float b, int dir, int start)static void_nAddRRect(long ptr, float l, float t, float r, float b, float[] radii, int dir, int start)static long_nApproximateBytesUsed(long ptr)static void_nArcTo(long ptr, float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean forceMoveTo)boolean_nativeEquals(Native other)Compares this path and o; Returns true ifPathFillMode, verb array, Point array, and weights are equivalent.static void_nClosePath(long ptr)static io.github.humbleui.types.Rect_nComputeTightBounds(long ptr)static void_nConicTo(long ptr, float x1, float y1, float x2, float y2, float w)static boolean_nConservativelyContainsRect(long ptr, float l, float t, float r, float b)static boolean_nContains(long ptr, float x, float y)static io.github.humbleui.types.Point[]_nConvertConicToQuads(float x0, float y0, float x1, float y1, float x2, float y2, float w, int pow2)static int_nCountVerbs(long ptr)static void_nCubicTo(long ptr, float x1, float y1, float x2, float y2, float x3, float y3)static void_nDump(long ptr)static void_nDumpHex(long ptr)static void_nEllipticalArcTo(long ptr, float rx, float ry, float xAxisRotate, int size, int direction, float x, float y)static boolean_nEquals(long aPtr, long bPtr)static io.github.humbleui.types.Rect_nGetBounds(long ptr)static int_nGetFillMode(long ptr)static long_nGetFinalizer()static int_nGetGenerationId(long ptr)static io.github.humbleui.types.Point_nGetLastPt(long ptr)static io.github.humbleui.types.Point_nGetPoint(long ptr, int index)static int_nGetPoints(long ptr, io.github.humbleui.types.Point[] points, int max)static int_nGetPointsCount(long ptr)static int_nGetSegmentMasks(long ptr)static int_nGetVerbs(long ptr, byte[] verbs, int max)static void_nIncReserve(long ptr, int extraPtCount)static boolean_nIsConvex(long ptr)static boolean_nIsCubicDegenerate(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, boolean exact)static boolean_nIsEmpty(long ptr)static boolean_nIsFinite(long ptr)static boolean_nIsInterpolatable(long ptr, long comparePtr)static boolean_nIsLastContourClosed(long ptr)static boolean_nIsLineDegenerate(float x0, float y0, float x1, float y1, boolean exact)static io.github.humbleui.types.Rect_nIsOval(long ptr)static boolean_nIsQuadDegenerate(float x0, float y0, float x1, float y1, float x2, float y2, boolean exact)static io.github.humbleui.types.Rect_nIsRect(long ptr)static io.github.humbleui.types.RRect_nIsRRect(long ptr)static boolean_nIsValid(long ptr)static boolean_nIsVolatile(long ptr)static void_nLineTo(long ptr, float x, float y)static long_nMake()static long_nMakeCombining(long onePtr, long twoPtr, int op)static long_nMakeFromBytes(byte[] data)static long_nMakeFromSVGString(java.lang.String s)static long_nMakeLerp(long ptr, long endingPtr, float weight)static io.github.humbleui.types.Point[]_nMaybeGetAsLine(long ptr)static void_nMoveTo(long ptr, float x, float y)static void_nOffset(long ptr, float dx, float dy, long dst)static void_nQuadTo(long ptr, float x1, float y1, float x2, float y2)static void_nRConicTo(long ptr, float dx1, float dy1, float dx2, float dy2, float w)static void_nRCubicTo(long ptr, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3)static void_nREllipticalArcTo(long ptr, float rx, float ry, float xAxisRotate, int size, int direction, float dx, float dy)static void_nReset(long ptr)static void_nReverseAddPath(long ptr, long srcPtr)static void_nRewind(long ptr)static void_nRLineTo(long ptr, float dx, float dy)static void_nRMoveTo(long ptr, float dx, float dy)static void_nRQuadTo(long ptr, float dx1, float dy1, float dx2, float dy2)static byte[]_nSerializeToBytes(long ptr)static void_nSetFillMode(long ptr, int fillMode)static void_nSetLastPt(long ptr, float x, float y)static void_nSetVolatile(long ptr, boolean isVolatile)static void_nSwap(long ptr, long otherPtr)static void_nTangentArcTo(long ptr, float x1, float y1, float x2, float y2, float radius)static void_nTransform(long ptr, float[] matrix, long dst, boolean applyPerspectiveClip)static void_nUpdateBoundsCache(long ptr)PathaddArc(io.github.humbleui.types.Rect oval, float startAngle, float sweepAngle)Appends arc to Path, as the start of new contour.PathaddCircle(float x, float y, float radius)Adds circle centered at (x, y) of size radius to Path, appendingPathVerb.MOVE, fourPathVerb.CONIC, andPathVerb.CLOSE.PathaddCircle(float x, float y, float radius, PathDirection dir)Adds circle centered at (x, y) of size radius to Path, appendingPathVerb.MOVE, fourPathVerb.CONIC, andPathVerb.CLOSE.PathaddOval(io.github.humbleui.types.Rect oval)PathaddOval(io.github.humbleui.types.Rect oval, PathDirection dir)PathaddOval(io.github.humbleui.types.Rect oval, PathDirection dir, int start)PathaddPath(Path src)Appends src to Path.PathaddPath(Path src, boolean extend)Appends src to Path.PathaddPath(Path src, float dx, float dy)Appends src to Path, offset by (dx, dy).PathaddPath(Path src, float dx, float dy, boolean extend)Appends src to Path, offset by (dx, dy).PathaddPath(Path src, Matrix33 matrix)Appends src to Path, transformed by matrix.PathaddPath(Path src, Matrix33 matrix, boolean extend)Appends src to Path, transformed by matrix.PathaddPoly(float[] pts, boolean close)Adds contour created from line array, adding (pts.length / 2 - 1) line segments.PathaddPoly(io.github.humbleui.types.Point[] pts, boolean close)Adds contour created from line array, adding (pts.length - 1) line segments.PathaddRect(io.github.humbleui.types.Rect rect)Adds Rect to Path, appendingPathVerb.MOVE, threePathVerb.LINE, andPathVerb.CLOSE, starting with top-left corner of Rect; followed by top-right, bottom-right, and bottom-left.PathaddRect(io.github.humbleui.types.Rect rect, PathDirection dir)Adds Rect to Path, appendingPathVerb.MOVE, threePathVerb.LINE, andPathVerb.CLOSE, starting with top-left corner of Rect; followed by top-right, bottom-right, and bottom-left if dir isPathDirection.CLOCKWISE; or followed by bottom-left, bottom-right, and top-right if dir isPathDirection.COUNTER_CLOCKWISE.PathaddRect(io.github.humbleui.types.Rect rect, PathDirection dir, int start)PathaddRRect(io.github.humbleui.types.RRect rrect)Adds rrect to Path, creating a new closed contour.PathaddRRect(io.github.humbleui.types.RRect rrect, PathDirection dir)Adds rrect to Path, creating a new closed contour.PathaddRRect(io.github.humbleui.types.RRect rrect, PathDirection dir, int start)Adds rrect to Path, creating a new closed contour.PatharcTo(io.github.humbleui.types.Rect oval, float startAngle, float sweepAngle, boolean forceMoveTo)Appends arc to Path.PathclosePath()AppendsPathVerb.CLOSEto Path.io.github.humbleui.types.RectcomputeTightBounds()Returns minimum and maximum axes values of the lines and curves in Path.PathconicTo(float x1, float y1, float x2, float y2, float w)Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.PathconicTo(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, float w)Adds conic from last point towards Point p1, to Point p2, weighted by w.booleanconservativelyContainsRect(io.github.humbleui.types.Rect rect)Returns true if rect is contained by Path.booleancontains(float x, float y)Returns true if the point (x, y) is contained by Path, taking into accountPathFillMode.booleancontains(io.github.humbleui.types.Point p)Returns true if the point is contained by Path, taking into accountPathFillMode.static io.github.humbleui.types.Point[]convertConicToQuads(io.github.humbleui.types.Point p0, io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, float w, int pow2)Approximates conic with quad array.PathcubicTo(float x1, float y1, float x2, float y2, float x3, float y3)Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at (x3, y3).PathcubicTo(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, io.github.humbleui.types.Point p3)Adds cubic from last point towards Point p1, then towards Point p2, ending at Point p3.Pathdump()Writes text representation of Path to standard output.PathdumpHex()Writes text representation of Path to standard output.PathellipticalArcTo(float rx, float ry, float xAxisRotate, PathEllipseArc arc, PathDirection direction, float x, float y)Appends arc to Path.PathellipticalArcTo(io.github.humbleui.types.Point r, float xAxisRotate, PathEllipseArc arc, PathDirection direction, io.github.humbleui.types.Point xy)Appends arc to Path.longgetApproximateBytesUsed()Returns the approximate byte size of the Path in memory.io.github.humbleui.types.Point[]getAsLine()Returns array of two points if Path contains only one line; Verb array has two entries:PathVerb.MOVE,PathVerb.LINE.io.github.humbleui.types.RectgetBounds()Returns minimum and maximum axes values of Point array.PathFillModegetFillMode()intgetGenerationId()Returns a non-zero, globally unique value.io.github.humbleui.types.PointgetLastPt()Returns last point on Path in lastPt.io.github.humbleui.types.PointgetPoint(int index)Returns Point at index in Point array.io.github.humbleui.types.Point[]getPoints()Returns all points in Path.intgetPoints(io.github.humbleui.types.Point[] points, int max)Returns number of points in Path.intgetPointsCount()Returns the number of points in Path.intgetSegmentMasks()Returns a mask, where each set bit corresponds to a SegmentMask constant if Path contains one or more verbs of that type.PathVerb[]getVerbs()intgetVerbs(PathVerb[] verbs, int max)Returns the number of verbs in the path.intgetVerbsCount()Returns the number of verbs:PathVerb.MOVE,PathVerb.LINE,PathVerb.QUAD,PathVerb.CONIC,PathVerb.CUBIC, andPathVerb.CLOSE; added to Path.PathincReserve(int extraPtCount)Grows Path verb array and Point array to contain extraPtCount additional Point.booleanisConvex()Returns true if the path is convex.static booleanisCubicDegenerate(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, io.github.humbleui.types.Point p3, io.github.humbleui.types.Point p4, boolean exact)Tests if cubic is degenerate.booleanisEmpty()Returns if Path is empty.booleanisFinite()Returns true for finite Point array values between negative Float.MIN_VALUE and positive Float.MAX_VALUE.booleanisInterpolatable(Path compare)Returns true if Path contain equal verbs and equal weights.booleanisLastContourClosed()Returns if contour is closed.static booleanisLineDegenerate(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, boolean exact)Tests if line between Point pair is degenerate.io.github.humbleui.types.RectisOval()Returns oval bounds if this path is recognized as an oval or circle.static booleanisQuadDegenerate(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, io.github.humbleui.types.Point p3, boolean exact)Tests if quad is degenerate.io.github.humbleui.types.RectisRect()Returns Rect if Path is equivalent to Rect when filled.io.github.humbleui.types.RRectisRRect()ReturnsRRectif this path is recognized as an oval, circle or RRect.booleanisValid()Returns if Path data is consistent.booleanisVolatile()Returns true if the path is volatile; it will not be altered or discarded by the caller after it is drawn.PathSegmentIteratoriterator()PathSegmentIteratoriterator(boolean forceClose)PathlineTo(float x, float y)Adds line from last point to (x, y).PathlineTo(io.github.humbleui.types.Point p)Adds line from last point to Point p.static @Nullable PathmakeCombining(@NotNull Path one, @NotNull Path two, PathOp op)Returns Path that is the result of applying the Op to the first path and the second path.static PathmakeFromBytes(byte[] data)Initializes Path from byte buffer.static @NotNull PathmakeFromSVGString(java.lang.String svg)PathmakeLerp(Path ending, float weight)Interpolates between Path withPointarray of equal size.PathmoveTo(float x, float y)Adds beginning of contour at Point (x, y).PathmoveTo(io.github.humbleui.types.Point p)Adds beginning of contour at Point p.Pathoffset(float dx, float dy)Offsets Point array by (dx, dy).Pathoffset(float dx, float dy, Path dst)Offsets Point array by (dx, dy).PathquadTo(float x1, float y1, float x2, float y2)Adds quad from last point towards (x1, y1), to (x2, y2).PathquadTo(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2)Adds quad from last point towards Point p1, to Point p2.PathrConicTo(float dx1, float dy1, float dx2, float dy2, float w)Adds conic from last point towards vector (dx1, dy1), to vector (dx2, dy2), weighted by w.PathrCubicTo(float dx1, float dy1, float dx2, float dy2, float dx3, float dy3)Adds cubic from last point towards vector (dx1, dy1), then towards vector (dx2, dy2), to vector (dx3, dy3).PathrEllipticalArcTo(float rx, float ry, float xAxisRotate, PathEllipseArc arc, PathDirection direction, float dx, float dy)Appends arc to Path, relative to last Path Point.Pathreset()Sets Path to its initial state.PathreverseAddPath(Path src)Appends src to Path, from back to front.Pathrewind()Sets Path to its initial state, preserving internal storage.PathrLineTo(float dx, float dy)Adds line from last point to vector (dx, dy).PathrMoveTo(float dx, float dy)Adds beginning of contour relative to last point.PathrQuadTo(float dx1, float dy1, float dx2, float dy2)Adds quad from last point towards vector (dx1, dy1), to vector (dx2, dy2).byte[]serializeToBytes()Writes Path to byte buffer.PathsetFillMode(PathFillMode fillMode)PathsetLastPt(float x, float y)Sets last point to (x, y).PathsetLastPt(io.github.humbleui.types.Point p)Sets the last point on the path.PathsetVolatile(boolean isVolatile)Specifies whether Path is volatile; whether it will be altered or discarded by the caller after it is drawn.Pathswap(Path other)Exchanges the verb array, Point array, weights, and FillMode with other.PathtangentArcTo(float x1, float y1, float x2, float y2, float radius)Appends arc to Path, after appending line if needed.PathtangentArcTo(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, float radius)Appends arc to Path, after appending line if needed.Pathtransform(Matrix33 matrix)Transforms verb array, Point array, and weight by matrix.Pathtransform(Matrix33 matrix, boolean applyPerspectiveClip)Transforms verb array, Point array, and weight by matrix.Pathtransform(Matrix33 matrix, Path dst)Transforms verb array, Point array, and weight by matrix.Pathtransform(Matrix33 matrix, Path dst, boolean applyPerspectiveClip)Transforms verb array, Point array, and weight by matrix.PathupdateBoundsCache()Updates internal bounds so that subsequent calls togetBounds()are instantaneous.-
Methods inherited from class io.github.humbleui.skija.impl.Managed
_nInvokeFinalizer, close, isClosed
-
Methods inherited from class io.github.humbleui.skija.impl.Native
equals, getPtr, hashCode, toString
-
-
-
-
Constructor Detail
-
Path
public Path()
Constructs an empty Path. By default, Path has no verbs, noPoint, and no weights. FillMode is set toPathFillMode.WINDING.
-
Path
@Internal public Path(long ptr)
-
-
Method Detail
-
makeFromSVGString
@NotNull public static @NotNull Path makeFromSVGString(java.lang.String svg)
-
_nativeEquals
@Internal public boolean _nativeEquals(Native other)
Compares this path and o; Returns true ifPathFillMode, verb array, Point array, and weights are equivalent.- Overrides:
_nativeEqualsin classNative- Parameters:
other- Path to compare- Returns:
- true if this and Path are equivalent
-
isInterpolatable
public boolean isInterpolatable(Path compare)
Returns true if Path contain equal verbs and equal weights. If Path contain one or more conics, the weights must match.
conicTo(float, float, float, float, float)may add different verbs depending on conic weight, so it is not trivial to interpolate a pair of Path containing conics with different conic weight values.- Parameters:
compare- Path to compare- Returns:
- true if Path verb array and weights are equivalent
- See Also:
- https://fiddle.skia.org/c/@Path_isInterpolatable
-
makeLerp
public Path makeLerp(Path ending, float weight)
Interpolates between Path with
Pointarray of equal size. Copy verb array and weights to out, and set out Point array to a weighted average of this Point array and ending Point array, using the formula:(Path Point * weight) + ending Point * (1 - weight)weight is most useful when between zero (ending Point array) and one (this Point_Array); will work with values outside of this range.
interpolate() returns null if Point array is not the same size as ending Point array. Call
isInterpolatable(Path)to check Path compatibility prior to calling interpolate().- Parameters:
ending- Point array averaged with this Point arrayweight- contribution of this Point array, and one minus contribution of ending Point array- Returns:
- interpolated Path if Path contain same number of Point, null otherwise
- See Also:
- https://fiddle.skia.org/c/@Path_interpolate
-
getFillMode
public PathFillMode getFillMode()
-
setFillMode
public Path setFillMode(PathFillMode fillMode)
-
isConvex
public boolean isConvex()
Returns true if the path is convex. If necessary, it will first compute the convexity.- Returns:
- true or false
-
isOval
public io.github.humbleui.types.Rect isOval()
Returns oval bounds if this path is recognized as an oval or circle.- Returns:
- bounds is recognized as an oval or circle, null otherwise
- See Also:
- https://fiddle.skia.org/c/@Path_isOval
-
isRRect
public io.github.humbleui.types.RRect isRRect()
ReturnsRRectif this path is recognized as an oval, circle or RRect.- Returns:
- bounds is recognized as an oval, circle or RRect, null otherwise
- See Also:
- https://fiddle.skia.org/c/@Path_isRRect
-
reset
public Path reset()
Sets Path to its initial state.
Removes verb array, Point array, and weights, and sets FillMode to
PathFillMode.WINDING. Internal storage associated with Path is released.- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Path_reset
-
rewind
public Path rewind()
Sets Path to its initial state, preserving internal storage. Removes verb array, Point array, and weights, and sets FillMode to kWinding. Internal storage associated with Path is retained.
Use
rewind()instead ofreset()if Path storage will be reused and performance is critical.- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Path_rewind
-
isEmpty
public boolean isEmpty()
Returns if Path is empty.
Empty Path may have FillMode but has no
Point,PathVerb, or conic weight.Path()constructs empty Path;reset()andrewind()make Path empty.- Returns:
- true if the path contains no Verb array
-
isLastContourClosed
public boolean isLastContourClosed()
Returns if contour is closed.
Contour is closed if Path Verb array was last modified by
closePath(). When stroked, closed contour drawsPaintStrokeJoininstead ofPaintStrokeCapat first and last Point.- Returns:
- true if the last contour ends with a
PathVerb.CLOSE - See Also:
- https://fiddle.skia.org/c/@Path_isLastContourClosed
-
isFinite
public boolean isFinite()
Returns true for finite Point array values between negative Float.MIN_VALUE and positive Float.MAX_VALUE. Returns false for any Point array value of Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, or Float.NaN.- Returns:
- true if all Point values are finite
-
isVolatile
public boolean isVolatile()
Returns true if the path is volatile; it will not be altered or discarded by the caller after it is drawn. Path by default have volatile set false, allowingSurfaceto attach a cache of data which speeds repeated drawing. If true,Surfacemay not speed repeated drawing.- Returns:
- true if caller will alter Path after drawing
-
setVolatile
public Path setVolatile(boolean isVolatile)
Specifies whether Path is volatile; whether it will be altered or discarded by the caller after it is drawn. Path by default have volatile set false, allowing SkBaseDevice to attach a cache of data which speeds repeated drawing.
Mark temporary paths, discarded or modified after use, as volatile to inform SkBaseDevice that the path need not be cached.
Mark animating Path volatile to improve performance. Mark unchanging Path non-volatile to improve repeated rendering.
raster surface Path draws are affected by volatile for some shadows. GPU surface Path draws are affected by volatile for some shadows and concave geometries.
- Parameters:
isVolatile- true if caller will alter Path after drawing- Returns:
- this
-
isLineDegenerate
public static boolean isLineDegenerate(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, boolean exact)Tests if line between Point pair is degenerate.
Line with no length or that moves a very short distance is degenerate; it is treated as a point.
exact changes the equality test. If true, returns true only if p1 equals p2. If false, returns true if p1 equals or nearly equals p2.
- Parameters:
p1- line start pointp2- line end pointexact- if false, allow nearly equals- Returns:
- true if line is degenerate; its length is effectively zero
- See Also:
- https://fiddle.skia.org/c/@Path_IsLineDegenerate
-
isQuadDegenerate
public static boolean isQuadDegenerate(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, io.github.humbleui.types.Point p3, boolean exact)Tests if quad is degenerate.
Quad with no length or that moves a very short distance is degenerate; it is treated as a point.
- Parameters:
p1- quad start pointp2- quad control pointp3- quad end pointexact- if true, returns true only if p1, p2, and p3 are equal; if false, returns true if p1, p2, and p3 are equal or nearly equal- Returns:
- true if quad is degenerate; its length is effectively zero
-
isCubicDegenerate
public static boolean isCubicDegenerate(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, io.github.humbleui.types.Point p3, io.github.humbleui.types.Point p4, boolean exact)Tests if cubic is degenerate.
Cubic with no length or that moves a very short distance is degenerate; it is treated as a point.
- Parameters:
p1- cubic start pointp2- cubic control point 1p3- cubic control point 2p4- cubic end pointexact- if true, returns true only if p1, p2, p3, and p4 are equal; if false, returns true if p1, p2, p3, and p4 are equal or nearly equal- Returns:
- true if cubic is degenerate; its length is effectively zero
-
getAsLine
public io.github.humbleui.types.Point[] getAsLine()
Returns array of two points if Path contains only one line; Verb array has two entries:PathVerb.MOVE,PathVerb.LINE. Returns null if Path is not one line.- Returns:
- Point[2] if Path contains exactly one line, null otherwise
- See Also:
- https://fiddle.skia.org/c/@Path_isLine
-
getPointsCount
public int getPointsCount()
Returns the number of points in Path. Point count is initially zero.- Returns:
- Path Point array length
- See Also:
- https://fiddle.skia.org/c/@Path_countPoints
-
getPoint
public io.github.humbleui.types.Point getPoint(int index)
Returns Point at index in Point array. Valid range for index is 0 to countPoints() - 1.
Returns (0, 0) if index is out of range.
- Parameters:
index- Point array element selector- Returns:
- Point array value or (0, 0)
- See Also:
- https://fiddle.skia.org/c/@Path_getPoint
-
getPoints
public io.github.humbleui.types.Point[] getPoints()
Returns all points in Path.
- Returns:
- Path Point array length
- See Also:
- https://fiddle.skia.org/c/@Path_getPoints
-
getPoints
public int getPoints(io.github.humbleui.types.Point[] points, int max)Returns number of points in Path. Up to max points are copied.
points may be null; then, max must be zero. If max is greater than number of points, excess points storage is unaltered.
- Parameters:
points- storage for Path Point array. May be nullmax- maximum to copy; must be greater than or equal to zero- Returns:
- Path Point array length
- See Also:
- https://fiddle.skia.org/c/@Path_getPoints
-
getVerbsCount
public int getVerbsCount()
Returns the number of verbs:PathVerb.MOVE,PathVerb.LINE,PathVerb.QUAD,PathVerb.CONIC,PathVerb.CUBIC, andPathVerb.CLOSE; added to Path.- Returns:
- length of verb array
- See Also:
- https://fiddle.skia.org/c/@Path_countVerbs
-
getVerbs
public PathVerb[] getVerbs()
-
getVerbs
public int getVerbs(PathVerb[] verbs, int max)
Returns the number of verbs in the path. Up to max verbs are copied.- Parameters:
verbs- storage for verbs, may be nullmax- maximum number to copy into verbs- Returns:
- the actual number of verbs in the path
- See Also:
- https://fiddle.skia.org/c/@Path_getVerbs
-
getApproximateBytesUsed
public long getApproximateBytesUsed()
Returns the approximate byte size of the Path in memory.- Returns:
- approximate size
-
swap
public Path swap(Path other)
Exchanges the verb array, Point array, weights, and FillMode with other. Cached state is also exchanged. swap() internally exchanges pointers, so it is lightweight and does not allocate memory.
- Parameters:
other- Path exchanged by value- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Path_swap
-
getBounds
public io.github.humbleui.types.Rect getBounds()
Returns minimum and maximum axes values of Point array.
Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may be larger or smaller than area affected when Path is drawn.
Rect returned includes all Point added to Path, including Point associated with
PathVerb.MOVEthat define empty contours.- Returns:
- bounds of all Point in Point array
-
updateBoundsCache
public Path updateBoundsCache()
Updates internal bounds so that subsequent calls to
getBounds()are instantaneous. Unaltered copies of Path may also access cached bounds throughgetBounds().For now, identical to calling
getBounds()and ignoring the returned value.Call to prepare Path subsequently drawn from multiple threads, to avoid a race condition where each draw separately computes the bounds.
- Returns:
- this
-
computeTightBounds
public io.github.humbleui.types.Rect computeTightBounds()
Returns minimum and maximum axes values of the lines and curves in Path. Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may be larger or smaller than area affected when Path is drawn.
Includes Point associated with
Behaves identically toPathVerb.MOVEthat define empty contours.getBounds()when Path contains only lines. If Path contains curves, computed bounds includes the maximum extent of the quad, conic, or cubic; is slower thangetBounds(); and unlikegetBounds(), does not cache the result.- Returns:
- tight bounds of curves in Path
- See Also:
- https://fiddle.skia.org/c/@Path_computeTightBounds
-
conservativelyContainsRect
public boolean conservativelyContainsRect(io.github.humbleui.types.Rect rect)
Returns true if rect is contained by Path. May return false when rect is contained by Path.
For now, only returns true if Path has one contour and is convex. rect may share points and edges with Path and be contained. Returns true if rect is empty, that is, it has zero width or height; and the Point or line described by rect is contained by Path.
- Parameters:
rect- Rect, line, or Point checked for containment- Returns:
- true if rect is contained
- See Also:
- https://fiddle.skia.org/c/@Path_conservativelyContainsRect
-
incReserve
public Path incReserve(int extraPtCount)
Grows Path verb array and Point array to contain extraPtCount additional Point. May improve performance and use less memory by reducing the number and size of allocations when creating Path.
- Parameters:
extraPtCount- number of additional Point to allocate- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Path_incReserve
-
moveTo
public Path moveTo(float x, float y)
Adds beginning of contour at Point (x, y).- Parameters:
x- x-axis value of contour starty- y-axis value of contour start- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_moveTo
-
moveTo
public Path moveTo(io.github.humbleui.types.Point p)
Adds beginning of contour at Point p.- Parameters:
p- contour start- Returns:
- this
-
rMoveTo
public Path rMoveTo(float dx, float dy)
Adds beginning of contour relative to last point.
If Path is empty, starts contour at (dx, dy). Otherwise, start contour at last point offset by (dx, dy). Function name stands for "relative move to".
- Parameters:
dx- offset from last point to contour start on x-axisdy- offset from last point to contour start on y-axis- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_rMoveTo
-
lineTo
public Path lineTo(float x, float y)
Adds line from last point to (x, y). If Path is empty, or last Verb is
PathVerb.CLOSE, last point is set to (0, 0) before adding line.lineTo() appends
PathVerb.MOVEto verb array and (0, 0) to Point array, if needed. lineTo() then appendsPathVerb.LINEto verb array and (x, y) to Point array.- Parameters:
x- end of added line on x-axisy- end of added line on y-axis- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Path_lineTo
-
lineTo
public Path lineTo(io.github.humbleui.types.Point p)
Adds line from last point to Point p. If Path is empty, or last
PathVerbisPathVerb.CLOSE, last point is set to (0, 0) before adding line.lineTo() first appends
PathVerb.MOVEto verb array and (0, 0) to Point array, if needed. lineTo() then appendsPathVerb.LINEto verb array and Point p to Point array.- Parameters:
p- end Point of added line- Returns:
- reference to Path
-
rLineTo
public Path rLineTo(float dx, float dy)
Adds line from last point to vector (dx, dy). If Path is empty, or last
PathVerbisPathVerb.CLOSE, last point is set to (0, 0) before adding line.Appends
PathVerb.MOVEto verb array and (0, 0) to Point array, if needed; then appendsPathVerb.LINEto verb array and line end to Point array.Line end is last point plus vector (dx, dy).
Function name stands for "relative line to".
- Parameters:
dx- offset from last point to line end on x-axisdy- offset from last point to line end on y-axis- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_rLineTo, https://fiddle.skia.org/c/@Quad_a, https://fiddle.skia.org/c/@Quad_b
-
quadTo
public Path quadTo(float x1, float y1, float x2, float y2)
Adds quad from last point towards (x1, y1), to (x2, y2). If Path is empty, or lastPathVerbisPathVerb.CLOSE, last point is set to (0, 0) before adding quad. AppendsPathVerb.MOVEto verb array and (0, 0) to Point array, if needed; then appendsPathVerb.QUADto verb array; and (x1, y1), (x2, y2) to Point array.- Parameters:
x1- control Point of quad on x-axisy1- control Point of quad on y-axisx2- end Point of quad on x-axisy2- end Point of quad on y-axis- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_quadTo
-
quadTo
public Path quadTo(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2)
Adds quad from last point towards Point p1, to Point p2.
If Path is empty, or last
PathVerbisPathVerb.CLOSE, last point is set to (0, 0) before adding quad.Appends
PathVerb.MOVEto verb array and (0, 0) to Point array, if needed; then appendsPathVerb.QUADto verb array; and Point p1, p2 to Point array.- Parameters:
p1- control Point of added quadp2- end Point of added quad- Returns:
- reference to Path
-
rQuadTo
public Path rQuadTo(float dx1, float dy1, float dx2, float dy2)
Adds quad from last point towards vector (dx1, dy1), to vector (dx2, dy2). If Path is empty, or last
PathVerbisPathVerb.CLOSE, last point is set to (0, 0) before adding quad.Appends
PathVerb.MOVEto verb array and (0, 0) to Point array, if needed; then appendsPathVerb.QUADto verb array; and appends quad control and quad end to Point array.Quad control is last point plus vector (dx1, dy1).
Quad end is last point plus vector (dx2, dy2).
Function name stands for "relative quad to".
- Parameters:
dx1- offset from last point to quad control on x-axisdy1- offset from last point to quad control on y-axisdx2- offset from last point to quad end on x-axisdy2- offset from last point to quad end on y-axis- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Conic_Weight_a, https://fiddle.skia.org/c/@Conic_Weight_b, https://fiddle.skia.org/c/@Conic_Weight_c, https://fiddle.skia.org/c/@Path_rQuadTo
-
conicTo
public Path conicTo(float x1, float y1, float x2, float y2, float w)
Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.
If Path is empty, or last
PathVerbisPathVerb.CLOSE, last point is set to (0, 0) before adding conic.Appends
PathVerb.MOVEto verb array and (0, 0) to Point array, if needed.If w is finite and not one, appends
PathVerb.CONICto verb array; and (x1, y1), (x2, y2) to Point array; and w to conic weights.If w is one, appends
PathVerb.QUADto verb array, and (x1, y1), (x2, y2) to Point array.If w is not finite, appends
PathVerb.LINEtwice to verb array, and (x1, y1), (x2, y2) to Point array.- Parameters:
x1- control Point of conic on x-axisy1- control Point of conic on y-axisx2- end Point of conic on x-axisy2- end Point of conic on y-axisw- weight of added conic- Returns:
- reference to Path
-
conicTo
public Path conicTo(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, float w)
Adds conic from last point towards Point p1, to Point p2, weighted by w.
If Path is empty, or last
PathVerbisPathVerb.CLOSE, last point is set to (0, 0) before adding conic.Appends
PathVerb.MOVEto verb array and (0, 0) to Point array, if needed.If w is finite and not one, appends
PathVerb.CONICto verb array; and Point p1, p2 to Point array; and w to conic weights.If w is one, appends
PathVerb.QUADto verb array, and Point p1, p2 to Point array.If w is not finite, appends
PathVerb.LINEtwice to verb array, and Point p1, p2 to Point array.- Parameters:
p1- control Point of added conicp2- end Point of added conicw- weight of added conic- Returns:
- reference to Path
-
rConicTo
public Path rConicTo(float dx1, float dy1, float dx2, float dy2, float w)
Adds conic from last point towards vector (dx1, dy1), to vector (dx2, dy2), weighted by w. If Path is empty, or last
PathVerbisPathVerb.CLOSE, last point is set to (0, 0) before adding conic.Appends
PathVerb.MOVEto verb array and (0, 0) to Point array, if needed.If w is finite and not one, next appends
PathVerb.CONICto verb array, and w is recorded as conic weight; otherwise, if w is one, appendsPathVerb.QUADto verb array; or if w is not finite, appendsPathVerb.LINEtwice to verb array.In all cases appends Point control and end to Point array. control is last point plus vector (dx1, dy1). end is last point plus vector (dx2, dy2).
Function name stands for "relative conic to".
- Parameters:
dx1- offset from last point to conic control on x-axisdy1- offset from last point to conic control on y-axisdx2- offset from last point to conic end on x-axisdy2- offset from last point to conic end on y-axisw- weight of added conic- Returns:
- reference to Path
-
cubicTo
public Path cubicTo(float x1, float y1, float x2, float y2, float x3, float y3)
Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at (x3, y3). If Path is empty, or last
PathVerbisPathVerb.CLOSE, last point is set to (0, 0) before adding cubic.Appends
PathVerb.MOVEto verb array and (0, 0) to Point array, if needed; then appendsPathVerb.CUBICto verb array; and (x1, y1), (x2, y2), (x3, y3) to Point array.- Parameters:
x1- first control Point of cubic on x-axisy1- first control Point of cubic on y-axisx2- second control Point of cubic on x-axisy2- second control Point of cubic on y-axisx3- end Point of cubic on x-axisy3- end Point of cubic on y-axis- Returns:
- reference to Path
-
cubicTo
public Path cubicTo(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, io.github.humbleui.types.Point p3)
Adds cubic from last point towards Point p1, then towards Point p2, ending at Point p3. If Path is empty, or last
PathVerbisPathVerb.CLOSE, last point is set to (0, 0) before adding cubic.Appends
PathVerb.MOVEto verb array and (0, 0) to Point array, if needed; then appendsPathVerb.CUBICto verb array; and Point p1, p2, p3 to Point array.- Parameters:
p1- first control Point of cubicp2- second control Point of cubicp3- end Point of cubic- Returns:
- reference to Path
-
rCubicTo
public Path rCubicTo(float dx1, float dy1, float dx2, float dy2, float dx3, float dy3)
Adds cubic from last point towards vector (dx1, dy1), then towards vector (dx2, dy2), to vector (dx3, dy3). If Path is empty, or last
PathVerbisPathVerb.CLOSE, last point is set to (0, 0) before adding cubic.Appends
PathVerb.MOVEto verb array and (0, 0) to Point array, if needed; then appendsPathVerb.CUBICto verb array; and appends cubic control and cubic end to Point array.Cubic control is last point plus vector (dx1, dy1).
Cubic end is last point plus vector (dx2, dy2).
Function name stands for "relative cubic to".
- Parameters:
dx1- offset from last point to first cubic control on x-axisdy1- offset from last point to first cubic control on y-axisdx2- offset from last point to second cubic control on x-axisdy2- offset from last point to second cubic control on y-axisdx3- offset from last point to cubic end on x-axisdy3- offset from last point to cubic end on y-axis- Returns:
- reference to Path
-
arcTo
public Path arcTo(io.github.humbleui.types.Rect oval, float startAngle, float sweepAngle, boolean forceMoveTo)
Appends arc to Path. Arc added is part of ellipse bounded by oval, from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees is aligned with the positive x-axis, and positive sweeps extends arc clockwise.
arcTo() adds line connecting Path last Point to initial arc Point if forceMoveTo is false and Path is not empty. Otherwise, added contour begins with first point of arc. Angles greater than -360 and less than 360 are treated modulo 360.
- Parameters:
oval- bounds of ellipse containing arcstartAngle- starting angle of arc in degreessweepAngle- sweep, in degrees. Positive is clockwise; treated modulo 360forceMoveTo- true to start a new contour with arc- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_arcTo
-
tangentArcTo
public Path tangentArcTo(float x1, float y1, float x2, float y2, float radius)
Appends arc to Path, after appending line if needed. Arc is implemented by conic weighted to describe part of circle. Arc is contained by tangent from last Path point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc is part of circle sized to radius, positioned so it touches both tangent lines.
If last Path Point does not start Arc, tangentArcTo appends connecting Line to Path. The length of Vector from (x1, y1) to (x2, y2) does not affect Arc.
Arc sweep is always less than 180 degrees. If radius is zero, or if tangents are nearly parallel, tangentArcTo appends Line from last Path Point to (x1, y1).
tangentArcTo appends at most one Line and one conic.
tangentArcTo implements the functionality of PostScript arct and HTML Canvas tangentArcTo.
- Parameters:
x1- x-axis value common to pair of tangentsy1- y-axis value common to pair of tangentsx2- x-axis value end of second tangenty2- y-axis value end of second tangentradius- distance from arc to circle center- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_arcTo_2_a, https://fiddle.skia.org/c/@Path_arcTo_2_b, https://fiddle.skia.org/c/@Path_arcTo_2_c
-
tangentArcTo
public Path tangentArcTo(io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, float radius)
Appends arc to Path, after appending line if needed. Arc is implemented by conic weighted to describe part of circle. Arc is contained by tangent from last Path point to p1, and tangent from p1 to p2. Arc is part of circle sized to radius, positioned so it touches both tangent lines.
If last Path Point does not start arc, tangentArcTo() appends connecting line to Path. The length of vector from p1 to p2 does not affect arc.
Arc sweep is always less than 180 degrees. If radius is zero, or if tangents are nearly parallel, tangentArcTo() appends line from last Path Point to p1.
tangentArcTo() appends at most one line and one conic.
tangentArcTo() implements the functionality of PostScript arct and HTML Canvas tangentArcTo.
- Parameters:
p1- Point common to pair of tangentsp2- end of second tangentradius- distance from arc to circle center- Returns:
- reference to Path
-
ellipticalArcTo
public Path ellipticalArcTo(float rx, float ry, float xAxisRotate, PathEllipseArc arc, PathDirection direction, float x, float y)
Appends arc to Path. Arc is implemented by one or more conics weighted to describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc curves from last Path Point to (x, y), choosing one of four possible routes: clockwise or counterclockwise, and smaller or larger.
Arc sweep is always less than 360 degrees. ellipticalArcTo() appends line to (x, y) if either radii are zero, or if last Path Point equals (x, y). ellipticalArcTo() scales radii (rx, ry) to fit last Path Point and (x, y) if both are greater than zero but too small.
ellipticalArcTo() appends up to four conic curves.
ellipticalArcTo() implements the functionality of SVG arc, although SVG sweep-flag value is opposite the integer value of sweep; SVG sweep-flag uses 1 for clockwise, while
PathDirection.CLOCKWISEcast to int is zero.- Parameters:
rx- radius on x-axis before x-axis rotationry- radius on y-axis before x-axis rotationxAxisRotate- x-axis rotation in degrees; positive values are clockwisearc- chooses smaller or larger arcdirection- chooses clockwise or counterclockwise arcx- end of arcy- end of arc- Returns:
- reference to Path
-
ellipticalArcTo
public Path ellipticalArcTo(io.github.humbleui.types.Point r, float xAxisRotate, PathEllipseArc arc, PathDirection direction, io.github.humbleui.types.Point xy)
Appends arc to Path. Arc is implemented by one or more conic weighted to describe part of oval with radii (r.fX, r.fY) rotated by xAxisRotate degrees. Arc curves from last Path Point to (xy.fX, xy.fY), choosing one of four possible routes: clockwise or counterclockwise, and smaller or larger.
Arc sweep is always less than 360 degrees. ellipticalArcTo() appends line to xy if either radii are zero, or if last Path Point equals (xy.fX, xy.fY). ellipticalArcTo() scales radii r to fit last Path Point and xy if both are greater than zero but too small to describe an arc.
ellipticalArcTo() appends up to four conic curves.
ellipticalArcTo() implements the functionality of SVG arc, although SVG sweep-flag value is opposite the integer value of sweep; SVG sweep-flag uses 1 for clockwise, while
PathDirection.CLOCKWISEcast to int is zero.- Parameters:
r- radii on axes before x-axis rotationxAxisRotate- x-axis rotation in degrees; positive values are clockwisearc- chooses smaller or larger arcdirection- chooses clockwise or counterclockwise arcxy- end of arc- Returns:
- reference to Path
-
rEllipticalArcTo
public Path rEllipticalArcTo(float rx, float ry, float xAxisRotate, PathEllipseArc arc, PathDirection direction, float dx, float dy)
Appends arc to Path, relative to last Path Point. Arc is implemented by one or more conic, weighted to describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc curves from last Path Point to relative end Point: (dx, dy), choosing one of four possible routes: clockwise or counterclockwise, and smaller or larger. If Path is empty, the start arc Point is (0, 0).
Arc sweep is always less than 360 degrees. rEllipticalArcTo() appends line to end Point if either radii are zero, or if last Path Point equals end Point. rEllipticalArcTo() scales radii (rx, ry) to fit last Path Point and end Point if both are greater than zero but too small to describe an arc.
rEllipticalArcTo() appends up to four conic curves.
rEllipticalArcTo() implements the functionality of svg arc, although SVG "sweep-flag" value is opposite the integer value of sweep; SVG "sweep-flag" uses 1 for clockwise, while
PathDirection.CLOCKWISEcast to int is zero.- Parameters:
rx- radius before x-axis rotationry- radius before x-axis rotationxAxisRotate- x-axis rotation in degrees; positive values are clockwisearc- chooses smaller or larger arcdirection- chooses clockwise or counterclockwise arcdx- x-axis offset end of arc from last Path Pointdy- y-axis offset end of arc from last Path Point- Returns:
- reference to Path
-
closePath
public Path closePath()
Appends
PathVerb.CLOSEto Path. A closed contour connects the first and last Point with line, forming a continuous loop. Open and closed contour draw the same withPaintMode.FILL. WithPaintMode.STROKE, open contour drawsPaintStrokeCapat contour start and end; closed contour drawsPaintStrokeJoinat contour start and end.closePath() has no effect if Path is empty or last Path
PathVerbisPathVerb.CLOSE.- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_close
-
convertConicToQuads
public static io.github.humbleui.types.Point[] convertConicToQuads(io.github.humbleui.types.Point p0, io.github.humbleui.types.Point p1, io.github.humbleui.types.Point p2, float w, int pow2)Approximates conic with quad array. Conic is constructed from start Point p0, control Point p1, end Point p2, and weight w.
Quad array is stored in pts; this storage is supplied by caller.
Maximum quad count is 2 to the pow2.
Every third point in array shares last Point of previous quad and first Point of next quad. Maximum pts storage size is given by:
(1 + 2 * (1 << pow2)).</p>Returns quad count used the approximation, which may be smaller than the number requested.
conic weight determines the amount of influence conic control point has on the curve.
w less than one represents an elliptical section. w greater than one represents a hyperbolic section. w equal to one represents a parabolic section.
Two quad curves are sufficient to approximate an elliptical conic with a sweep of up to 90 degrees; in this case, set pow2 to one.
- Parameters:
p0- conic start Pointp1- conic control Pointp2- conic end Pointw- conic weightpow2- quad count, as power of two, normally 0 to 5 (1 to 32 quad curves)- Returns:
- number of quad curves written to pts
-
isRect
public io.github.humbleui.types.Rect isRect()
Returns Rect if Path is equivalent to Rect when filled.
rect may be smaller than the Path bounds. Path bounds may includePathVerb.MOVEpoints that do not alter the area drawn by the returned rect.- Returns:
- bounds if Path contains Rect, null otherwise
- See Also:
- https://fiddle.skia.org/c/@Path_isRect
-
addRect
public Path addRect(io.github.humbleui.types.Rect rect)
Adds Rect to Path, appendingPathVerb.MOVE, threePathVerb.LINE, andPathVerb.CLOSE, starting with top-left corner of Rect; followed by top-right, bottom-right, and bottom-left.- Parameters:
rect- Rect to add as a closed contour- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_addRect
-
addRect
public Path addRect(io.github.humbleui.types.Rect rect, PathDirection dir)
Adds Rect to Path, appendingPathVerb.MOVE, threePathVerb.LINE, andPathVerb.CLOSE, starting with top-left corner of Rect; followed by top-right, bottom-right, and bottom-left if dir isPathDirection.CLOCKWISE; or followed by bottom-left, bottom-right, and top-right if dir isPathDirection.COUNTER_CLOCKWISE.- Parameters:
rect- Rect to add as a closed contourdir- Direction to wind added contour- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_addRect
-
addRect
public Path addRect(io.github.humbleui.types.Rect rect, PathDirection dir, int start)
Adds Rect to Path, appendingPathVerb.MOVE, threePathVerb.LINE, andPathVerb.CLOSE. If dir isPathDirection.CLOCKWISE, Rect corners are added clockwise; if dir isPathDirection.COUNTER_CLOCKWISE, Rect corners are added counterclockwise. start determines the first corner added.- Parameters:
rect- Rect to add as a closed contourdir- Direction to wind added contourstart- initial corner of Rect to add. 0 for top left, 1 for top right, 2 for lower right, 3 for lower left- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_addRect_2
-
addOval
public Path addOval(io.github.humbleui.types.Rect oval)
Adds oval to path, appending
PathVerb.MOVE, fourPathVerb.CONIC, andPathVerb.CLOSE.Oval is upright ellipse bounded by Rect oval with radii equal to half oval width and half oval height. Oval begins at (oval.fRight, oval.centerY()) and continues clockwise.
- Parameters:
oval- bounds of ellipse added- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_addOval
-
addOval
public Path addOval(io.github.humbleui.types.Rect oval, PathDirection dir)
Adds oval to path, appending
PathVerb.MOVE, fourPathVerb.CONIC, andPathVerb.CLOSE.Oval is upright ellipse bounded by Rect oval with radii equal to half oval width and half oval height. Oval begins at (oval.fRight, oval.centerY()) and continues clockwise if dir is
PathDirection.CLOCKWISE, counterclockwise if dir isPathDirection.COUNTER_CLOCKWISE.- Parameters:
oval- bounds of ellipse addeddir- Direction to wind ellipse- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_addOval
-
addOval
public Path addOval(io.github.humbleui.types.Rect oval, PathDirection dir, int start)
Adds oval to Path, appendingPathVerb.MOVE, fourPathVerb.CONIC, andPathVerb.CLOSE. Oval is upright ellipse bounded by Rect oval with radii equal to half oval width and half oval height. Oval begins at start and continues clockwise if dir isPathDirection.CLOCKWISE, counterclockwise if dir isPathDirection.COUNTER_CLOCKWISE.- Parameters:
oval- bounds of ellipse addeddir- Direction to wind ellipsestart- index of initial point of ellipse. 0 for top, 1 for right, 2 for bottom, 3 for left- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_addOval_2
-
addCircle
public Path addCircle(float x, float y, float radius)
Adds circle centered at (x, y) of size radius to Path, appending
PathVerb.MOVE, fourPathVerb.CONIC, andPathVerb.CLOSE. Circle begins at: (x + radius, y)Has no effect if radius is zero or negative.
- Parameters:
x- center of circley- center of circleradius- distance from center to edge- Returns:
- reference to Path
-
addCircle
public Path addCircle(float x, float y, float radius, PathDirection dir)
Adds circle centered at (x, y) of size radius to Path, appending
PathVerb.MOVE, fourPathVerb.CONIC, andPathVerb.CLOSE. Circle begins at: (x + radius, y), continuing clockwise if dir isPathDirection.CLOCKWISE, and counterclockwise if dir isPathDirection.COUNTER_CLOCKWISE.Has no effect if radius is zero or negative.
- Parameters:
x- center of circley- center of circleradius- distance from center to edgedir- Direction to wind circle- Returns:
- reference to Path
-
addArc
public Path addArc(io.github.humbleui.types.Rect oval, float startAngle, float sweepAngle)
Appends arc to Path, as the start of new contour. Arc added is part of ellipse bounded by oval, from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees is aligned with the positive x-axis, and positive sweeps extends arc clockwise.
If sweepAngle ≤ -360, or sweepAngle ≥ 360; and startAngle modulo 90 is nearly zero, append oval instead of arc. Otherwise, sweepAngle values are treated modulo 360, and arc may or may not draw depending on numeric rounding.
- Parameters:
oval- bounds of ellipse containing arcstartAngle- starting angle of arc in degreessweepAngle- sweep, in degrees. Positive is clockwise; treated modulo 360- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_addArc
-
addRRect
public Path addRRect(io.github.humbleui.types.RRect rrect)
Adds rrect to Path, creating a new closed contour. RRect starts at top-left of the lower-left corner and winds clockwise.
After appending, Path may be empty, or may contain: Rect, Oval, or RRect.
- Parameters:
rrect- bounds and radii of rounded rectangle- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_addRRect
-
addRRect
public Path addRRect(io.github.humbleui.types.RRect rrect, PathDirection dir)
Adds rrect to Path, creating a new closed contour. If dir is
PathDirection.CLOCKWISE, rrect starts at top-left of the lower-left corner and winds clockwise. If dir isPathDirection.COUNTER_CLOCKWISE, rrect starts at the bottom-left of the upper-left corner and winds counterclockwise.After appending, Path may be empty, or may contain: Rect, Oval, or RRect.
- Parameters:
rrect- bounds and radii of rounded rectangledir- Direction to wind RRect- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_addRRect
-
addRRect
public Path addRRect(io.github.humbleui.types.RRect rrect, PathDirection dir, int start)
Adds rrect to Path, creating a new closed contour. If dir is
PathDirection.CLOCKWISE, rrect winds clockwise; if dir isPathDirection.COUNTER_CLOCKWISE, rrect winds counterclockwise. start determines the first point of rrect to add.- Parameters:
rrect- bounds and radii of rounded rectangledir- Direction to wind RRectstart- index of initial point of RRect. 0 for top-right end of the arc at top left, 1 for top-left end of the arc at top right, 2 for bottom-right end of top right arc, etc.- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_addRRect_2
-
addPoly
public Path addPoly(io.github.humbleui.types.Point[] pts, boolean close)
Adds contour created from line array, adding (pts.length - 1) line segments. Contour added starts at pts[0], then adds a line for every additional Point in pts array. If close is true, appends
PathVerb.CLOSEto Path, connecting pts[pts.length - 1] and pts[0].If pts is empty, append
PathVerb.MOVEto path.- Parameters:
pts- array of line sharing end and start Pointclose- true to add line connecting contour end and start- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_addPoly
-
addPoly
public Path addPoly(float[] pts, boolean close)
Adds contour created from line array, adding (pts.length / 2 - 1) line segments. Contour added starts at (pts[0], pts[1]), then adds a line for every additional pair of floats in pts array. If close is true, appends
PathVerb.CLOSEto Path, connecting (pts[count - 2], pts[count - 1]) and (pts[0], pts[1]).If pts is empty, append
PathVerb.MOVEto path.- Parameters:
pts- flat array of line sharing end and start Pointclose- true to add line connecting contour end and start- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_addPoly
-
addPath
public Path addPath(Path src)
Appends src to Path.
src verb array, Point array, and conic weights are added unaltered.
- Parameters:
src- Path verbs, Point, and conic weights to add- Returns:
- reference to Path
-
addPath
public Path addPath(Path src, boolean extend)
Appends src to Path.
If extend is false, src verb array, Point array, and conic weights are added unaltered. If extend is true, add line before appending verbs, Point, and conic weights.
- Parameters:
src- Path verbs, Point, and conic weights to addextend- if should add a line before appending verbs- Returns:
- reference to Path
-
addPath
public Path addPath(Path src, float dx, float dy)
Appends src to Path, offset by (dx, dy).
Src verb array, Point array, and conic weights are added unaltered.
- Parameters:
src- Path verbs, Point, and conic weights to adddx- offset added to src Point array x-axis coordinatesdy- offset added to src Point array y-axis coordinates- Returns:
- reference to Path
-
addPath
public Path addPath(Path src, float dx, float dy, boolean extend)
Appends src to Path, offset by (dx, dy).
If extend is false, src verb array, Point array, and conic weights are added unaltered. If extend is true, add line before appending verbs, Point, and conic weights.
- Parameters:
src- Path verbs, Point, and conic weights to adddx- offset added to src Point array x-axis coordinatesdy- offset added to src Point array y-axis coordinatesextend- if should add a line before appending verbs- Returns:
- reference to Path
-
addPath
public Path addPath(Path src, Matrix33 matrix)
Appends src to Path, transformed by matrix. Transformed curves may have different verbs, Point, and conic weights.
Src verb array, Point array, and conic weights are added unaltered.
- Parameters:
src- Path verbs, Point, and conic weights to addmatrix- transform applied to src- Returns:
- reference to Path
-
addPath
public Path addPath(Path src, Matrix33 matrix, boolean extend)
Appends src to Path, transformed by matrix. Transformed curves may have different verbs, Point, and conic weights.
If extend is false, src verb array, Point array, and conic weights are added unaltered. If extend is true, add line before appending verbs, Point, and conic weights.
- Parameters:
src- Path verbs, Point, and conic weights to addmatrix- transform applied to srcextend- if should add a line before appending verbs- Returns:
- reference to Path
-
reverseAddPath
public Path reverseAddPath(Path src)
Appends src to Path, from back to front. Reversed src always appends a new contour to Path.- Parameters:
src- Path verbs, Point, and conic weights to add- Returns:
- reference to Path
- See Also:
- https://fiddle.skia.org/c/@Path_reverseAddPath
-
offset
public Path offset(float dx, float dy)
Offsets Point array by (dx, dy). Path is replaced by offset data.- Parameters:
dx- offset added to Point array x-axis coordinatesdy- offset added to Point array y-axis coordinates- Returns:
- this
-
offset
public Path offset(float dx, float dy, Path dst)
Offsets Point array by (dx, dy). Offset Path replaces dst. If dst is null, Path is replaced by offset data.- Parameters:
dx- offset added to Point array x-axis coordinatesdy- offset added to Point array y-axis coordinatesdst- overwritten, translated copy of Path; may be null- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Path_offset
-
transform
public Path transform(Matrix33 matrix)
Transforms verb array, Point array, and weight by matrix. transform may change verbs and increase their number. Path is replaced by transformed data.- Parameters:
matrix- matrix to apply to Path- Returns:
- this
-
transform
public Path transform(Matrix33 matrix, boolean applyPerspectiveClip)
Transforms verb array, Point array, and weight by matrix. transform may change verbs and increase their number. Path is replaced by transformed data.- Parameters:
matrix- matrix to apply to PathapplyPerspectiveClip- whether to apply perspective clipping- Returns:
- this
-
transform
public Path transform(Matrix33 matrix, Path dst)
Transforms verb array, Point array, and weight by matrix. transform may change verbs and increase their number. Transformed Path replaces dst; if dst is null, original data is replaced.- Parameters:
matrix- matrix to apply to Pathdst- overwritten, transformed copy of Path; may be null- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Path_transform
-
transform
public Path transform(Matrix33 matrix, Path dst, boolean applyPerspectiveClip)
Transforms verb array, Point array, and weight by matrix. transform may change verbs and increase their number. Transformed Path replaces dst; if dst is null, original data is replaced.- Parameters:
matrix- matrix to apply to Pathdst- overwritten, transformed copy of Path; may be nullapplyPerspectiveClip- whether to apply perspective clipping- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Path_transform
-
getLastPt
public io.github.humbleui.types.Point getLastPt()
Returns last point on Path in lastPt. Returns null if Point array is empty.- Returns:
- point if Point array contains one or more Point, null otherwise
- See Also:
- https://fiddle.skia.org/c/@Path_getLastPt
-
setLastPt
public Path setLastPt(float x, float y)
Sets last point to (x, y). If Point array is empty, appendPathVerb.MOVEto verb array and append (x, y) to Point array.- Parameters:
x- set x-axis value of last pointy- set y-axis value of last point- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Path_setLastPt
-
setLastPt
public Path setLastPt(io.github.humbleui.types.Point p)
Sets the last point on the path. If Point array is empty, appendPathVerb.MOVEto verb array and append p to Point array.- Parameters:
p- set value of last point- Returns:
- this
-
getSegmentMasks
public int getSegmentMasks()
Returns a mask, where each set bit corresponds to a SegmentMask constant if Path contains one or more verbs of that type.
Returns zero if Path contains no lines, or curves: quads, conics, or cubics.
getSegmentMasks() returns a cached result; it is very fast.
- Returns:
- SegmentMask bits or zero
- See Also:
PathSegmentMask.LINE,PathSegmentMask.QUAD,PathSegmentMask.CONIC,PathSegmentMask.CUBIC
-
iterator
public PathSegmentIterator iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<PathSegment>
-
iterator
public PathSegmentIterator iterator(boolean forceClose)
-
contains
public boolean contains(float x, float y)Returns true if the point (x, y) is contained by Path, taking into accountPathFillMode.- Parameters:
x- x-axis value of containment testy- y-axis value of containment test- Returns:
- true if Point is in Path
- See Also:
- https://fiddle.skia.org/c/@Path_contains
-
contains
public boolean contains(io.github.humbleui.types.Point p)
Returns true if the point is contained by Path, taking into accountPathFillMode.- Parameters:
p- point of containment test- Returns:
- true if Point is in Path
- See Also:
- https://fiddle.skia.org/c/@Path_contains
-
dump
public Path dump()
Writes text representation of Path to standard output. The representation may be directly compiled as C++ code. Floating point values are written with limited precision; it may not be possible to reconstruct original Path from output.- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Path_dump_2
-
dumpHex
public Path dumpHex()
Writes text representation of Path to standard output. The representation may be directly compiled as C++ code. Floating point values are written in hexadecimal to preserve their exact bit pattern. The output reconstructs the original Path.
Use instead of
dump()when submitting- Returns:
- this
- See Also:
- https://fiddle.skia.org/c/@Path_dumpHex
-
serializeToBytes
public byte[] serializeToBytes()
Writes Path to byte buffer.
Writes
PathFillMode, verb array, Point array, conic weight, and additionally writes computed information like path convexity and bounds.Use only be used in concert with
makeFromBytes(byte[]); the format used for Path in memory is not guaranteed.- Returns:
- serialized Path; length always a multiple of 4
- See Also:
- https://fiddle.skia.org/c/@Path_writeToMemory
-
makeCombining
@Nullable public static @Nullable Path makeCombining(@NotNull @NotNull Path one, @NotNull @NotNull Path two, PathOp op)
Returns Path that is the result of applying the Op to the first path and the second path.
The resulting path will be constructed from non-overlapping contours.
The curve order is reduced where possible so that cubics may be turned into quadratics, and quadratics maybe turned into lines.
- Parameters:
one- The first operand (for difference, the minuend)two- The second operand (for difference, the subtrahend)op- The operator to apply.- Returns:
- Path if operation was able to produce a result, null otherwise
-
makeFromBytes
public static Path makeFromBytes(byte[] data)
Initializes Path from byte buffer. Returns null if the buffer is data is inconsistent, or the length is too small.
Reads
PathFillMode, verb array, Point array, conic weight, and additionally reads computed information like path convexity and bounds.Used only in concert with
serializeToBytes(); the format used for Path in memory is not guaranteed.- Parameters:
data- storage for Path- Returns:
- reconstructed Path
- See Also:
- https://fiddle.skia.org/c/@Path_readFromMemory
-
getGenerationId
public int getGenerationId()
Returns a non-zero, globally unique value. A different value is returned if verb array, Point array, or conic weight changes.
Setting
PathFillModedoes not change generation identifier.Each time the path is modified, a different generation identifier will be returned.
PathFillModedoes affect generation identifier on Android framework.- Returns:
- non-zero, globally unique value
- See Also:
- https://fiddle.skia.org/c/@Path_getGenerationID, https://bugs.chromium.org/p/skia/issues/detail?id=1762
-
isValid
public boolean isValid()
Returns if Path data is consistent. Corrupt Path data is detected if internal values are out of range or internal storage does not match array dimensions.- Returns:
- true if Path data is consistent
-
_nGetFinalizer
public static long _nGetFinalizer()
-
_nMake
public static long _nMake()
-
_nMakeFromSVGString
public static long _nMakeFromSVGString(java.lang.String s)
-
_nEquals
public static boolean _nEquals(long aPtr, long bPtr)
-
_nIsInterpolatable
public static boolean _nIsInterpolatable(long ptr, long comparePtr)
-
_nMakeLerp
public static long _nMakeLerp(long ptr, long endingPtr, float weight)
-
_nGetFillMode
public static int _nGetFillMode(long ptr)
-
_nSetFillMode
public static void _nSetFillMode(long ptr, int fillMode)
-
_nIsConvex
public static boolean _nIsConvex(long ptr)
-
_nIsOval
public static io.github.humbleui.types.Rect _nIsOval(long ptr)
-
_nIsRRect
public static io.github.humbleui.types.RRect _nIsRRect(long ptr)
-
_nReset
public static void _nReset(long ptr)
-
_nRewind
public static void _nRewind(long ptr)
-
_nIsEmpty
public static boolean _nIsEmpty(long ptr)
-
_nIsLastContourClosed
public static boolean _nIsLastContourClosed(long ptr)
-
_nIsFinite
public static boolean _nIsFinite(long ptr)
-
_nIsVolatile
public static boolean _nIsVolatile(long ptr)
-
_nSetVolatile
public static void _nSetVolatile(long ptr, boolean isVolatile)
-
_nIsLineDegenerate
public static boolean _nIsLineDegenerate(float x0, float y0, float x1, float y1, boolean exact)
-
_nIsQuadDegenerate
public static boolean _nIsQuadDegenerate(float x0, float y0, float x1, float y1, float x2, float y2, boolean exact)
-
_nIsCubicDegenerate
public static boolean _nIsCubicDegenerate(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, boolean exact)
-
_nMaybeGetAsLine
public static io.github.humbleui.types.Point[] _nMaybeGetAsLine(long ptr)
-
_nGetPointsCount
public static int _nGetPointsCount(long ptr)
-
_nGetPoint
public static io.github.humbleui.types.Point _nGetPoint(long ptr, int index)
-
_nGetPoints
public static int _nGetPoints(long ptr, io.github.humbleui.types.Point[] points, int max)
-
_nCountVerbs
public static int _nCountVerbs(long ptr)
-
_nGetVerbs
public static int _nGetVerbs(long ptr, byte[] verbs, int max)
-
_nApproximateBytesUsed
public static long _nApproximateBytesUsed(long ptr)
-
_nSwap
public static void _nSwap(long ptr, long otherPtr)
-
_nGetBounds
public static io.github.humbleui.types.Rect _nGetBounds(long ptr)
-
_nUpdateBoundsCache
public static void _nUpdateBoundsCache(long ptr)
-
_nComputeTightBounds
public static io.github.humbleui.types.Rect _nComputeTightBounds(long ptr)
-
_nConservativelyContainsRect
public static boolean _nConservativelyContainsRect(long ptr, float l, float t, float r, float b)
-
_nIncReserve
public static void _nIncReserve(long ptr, int extraPtCount)
-
_nMoveTo
public static void _nMoveTo(long ptr, float x, float y)
-
_nRMoveTo
public static void _nRMoveTo(long ptr, float dx, float dy)
-
_nLineTo
public static void _nLineTo(long ptr, float x, float y)
-
_nRLineTo
public static void _nRLineTo(long ptr, float dx, float dy)
-
_nQuadTo
public static void _nQuadTo(long ptr, float x1, float y1, float x2, float y2)
-
_nRQuadTo
public static void _nRQuadTo(long ptr, float dx1, float dy1, float dx2, float dy2)
-
_nConicTo
public static void _nConicTo(long ptr, float x1, float y1, float x2, float y2, float w)
-
_nRConicTo
public static void _nRConicTo(long ptr, float dx1, float dy1, float dx2, float dy2, float w)
-
_nCubicTo
public static void _nCubicTo(long ptr, float x1, float y1, float x2, float y2, float x3, float y3)
-
_nRCubicTo
public static void _nRCubicTo(long ptr, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3)
-
_nArcTo
public static void _nArcTo(long ptr, float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean forceMoveTo)
-
_nTangentArcTo
public static void _nTangentArcTo(long ptr, float x1, float y1, float x2, float y2, float radius)
-
_nEllipticalArcTo
public static void _nEllipticalArcTo(long ptr, float rx, float ry, float xAxisRotate, int size, int direction, float x, float y)
-
_nREllipticalArcTo
public static void _nREllipticalArcTo(long ptr, float rx, float ry, float xAxisRotate, int size, int direction, float dx, float dy)
-
_nClosePath
public static void _nClosePath(long ptr)
-
_nConvertConicToQuads
public static io.github.humbleui.types.Point[] _nConvertConicToQuads(float x0, float y0, float x1, float y1, float x2, float y2, float w, int pow2)
-
_nIsRect
public static io.github.humbleui.types.Rect _nIsRect(long ptr)
-
_nAddRect
public static void _nAddRect(long ptr, float l, float t, float r, float b, int dir, int start)
-
_nAddOval
public static void _nAddOval(long ptr, float l, float t, float r, float b, int dir, int start)
-
_nAddCircle
public static void _nAddCircle(long ptr, float x, float y, float r, int dir)
-
_nAddArc
public static void _nAddArc(long ptr, float l, float t, float r, float b, float startAngle, float sweepAngle)
-
_nAddRRect
public static void _nAddRRect(long ptr, float l, float t, float r, float b, float[] radii, int dir, int start)
-
_nAddPoly
public static void _nAddPoly(long ptr, float[] coords, boolean close)
-
_nAddPath
public static void _nAddPath(long ptr, long srcPtr, boolean extend)
-
_nAddPathOffset
public static void _nAddPathOffset(long ptr, long srcPtr, float dx, float dy, boolean extend)
-
_nAddPathTransform
public static void _nAddPathTransform(long ptr, long srcPtr, float[] matrix, boolean extend)
-
_nReverseAddPath
public static void _nReverseAddPath(long ptr, long srcPtr)
-
_nOffset
public static void _nOffset(long ptr, float dx, float dy, long dst)
-
_nTransform
public static void _nTransform(long ptr, float[] matrix, long dst, boolean applyPerspectiveClip)
-
_nGetLastPt
public static io.github.humbleui.types.Point _nGetLastPt(long ptr)
-
_nSetLastPt
public static void _nSetLastPt(long ptr, float x, float y)
-
_nGetSegmentMasks
public static int _nGetSegmentMasks(long ptr)
-
_nContains
public static boolean _nContains(long ptr, float x, float y)
-
_nDump
public static void _nDump(long ptr)
-
_nDumpHex
public static void _nDumpHex(long ptr)
-
_nSerializeToBytes
public static byte[] _nSerializeToBytes(long ptr)
-
_nMakeCombining
public static long _nMakeCombining(long onePtr, long twoPtr, int op)
-
_nMakeFromBytes
public static long _nMakeFromBytes(byte[] data)
-
_nGetGenerationId
public static int _nGetGenerationId(long ptr)
-
_nIsValid
public static boolean _nIsValid(long ptr)
-
-