Class 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.

    • Field Summary

      • Fields inherited from class io.github.humbleui.skija.impl.Native

        _ptr
    • Constructor Summary

      Constructors 
      Constructor Description
      Path()
      Constructs an empty Path.
      Path​(long ptr)  
    • 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 if PathFillMode, 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)  
      Path addArc​(io.github.humbleui.types.Rect oval, float startAngle, float sweepAngle)
      Appends arc to Path, as the start of new contour.
      Path addCircle​(float x, float y, float radius)
      Adds circle centered at (x, y) of size radius to Path, appending PathVerb.MOVE, four PathVerb.CONIC, and PathVerb.CLOSE.
      Path addCircle​(float x, float y, float radius, PathDirection dir)
      Adds circle centered at (x, y) of size radius to Path, appending PathVerb.MOVE, four PathVerb.CONIC, and PathVerb.CLOSE.
      Path addOval​(io.github.humbleui.types.Rect oval)
      Adds oval to path, appending PathVerb.MOVE, four PathVerb.CONIC, and PathVerb.CLOSE.
      Path addOval​(io.github.humbleui.types.Rect oval, PathDirection dir)
      Adds oval to path, appending PathVerb.MOVE, four PathVerb.CONIC, and PathVerb.CLOSE.
      Path addOval​(io.github.humbleui.types.Rect oval, PathDirection dir, int start)
      Adds oval to Path, appending PathVerb.MOVE, four PathVerb.CONIC, and PathVerb.CLOSE.
      Path addPath​(Path src)
      Appends src to Path.
      Path addPath​(Path src, boolean extend)
      Appends src to Path.
      Path addPath​(Path src, float dx, float dy)
      Appends src to Path, offset by (dx, dy).
      Path addPath​(Path src, float dx, float dy, boolean extend)
      Appends src to Path, offset by (dx, dy).
      Path addPath​(Path src, Matrix33 matrix)
      Appends src to Path, transformed by matrix.
      Path addPath​(Path src, Matrix33 matrix, boolean extend)
      Appends src to Path, transformed by matrix.
      Path addPoly​(float[] pts, boolean close)
      Adds contour created from line array, adding (pts.length / 2 - 1) line segments.
      Path addPoly​(io.github.humbleui.types.Point[] pts, boolean close)
      Adds contour created from line array, adding (pts.length - 1) line segments.
      Path addRect​(io.github.humbleui.types.Rect rect)
      Adds Rect to Path, appending PathVerb.MOVE, three PathVerb.LINE, and PathVerb.CLOSE, starting with top-left corner of Rect; followed by top-right, bottom-right, and bottom-left.
      Path addRect​(io.github.humbleui.types.Rect rect, PathDirection dir)
      Adds Rect to Path, appending PathVerb.MOVE, three PathVerb.LINE, and PathVerb.CLOSE, starting with top-left corner of Rect; followed by top-right, bottom-right, and bottom-left if dir is PathDirection.CLOCKWISE; or followed by bottom-left, bottom-right, and top-right if dir is PathDirection.COUNTER_CLOCKWISE.
      Path addRect​(io.github.humbleui.types.Rect rect, PathDirection dir, int start)
      Adds Rect to Path, appending PathVerb.MOVE, three PathVerb.LINE, and PathVerb.CLOSE.
      Path addRRect​(io.github.humbleui.types.RRect rrect)
      Adds rrect to Path, creating a new closed contour.
      Path addRRect​(io.github.humbleui.types.RRect rrect, PathDirection dir)
      Adds rrect to Path, creating a new closed contour.
      Path addRRect​(io.github.humbleui.types.RRect rrect, PathDirection dir, int start)
      Adds rrect to Path, creating a new closed contour.
      Path arcTo​(io.github.humbleui.types.Rect oval, float startAngle, float sweepAngle, boolean forceMoveTo)
      Appends arc to Path.
      Path closePath()
      Appends PathVerb.CLOSE to Path.
      io.github.humbleui.types.Rect computeTightBounds()
      Returns minimum and maximum axes values of the lines and curves in Path.
      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.
      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.
      boolean conservativelyContainsRect​(io.github.humbleui.types.Rect rect)
      Returns true if rect is contained by Path.
      boolean contains​(float x, float y)
      Returns true if the point (x, y) is contained by Path, taking into account PathFillMode.
      boolean contains​(io.github.humbleui.types.Point p)
      Returns true if the point is contained by Path, taking into account PathFillMode.
      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.
      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).
      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.
      Path dump()
      Writes text representation of Path to standard output.
      Path dumpHex()
      Writes text representation of Path to standard output.
      Path ellipticalArcTo​(float rx, float ry, float xAxisRotate, PathEllipseArc arc, PathDirection direction, float x, float y)
      Appends arc to Path.
      Path ellipticalArcTo​(io.github.humbleui.types.Point r, float xAxisRotate, PathEllipseArc arc, PathDirection direction, io.github.humbleui.types.Point xy)
      Appends arc to Path.
      long getApproximateBytesUsed()
      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.Rect getBounds()
      Returns minimum and maximum axes values of Point array.
      PathFillMode getFillMode()  
      int getGenerationId()
      Returns a non-zero, globally unique value.
      io.github.humbleui.types.Point getLastPt()
      Returns last point on Path in lastPt.
      io.github.humbleui.types.Point getPoint​(int index)
      Returns Point at index in Point array.
      io.github.humbleui.types.Point[] getPoints()
      Returns all points in Path.
      int getPoints​(io.github.humbleui.types.Point[] points, int max)
      Returns number of points in Path.
      int getPointsCount()
      Returns the number of points in Path.
      int getSegmentMasks()
      Returns a mask, where each set bit corresponds to a SegmentMask constant if Path contains one or more verbs of that type.
      PathVerb[] getVerbs()  
      int getVerbs​(PathVerb[] verbs, int max)
      Returns the number of verbs in the path.
      int getVerbsCount()
      Returns the number of verbs: PathVerb.MOVE, PathVerb.LINE, PathVerb.QUAD, PathVerb.CONIC, PathVerb.CUBIC, and PathVerb.CLOSE; added to Path.
      Path incReserve​(int extraPtCount)
      Grows Path verb array and Point array to contain extraPtCount additional Point.
      boolean isConvex()
      Returns true if the path is convex.
      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.
      boolean isEmpty()
      Returns if Path is empty.
      boolean isFinite()
      Returns true for finite Point array values between negative Float.MIN_VALUE and positive Float.MAX_VALUE.
      boolean isInterpolatable​(Path compare)
      Returns true if Path contain equal verbs and equal weights.
      boolean isLastContourClosed()
      Returns if contour is closed.
      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.
      io.github.humbleui.types.Rect isOval()
      Returns oval bounds if this path is recognized as an oval or circle.
      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.
      io.github.humbleui.types.Rect isRect()
      Returns Rect if Path is equivalent to Rect when filled.
      io.github.humbleui.types.RRect isRRect()
      Returns RRect if this path is recognized as an oval, circle or RRect.
      boolean isValid()
      Returns if Path data is consistent.
      boolean isVolatile()
      Returns true if the path is volatile; it will not be altered or discarded by the caller after it is drawn.
      PathSegmentIterator iterator()  
      PathSegmentIterator iterator​(boolean forceClose)  
      Path lineTo​(float x, float y)
      Adds line from last point to (x, y).
      Path lineTo​(io.github.humbleui.types.Point p)
      Adds line from last point to Point p.
      static @Nullable Path makeCombining​(@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 Path makeFromBytes​(byte[] data)
      Initializes Path from byte buffer.
      static @NotNull Path makeFromSVGString​(java.lang.String svg)  
      Path makeLerp​(Path ending, float weight)
      Interpolates between Path with Point array of equal size.
      Path moveTo​(float x, float y)
      Adds beginning of contour at Point (x, y).
      Path moveTo​(io.github.humbleui.types.Point p)
      Adds beginning of contour at Point p.
      Path offset​(float dx, float dy)
      Offsets Point array by (dx, dy).
      Path offset​(float dx, float dy, Path dst)
      Offsets Point array by (dx, dy).
      Path quadTo​(float x1, float y1, float x2, float y2)
      Adds quad from last point towards (x1, y1), to (x2, y2).
      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.
      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.
      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).
      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.
      Path reset()
      Sets Path to its initial state.
      Path reverseAddPath​(Path src)
      Appends src to Path, from back to front.
      Path rewind()
      Sets Path to its initial state, preserving internal storage.
      Path rLineTo​(float dx, float dy)
      Adds line from last point to vector (dx, dy).
      Path rMoveTo​(float dx, float dy)
      Adds beginning of contour relative to last point.
      Path rQuadTo​(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.
      Path setFillMode​(PathFillMode fillMode)  
      Path setLastPt​(float x, float y)
      Sets last point to (x, y).
      Path setLastPt​(io.github.humbleui.types.Point p)
      Sets the last point on the path.
      Path setVolatile​(boolean isVolatile)
      Specifies whether Path is volatile; whether it will be altered or discarded by the caller after it is drawn.
      Path swap​(Path other)
      Exchanges the verb array, Point array, weights, and FillMode with other.
      Path tangentArcTo​(float x1, float y1, float x2, float y2, float radius)
      Appends arc to Path, after appending line if needed.
      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.
      Path transform​(Matrix33 matrix)
      Transforms verb array, Point array, and weight by matrix.
      Path transform​(Matrix33 matrix, boolean applyPerspectiveClip)
      Transforms verb array, Point array, and weight by matrix.
      Path transform​(Matrix33 matrix, Path dst)
      Transforms verb array, Point array, and weight by matrix.
      Path transform​(Matrix33 matrix, Path dst, boolean applyPerspectiveClip)
      Transforms verb array, Point array, and weight by matrix.
      Path updateBoundsCache()
      Updates internal bounds so that subsequent calls to getBounds() are instantaneous.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • Path

        public Path()
        Constructs an empty Path. By default, Path has no verbs, no Point, and no weights. FillMode is set to PathFillMode.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 if PathFillMode, verb array, Point array, and weights are equivalent.
        Overrides:
        _nativeEquals in class Native
        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 Point array 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 array
        weight - 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
      • 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()
        Returns RRect if 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
      • 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 of reset() 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() and rewind() make Path empty.

        Returns:
        true if the path contains no Verb array
      • 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, allowing Surface to attach a cache of data which speeds repeated drawing. If true, Surface may 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 point
        p2 - line end point
        exact - 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 point
        p2 - quad control point
        p3 - quad end point
        exact - 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 point
        p2 - cubic control point 1
        p3 - cubic control point 2
        p4 - cubic end point
        exact - 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
      • 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 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 null
        max - 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
      • 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 null
        max - 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.MOVE that 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 through getBounds().

        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 PathVerb.MOVE that define empty contours.

        Behaves identically to getBounds() when Path contains only lines. If Path contains curves, computed bounds includes the maximum extent of the quad, conic, or cubic; is slower than getBounds(); and unlike getBounds(), 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 start
        y - 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-axis
        dy - 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.MOVE to verb array and (0, 0) to Point array, if needed. lineTo() then appends PathVerb.LINE to verb array and (x, y) to Point array.

        Parameters:
        x - end of added line on x-axis
        y - 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 PathVerb is PathVerb.CLOSE, last point is set to (0, 0) before adding line.

        lineTo() first appends PathVerb.MOVE to verb array and (0, 0) to Point array, if needed. lineTo() then appends PathVerb.LINE to verb array and Point p to Point array.

        Parameters:
        p - end Point of added line
        Returns:
        reference to Path
      • 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 last PathVerb is PathVerb.CLOSE, last point is set to (0, 0) before adding quad. Appends PathVerb.MOVE to verb array and (0, 0) to Point array, if needed; then appends PathVerb.QUAD to verb array; and (x1, y1), (x2, y2) to Point array.
        Parameters:
        x1 - control Point of quad on x-axis
        y1 - control Point of quad on y-axis
        x2 - end Point of quad on x-axis
        y2 - 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 PathVerb is PathVerb.CLOSE, last point is set to (0, 0) before adding quad.

        Appends PathVerb.MOVE to verb array and (0, 0) to Point array, if needed; then appends PathVerb.QUAD to verb array; and Point p1, p2 to Point array.

        Parameters:
        p1 - control Point of added quad
        p2 - end Point of added quad
        Returns:
        reference to Path
      • 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 PathVerb is PathVerb.CLOSE, last point is set to (0, 0) before adding conic.

        Appends PathVerb.MOVE to verb array and (0, 0) to Point array, if needed.

        If w is finite and not one, appends PathVerb.CONIC to verb array; and (x1, y1), (x2, y2) to Point array; and w to conic weights.

        If w is one, appends PathVerb.QUAD to verb array, and (x1, y1), (x2, y2) to Point array.

        If w is not finite, appends PathVerb.LINE twice to verb array, and (x1, y1), (x2, y2) to Point array.

        Parameters:
        x1 - control Point of conic on x-axis
        y1 - control Point of conic on y-axis
        x2 - end Point of conic on x-axis
        y2 - end Point of conic on y-axis
        w - 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 PathVerb is PathVerb.CLOSE, last point is set to (0, 0) before adding conic.

        Appends PathVerb.MOVE to verb array and (0, 0) to Point array, if needed.

        If w is finite and not one, appends PathVerb.CONIC to verb array; and Point p1, p2 to Point array; and w to conic weights.

        If w is one, appends PathVerb.QUAD to verb array, and Point p1, p2 to Point array.

        If w is not finite, appends PathVerb.LINE twice to verb array, and Point p1, p2 to Point array.

        Parameters:
        p1 - control Point of added conic
        p2 - end Point of added conic
        w - 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 PathVerb is PathVerb.CLOSE, last point is set to (0, 0) before adding conic.

        Appends PathVerb.MOVE to verb array and (0, 0) to Point array, if needed.

        If w is finite and not one, next appends PathVerb.CONIC to verb array, and w is recorded as conic weight; otherwise, if w is one, appends PathVerb.QUAD to verb array; or if w is not finite, appends PathVerb.LINE twice 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-axis
        dy1 - offset from last point to conic control on y-axis
        dx2 - offset from last point to conic end on x-axis
        dy2 - offset from last point to conic end on y-axis
        w - 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 PathVerb is PathVerb.CLOSE, last point is set to (0, 0) before adding cubic.

        Appends PathVerb.MOVE to verb array and (0, 0) to Point array, if needed; then appends PathVerb.CUBIC to verb array; and (x1, y1), (x2, y2), (x3, y3) to Point array.

        Parameters:
        x1 - first control Point of cubic on x-axis
        y1 - first control Point of cubic on y-axis
        x2 - second control Point of cubic on x-axis
        y2 - second control Point of cubic on y-axis
        x3 - end Point of cubic on x-axis
        y3 - 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 PathVerb is PathVerb.CLOSE, last point is set to (0, 0) before adding cubic.

        Appends PathVerb.MOVE to verb array and (0, 0) to Point array, if needed; then appends PathVerb.CUBIC to verb array; and Point p1, p2, p3 to Point array.

        Parameters:
        p1 - first control Point of cubic
        p2 - second control Point of cubic
        p3 - 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 PathVerb is PathVerb.CLOSE, last point is set to (0, 0) before adding cubic.

        Appends PathVerb.MOVE to verb array and (0, 0) to Point array, if needed; then appends PathVerb.CUBIC to 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-axis
        dy1 - offset from last point to first cubic control on y-axis
        dx2 - offset from last point to second cubic control on x-axis
        dy2 - offset from last point to second cubic control on y-axis
        dx3 - offset from last point to cubic end on x-axis
        dy3 - 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 arc
        startAngle - starting angle of arc in degrees
        sweepAngle - sweep, in degrees. Positive is clockwise; treated modulo 360
        forceMoveTo - 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 tangents
        y1 - y-axis value common to pair of tangents
        x2 - x-axis value end of second tangent
        y2 - y-axis value end of second tangent
        radius - 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 tangents
        p2 - end of second tangent
        radius - 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.CLOCKWISE cast to int is zero.

        Parameters:
        rx - radius on x-axis before x-axis rotation
        ry - radius on y-axis before x-axis rotation
        xAxisRotate - x-axis rotation in degrees; positive values are clockwise
        arc - chooses smaller or larger arc
        direction - chooses clockwise or counterclockwise arc
        x - end of arc
        y - 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.CLOCKWISE cast to int is zero.

        Parameters:
        r - radii on axes before x-axis rotation
        xAxisRotate - x-axis rotation in degrees; positive values are clockwise
        arc - chooses smaller or larger arc
        direction - chooses clockwise or counterclockwise arc
        xy - 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.CLOCKWISE cast to int is zero.

        Parameters:
        rx - radius before x-axis rotation
        ry - radius before x-axis rotation
        xAxisRotate - x-axis rotation in degrees; positive values are clockwise
        arc - chooses smaller or larger arc
        direction - chooses clockwise or counterclockwise arc
        dx - x-axis offset end of arc from last Path Point
        dy - y-axis offset end of arc from last Path Point
        Returns:
        reference to Path
      • 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 Point
        p1 - conic control Point
        p2 - conic end Point
        w - conic weight
        pow2 - 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 include PathVerb.MOVE points 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
      • addOval

        public Path addOval​(io.github.humbleui.types.Rect oval)

        Adds oval to path, appending PathVerb.MOVE, four PathVerb.CONIC, and PathVerb.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
      • addCircle

        public Path addCircle​(float x,
                              float y,
                              float radius)

        Adds circle centered at (x, y) of size radius to Path, appending PathVerb.MOVE, four PathVerb.CONIC, and PathVerb.CLOSE. Circle begins at: (x + radius, y)

        Has no effect if radius is zero or negative.

        Parameters:
        x - center of circle
        y - center of circle
        radius - 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, four PathVerb.CONIC, and PathVerb.CLOSE. Circle begins at: (x + radius, y), continuing clockwise if dir is PathDirection.CLOCKWISE, and counterclockwise if dir is PathDirection.COUNTER_CLOCKWISE.

        Has no effect if radius is zero or negative.

        Parameters:
        x - center of circle
        y - center of circle
        radius - distance from center to edge
        dir - 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 arc
        startAngle - starting angle of arc in degrees
        sweepAngle - 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 is PathDirection.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 rectangle
        dir - 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 is PathDirection.COUNTER_CLOCKWISE, rrect winds counterclockwise. start determines the first point of rrect to add.

        Parameters:
        rrect - bounds and radii of rounded rectangle
        dir - Direction to wind RRect
        start - 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.CLOSE to Path, connecting pts[pts.length - 1] and pts[0].

        If pts is empty, append PathVerb.MOVE to path.

        Parameters:
        pts - array of line sharing end and start Point
        close - 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.CLOSE to Path, connecting (pts[count - 2], pts[count - 1]) and (pts[0], pts[1]).

        If pts is empty, append PathVerb.MOVE to path.

        Parameters:
        pts - flat array of line sharing end and start Point
        close - 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 add
        extend - 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 add
        dx - offset added to src Point array x-axis coordinates
        dy - 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 add
        dx - offset added to src Point array x-axis coordinates
        dy - offset added to src Point array y-axis coordinates
        extend - 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 add
        matrix - 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 add
        matrix - transform applied to src
        extend - 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 coordinates
        dy - 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 coordinates
        dy - offset added to Point array y-axis coordinates
        dst - 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 Path
        applyPerspectiveClip - 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 Path
        dst - 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 Path
        dst - overwritten, transformed copy of Path; may be null
        applyPerspectiveClip - 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, append PathVerb.MOVE to verb array and append (x, y) to Point array.
        Parameters:
        x - set x-axis value of last point
        y - 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, append PathVerb.MOVE to 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
      • contains

        public boolean contains​(float x,
                                float y)
        Returns true if the point (x, y) is contained by Path, taking into account PathFillMode.
        Parameters:
        x - x-axis value of containment test
        y - 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 account PathFillMode.
        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
      • 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)