Path

class Path

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 Path.updateBoundsCache() to make Path thread safe.

Example:

path = skia.Path()
path.addCircle(25, 25, 10)
path.addRect((50, 60, 70, 70))

for verb, points in path:
    print(verb)

Classes

AddPathMode

Members:

ArcSize

Members:

Iter

Iterates through verb array, and associated Point array and conic weight.

RawIter

Iterates through verb array, and associated Point array and conic weight.

SegmentMask

Members:

Verb

Members:

Methods

Circle

ConvertConicToQuads

Approximates conic with quad array.

IsCubicDegenerate

Tests if cubic is degenerate.

IsLineDegenerate

Tests if line between Point pair is degenerate.

IsQuadDegenerate

Tests if quad is degenerate.

Line

Make

Create a new path with the specified segments.

Oval

Polygon

RRect

Overloaded function.

Rect

__init__

Overloaded function.

addArc

Appends arc to Path, as the start of new contour.

addCircle

Adds circle centered at (x, y) of size radius to Path, appending PathVerb.kMove, four PathVerb.kConic, and PathVerb.kClose.

addOval

Overloaded function.

addPath

Overloaded function.

addPoly

Adds contour created from pts.

addRRect

Overloaded function.

addRect

Overloaded function.

addRoundRect

Overloaded function.

approximateBytesUsed

Returns the approximate byte size of the SkPath in memory.

arcTo

Overloaded function.

close

Appends Path.Verb.kClose to Path.

computeTightBounds

Returns minimum and maximum axes values of the lines and curves in Path.

conicTo

Overloaded function.

conservativelyContainsRect

Returns true if rect is contained by Path.

contains

Returns true if the point (x, y) is contained by Path, taking into account FillType.

countPoints

Returns the number of points in Path.

countVerbs

Returns the number of verbs: kMove_Verb, kLine_Verb, kQuad_Verb, kConic_Verb, kCubic_Verb, and kClose_Verb; added to Path.

cubicTo

Overloaded function.

dump

Overloaded function.

dumpHex

Writes text representation of Path to standard output.

getBounds

Returns minimum and maximum axes values of Point array.

getFillType

Returns PathFillType, the rule used to fill Path.

getGenerationID

(See Skia bug 1762.) Returns a non-zero, globally unique value.

getLastPt

Returns last point on Path in lastPt.

getPoint

Returns Point at index in Point array.

getPoints

Returns number of points in Path.

getSegmentMasks

Returns a mask, where each set bit corresponds to a SegmentMask constant if Path contains one or more verbs of that type.

getVerbs

Returns verbs in the path.

incReserve

Grows Path verb array, Point array and comics to contain extraPtCount additional Point.

interpolate

Interpolates between Path with Point array of equal size.

isConvex

Returns true if the path is convex.

isEmpty

Returns if Path is empty.

isFinite

Returns true for finite Point array values between negative SK_ScalarMax and positive SK_ScalarMax.

isInterpolatable

Returns true if Path contain equal verbs and equal weights.

isInverseFillType

Returns if FillType describes area outside Path geometry.

isLastContourClosed

Returns if contour is closed.

isLine

Returns true if Path contains only one line; Verb array has two entries: kMove_Verb, kLine_Verb.

isOval

Returns true if this path is recognized as an oval or circle.

isRRect

Returns true if path is representable as RRect.

isRect

Returns true if Path is equivalent to Rect when filled.

isValid

Returns if Path data is consistent.

isVolatile

Returns true if the path is volatile; it will not be altered or discarded by the caller after it is drawn.

lineTo

Overloaded function.

moveTo

Overloaded function.

offset

Offsets Point array by (dx, dy).

quadTo

Overloaded function.

rArcTo

Appends arc to Path, relative to last Path Point.

rConicTo

Adds conic from last point towards vector (dx1, dy1), to vector (dx2, dy2), weighted by w.

rCubicTo

Adds cubic from last point towards vector (dx1, dy1), then towards vector (dx2, dy2), to vector (dx3, dy3).

rLineTo

Adds line from last point to vector (dx, dy).

rMoveTo

Adds beginning of contour relative to last point.

rQuadTo

Adds quad from last point towards vector (dx1, dy1), to vector (dx2, dy2).

readFromMemory

Initializes Path from buffer of size length.

reset

Sets Path to its initial state.

reverseAddPath

Appends src to Path, from back to front.

rewind

Sets Path to its initial state, preserving internal storage.

serialize

Writes Path to buffer, returning the buffer written to, wrapped in Data.

setFillType

Sets FillType, the rule used to fill Path.

setIsVolatile

Specifies whether Path is volatile; whether it will be altered or discarded by the caller after it is drawn.

setLastPt

Overloaded function.

swap

Exchanges the verb array, Point array, weights, and PathFillType with other.

toggleInverseFillType

Replaces FillType with its inverse.

transform

Transforms verb array, Point array, and weight by matrix.

updateBoundsCache

Updates internal bounds so that subsequent calls to getBounds() are instantaneous.

writeToMemory

Writes Path to buffer, returning bytes.

Attributes

kAppend_AddPathMode

kClose_Verb

kConic_SegmentMask

kConic_Verb

kCubic_SegmentMask

kCubic_Verb

kDone_Verb

kExtend_AddPathMode

kLarge_ArcSize

kLine_SegmentMask

kLine_Verb

kMove_Verb

kQuad_SegmentMask

kQuad_Verb

kSmall_ArcSize

Methods

static Path.Circle(center_x: float, center_y: float, radius: float, pathDirection: skia.PathDirection = skia.PathDirection.kCW) skia.Path
static Path.ConvertConicToQuads(p0: skia.Point, p1: skia.Point, p2: skia.Point, w: float, pow2: int) list[skia.Point]

Approximates conic with quad array.

Conic is constructed from start Point p0, control Point p1, end Point p2, and weight w. 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 possible return array size is given by: (1 + 2 * (1 << pow2)).

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:
Returns:

quad array

Return type:

List[skia.Point]

static Path.IsCubicDegenerate(p1: skia.Point, p2: skia.Point, p3: skia.Point, p4: skia.Point, exact: bool) bool

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 (skia.Path) – cubic start point

  • p2 (skia.Path) – cubic control point 1

  • p3 (skia.Path) – cubic control point 2

  • p4 (skia.Path) – cubic end point

  • exact (bool) – 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

static Path.IsLineDegenerate(p1: skia.Point, p2: skia.Point, exact: bool) bool

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 (skia.Point) – line start point

  • p2 (skia.Point) – line end point

  • exact (bool) – if false, allow nearly equals

Returns:

true if line is degenerate; its length is effectively zero

static Path.IsQuadDegenerate(p1: skia.Point, p2: skia.Point, p3: skia.Point, exact: bool) bool

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 (skia.Path) – quad start point

  • p2 (skia.Path) – quad control point

  • p3 (skia.Path) – quad end point

  • exact (bool) – 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

static Path.Line(a: skia.Point, b: skia.Point) skia.Path
static Path.Make(points: list[skia.Point], verbs: list[int], conicWeights: list[float], fillType: skia.PathFillType, isVolatile: bool = False) skia.Path

Create a new path with the specified segments.

The points and weights arrays are read in order, based on the sequence of verbs.

Move 1 point Line 1 point Quad 2 points Conic 2 points and 1 weight Cubic 3 points Close 0 points

If an illegal sequence of verbs is encountered, or the specified number of points or weights is not sufficient given the verbs, an empty Path is returned.

A legal sequence of verbs consists of any number of Contours. A contour always begins with a Move verb, followed by 0 or more segments: Line, Quad, Conic, Cubic, followed by an optional Close.

static Path.Oval(rect: skia.Rect, pathDirection: skia.PathDirection = skia.PathDirection.kCW, startIndex: int = 0) skia.Path
static Path.Polygon(points: list[skia.Point], isClosed: bool, fillType: skia.PathFillType = skia.PathFillType.kWinding, isVolatile: bool = False) skia.Path
static Path.RRect(*args, **kwargs)

Overloaded function.

  1. RRect(rrect: skia.RRect, pathDirection: skia.PathDirection = skia.PathDirection.kCW, startIndex: int = 0) -> skia.Path

  2. RRect(bounds: skia.Rect, rx: float, ry: float, pathDirection: skia.PathDirection = skia.PathDirection.kCW) -> skia.Path

static Path.Rect(rect: skia.Rect, pathDirection: skia.PathDirection = skia.PathDirection.kCW, startIndex: int = 0) skia.Path
Path.__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: skia.Path) -> None

    Constructs an empty Path.

    By default, Path has no verbs, no Point, and no weights. FillType is set to kWinding.

  2. __init__(self: skia.Path, path: skia.Path) -> None

    Constructs a copy of an existing path.

    Copy constructor makes two paths identical by value. Internally, path and the returned result share pointer values. The underlying verb array, Point array and weights are copied when modified.

    Creating a Path copy is very efficient and never allocates memory. Path are always copied by value from the interface; the underlying shared pointers are not exposed.

    path:

    Path to copy by value

Path.addArc(self: skia.Path, oval: skia.Rect, startAngle: float, sweepAngle: float) skia.Path

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 (skia.Rect) – bounds of ellipse containing arc

  • startAngle (float) – starting angle of arc in degrees

  • sweepAngle (float) – sweep, in degrees. Positive is clockwise; treated modulo 360

Returns:

reference to Path

Path.addCircle(self: skia.Path, x: float, y: float, radius: float, dir: skia.PathDirection = skia.PathDirection.kCW) skia.Path

Adds circle centered at (x, y) of size radius to Path, appending PathVerb.kMove, four PathVerb.kConic, and PathVerb.kClose.

Circle begins at: (x + radius, y), continuing clockwise if dir is PathDirection.kCW, and counterclockwise if dir is PathDirection.kCCW.

Has no effect if radius is zero or negative.

Parameters:
  • x (float) – center of circle

  • y (float) – center of circle

  • radius (float) – distance from center to edge

  • dir (skia.PathDirection) – PathDirection to wind circle

Return type:

Path

Path.addOval(*args, **kwargs)

Overloaded function.

  1. addOval(self: skia.Path, oval: skia.Rect, dir: skia.PathDirection = skia.PathDirection.kCW) -> skia.Path

    Adds oval to path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.

    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 kCW, counterclockwise if dir is kCCW.

    oval:

    bounds of ellipse added

    dir:

    PathDirection to wind ellipse

    return:

    reference to Path

  2. addOval(self: skia.Path, oval: skia.Rect, dir: skia.PathDirection, start: int) -> skia.Path

    Adds oval to path, appending kMove_Verb, four kConic_Verb, and kClose_Verb.

    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 is kCW_Direction, counterclockwise if dir is kCW, counterclockwise if dir is kCCW.

    oval:

    bounds of ellipse added

    dir:

    Path::Direction to wind ellipse

    start:

    index of initial point of ellipse

    return:

    reference to Path

Path.addPath(*args, **kwargs)

Overloaded function.

  1. addPath(self: skia.Path, src: skia.Path, dx: float, dy: float, mode: skia.Path.AddPathMode = skia.Path.AddPathMode.kAppend_AddPathMode) -> skia.Path

    Appends src to Path, offset by (dx, dy).

    If mode is kAppend_AddPathMode, src verb array, Point array, and conic weights are added unaltered. If mode is kExtend_AddPathMode, add line before appending verbs, Point, and conic weights.

    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

    mode:

    kAppend_AddPathMode or kExtend_AddPathMode

    refe:return: rence to Path

  2. addPath(self: skia.Path, src: skia.Path, mode: skia.Path.AddPathMode = skia.Path.AddPathMode.kAppend_AddPathMode) -> skia.Path

    Appends src to Path.

    If mode is kAppend_AddPathMode, src verb array, Point array, and conic weights are added unaltered. If mode is kExtend_AddPathMode, add line before appending verbs, Point, and conic weights.

    src:

    Path verbs, Point, and conic weights to add

    mode:

    kAppend_AddPathMode or kExtend_AddPathMode

    return:

    reference to Path

  3. addPath(self: skia.Path, src: skia.Path, matrix: skia.Matrix, mode: skia.Path.AddPathMode = skia.Path.AddPathMode.kAppend_AddPathMode) -> skia.Path

    Appends src to Path, transformed by matrix.

    Transformed curves may have different verbs, Point, and conic weights.

    If mode is kAppend_AddPathMode, src verb array, Point array, and conic weights are added unaltered. If mode is kExtend_AddPathMode, add line before appending verbs, Point, and conic weights.

    src:

    Path verbs, Point, and conic weights to add

    matrix:

    transform applied to src

    mode:

    kAppend_AddPathMode or kExtend_AddPathMode

    return:

    reference to Path

Path.addPoly(self: skia.Path, pts: list[skia.Point], close: bool) skia.Path

Adds contour created from pts.

Contour added starts at pts[0], then adds a line for every additional Point in pts. If close is true, appends kClose_Verb to Path, connecting last and first Point in pts.

If pts is empty, append kMove_Verb to path.

Parameters:
  • pts – iterable of Point

  • close – true to add line connecting contour end and start

Returns:

reference to Path

Path.addRRect(*args, **kwargs)

Overloaded function.

  1. addRRect(self: skia.Path, rrect: skia.RRect, dir: skia.PathDirection = skia.PathDirection.kCW) -> skia.Path

    Adds rrect to Path, creating a new closed contour.

    If dir is kCW, rrect starts at top-left of the lower-left corner and winds clockwise. If dir is kCCW, 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.

    rrect:

    bounds and radii of rounded rectangle

    dir:

    Path::Direction to wind RRect

    return:

    reference to Path

  2. addRRect(self: skia.Path, rrect: skia.RRect, dir: skia.PathDirection, start: int) -> skia.Path

    Adds rrect to Path, creating a new closed contour.

    If dir is:py:attr:~skia.PathDirection.kCW, rrect winds clockwise; if dir is kCCW, rrect winds counterclockwise. start determines the first point of rrect to add.

    rrect:

    bounds and radii of rounded rectangle

    dir:

    Path::Direction to wind RRect

    start:

    index of initial point of RRect

    return:

    reference to Path

Path.addRect(*args, **kwargs)

Overloaded function.

  1. addRect(self: skia.Path, rect: skia.Rect, dir: skia.PathDirection = skia.PathDirection.kCW) -> skia.Path

    Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb, starting with top-left corner of Rect; followed by top-right, bottom-right, and bottom-left if dir is kCW; or followed by bottom-left, bottom-right, and top-right if dir is kCCW

    rect:

    Rect to add as a closed contour

    dir:

    Path::Direction to wind added contour

    return:

    reference to Path

  2. addRect(self: skia.Path, rect: skia.Rect, dir: skia.PathDirection, start: int) -> skia.Path

    Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and k:py:attr:~skia.Path.Verb.Close.

    If dir is kCW, Rect corners are added clockwise; if dir is kCCW, Rect corners are added counterclockwise. start determines the first corner added.

    rect:

    Rect to add as a closed contour

    dir:

    Path::Direction to wind added contour

    start:

    initial corner of Rect to add

    return:

    reference to Path

  3. addRect(self: skia.Path, left: float, top: float, right: float, bottom: float, dir: skia.PathDirection = skia.PathDirection.kCW) -> skia.Path

    Adds Rect (left, top, right, bottom) to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb, starting with top-left corner of Rect; followed by top-right, bottom-right, and bottom-left if dir is kCW; or followed by bottom-left, bottom-right, and top-right if dir is kCCW.

    left:

    smaller x-axis value of Rect

    top:

    smaller y-axis value of Rect

    right:

    larger x-axis value of Rect

    bottom:

    larger y-axis value of Rect

    dir:

    Path::Direction to wind added contour

    return:

    reference to Path

Path.addRoundRect(*args, **kwargs)

Overloaded function.

  1. addRoundRect(self: skia.Path, rect: skia.Rect, rx: float, ry: float, dir: skia.PathDirection = skia.PathDirection.kCW) -> skia.Path

    Appends RRect to Path, creating a new closed contour.

    RRect has bounds equal to rect; each corner is 90 degrees of an ellipse with radii (rx, ry). If dir is kCW, RRect starts at top-left of the lower-left corner and winds clockwise. If dir is kCCW, RRect starts at the bottom-left of the upper-left corner and winds counterclockwise.

    If either rx or ry is too large, rx and ry are scaled uniformly until the corners fit. If rx or ry is less than or equal to zero, addRoundRect() appends Rect rect to Path.

    After appending, Path may be empty, or may contain: Rect, oval, or RRect.

    rect:

    bounds of RRect

    rx:

    x-axis radius of rounded corners on the RRect

    ry:

    y-axis radius of rounded corners on the RRect

    dir:

    Path::Direction to wind RRect

    return:

    reference to Path

  2. addRoundRect(self: skia.Path, rect: skia.Rect, radii: Iterable, dir: skia.PathDirection = skia.PathDirection.kCW) -> skia.Path

    Appends RRect to Path, creating a new closed contour.

    RRect has bounds equal to rect; each corner is 90 degrees of an ellipse with radii from the array.

    rect:

    bounds of RRect

    radii:

    array of 8 Scalar values, a radius pair for each corner

    dir:

    Path::Direction to wind RRect

    Returns:

    reference to Path

Path.approximateBytesUsed(self: skia.Path) int

Returns the approximate byte size of the SkPath in memory.

Returns:

approximate size

Path.arcTo(*args, **kwargs)

Overloaded function.

  1. arcTo(self: skia.Path, oval: skia.Rect, startAngle: float, sweepAngle: float, forceMoveTo: bool) -> skia.Path

    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.

    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

    return:

    reference to Path

  2. arcTo(self: skia.Path, x1: float, y1: float, x2: float, y2: float, radius: float) -> skia.Path

    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, arcTo() 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, arcTo() appends Line from last Path Point to (x1, y1).

    arcTo() appends at most one Line and one conic. arcTo() implements the functionality of PostScript arct and HTML Canvas arcTo.

    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

    return:

    reference to Path

  3. arcTo(self: skia.Path, p1: skia.Point, p2: skia.Point, radius: float) -> skia.Path

    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, arcTo() 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, arcTo() appends line from last Path Point to p1.

    arcTo() appends at most one line and one conic. arcTo() implements the functionality of PostScript arct and HTML Canvas arcTo.

    p1:

    Point common to pair of tangents

    p2:

    end of second tangent

    radius:

    distance from arc to circle center

    return:

    reference to Path

  4. arcTo(self: skia.Path, rx: float, ry: float, xAxisRotate: float, largeArc: skia.Path.ArcSize, sweep: skia.PathDirection, x: float, y: float) -> skia.Path

    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. arcTo() appends line to (x, y) if either radii are zero, or if last Path Point equals (x, y). arcTo() scales radii (rx, ry) to fit last Path Point and (x, y) if both are greater than zero but too small.

    arcTo() appends up to four conic curves. arcTo() 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 kCW cast to int is zero.

    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

    largeArc:

    chooses smaller or larger arc

    sweep:

    chooses clockwise or counterclockwise arc

    x:

    end of arc

    y:

    end of arc

    return:

    reference to Path

  5. arcTo(self: skia.Path, r: skia.Point, xAxisRotate: float, largeArc: skia.Path.ArcSize, sweep: skia.PathDirection, xy: skia.Point) -> skia.Path

    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. arcTo() appends line to xy if either radii are zero, or if last Path Point equals (xy.fX, xy.fY). arcTo() scales radii r to fit last Path Point and xy if both are greater than zero but too small to describe an arc.

    arcTo() appends up to four conic curves. arcTo() 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 kCW cast to int is zero.

    r:

    radii on axes before x-axis rotation

    xAxisRotate:

    x-axis rotation in degrees; positive values are clockwise

    largeArc:

    chooses smaller or larger arc

    sweep:

    chooses clockwise or counterclockwise arc

    xy:

    end of arc

    return:

    reference to Path

Path.close(self: skia.Path) skia.Path

Appends Path.Verb.kClose to Path.

A closed contour connects the first and last Point with line, forming a continuous loop. Open and closed contour draw the same with Paint.kFill_Style. With Paint.kStroke_Style, open contour draws Paint.Cap at contour start and end; closed contour draws Paint.Join at contour start and end.

close() has no effect if Path is empty or last Path Verb is Path.Verb.kClose.

Returns:

reference to Path

Path.computeTightBounds(self: skia.Path) skia.Rect

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 kMove_Verb 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

Path.conicTo(*args, **kwargs)

Overloaded function.

  1. conicTo(self: skia.Path, x1: float, y1: float, x2: float, y2: float, w: float) -> skia.Path

    Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w.

    If Path is empty, or last Path.Verb is kClose_Verb, last point is set to (0, 0) before adding conic.

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

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

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

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

    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

    return:

    reference to Path

  2. conicTo(self: skia.Path, p1: skia.Point, p2: skia.Point, w: float) -> skia.Path

    Adds conic from last point towards Point p1, to Point p2, weighted by w.

    If Path is empty, or last Path.Verb is kClose_Verb, last point is set to (0, 0) before adding conic.

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

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

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

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

    p1:

    control Point of added conic

    p2:

    end Point of added conic

    w:

    weight of added conic

    return:

    reference to Path

Path.conservativelyContainsRect(self: skia.Path, rect: skia.Rect) bool

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 (skia.Rect) – Rect, line, or Point checked for containment

Returns:

true if rect is contained

Path.contains(self: skia.Path, x: float, y: float) bool

Returns true if the point (x, y) is contained by Path, taking into account FillType.

Parameters:
  • x (float) – x-axis value of containment test

  • y (float) – y-axis value of containment test

Returns:

true if Point is in Path

Path.countPoints(self: skia.Path) int

Returns the number of points in Path.

Point count is initially zero.

Returns:

Path Point array length

Path.countVerbs(self: skia.Path) int

Returns the number of verbs: kMove_Verb, kLine_Verb, kQuad_Verb, kConic_Verb, kCubic_Verb, and kClose_Verb; added to Path.

Returns:

length of verb array

Path.cubicTo(*args, **kwargs)

Overloaded function.

  1. cubicTo(self: skia.Path, x1: float, y1: float, x2: float, y2: float, x3: float, y3: float) -> skia.Path

    Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at (x3, y3).

    If Path is empty, or last Path.Verb is kClose_Verb, last point is set to (0, 0) before adding cubic.

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

    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

    return:

    reference to Path

  2. cubicTo(self: skia.Path, p1: skia.Point, p2: skia.Point, p3: skia.Point) -> skia.Path

    Adds cubic from last point towards Point p1, then towards Point p2, ending at Point p3.

    If Path is empty, or last Path.Verb is kClose_Verb, last point is set to (0, 0) before adding cubic.

    Appends kMove_Verb to verb array and (0, 0) to Point array, if needed; then appends kCubic_Verb to verb array; and Point p1, p2, p3 to Point array.

    p1:

    first control Point of cubic

    p2:

    second control Point of cubic

    p3:

    end Point of cubic

    return:

    reference to Path

Path.dump(*args, **kwargs)

Overloaded function.

  1. dump(self: skia.Path, stream: skia.WStream, dumpAsHex: bool) -> None

    Writes text representation of Path to stream.

    If stream is nullptr, writes to standard output. Set forceClose to true to get edges used to fill Path. Set dumpAsHex true to generate exact binary representations of floating point numbers used in Point array and conic weights.

    stream:

    writable WStream receiving Path text representation; may be nullptr

    dumpAsHex:

    true if Scalar values are written as hexadecimal

  2. dump(self: skia.Path) -> None

    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.

Path.dumpHex(self: skia.Path) None

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

Path.getBounds(self: skia.Path) skia.Rect

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

Returns:

bounds of all Point in Point array

Path.getFillType(self: skia.Path) skia.PathFillType

Returns PathFillType, the rule used to fill Path.

Returns:

current PathFillType setting

Path.getGenerationID(self: skia.Path) int

(See Skia bug 1762.) Returns a non-zero, globally unique value.

A different value is returned if verb array, Point array, or conic weight changes.

Setting Path.FillType does not change generation identifier.

Each time the path is modified, a different generation identifier will be returned. Path.FillType does affect generation identifier on Android framework.

Returns:

non-zero, globally unique value

Path.getLastPt(self: skia.Path, lastPt: skia.Point = None) bool

Returns last point on Path in lastPt.

Returns false if Point array is empty, storing (0, 0) if lastPt is not nullptr.

Parameters:

lastPt (skia.Point) – storage for final Point in Point array; may be nullptr

Returns:

true if Point array contains one or more Point

Path.getPoint(self: skia.Path, index: int) skia.Point

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 (skia.Point) – Point array element selector

Returns:

Point array value or (0, 0)

Path.getPoints(self: skia.Path, max: int = 0) list[skia.Point]

Returns number of points in Path.

Up to max points are copied. If max is greater than number of points, excess points storage is removed. If max is zero, calls countPoints() to get max.

Parameters:

max (int) – maximum to copy; must be greater than or equal to zero

Returns:

List of skia.Point

Return type:

List[skia.Point]

Path.getSegmentMasks(self: skia.Path) int

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

Path.getVerbs(self: skia.Path, max: int = 0) list[skia.Path.Verb]

Returns verbs in the path.

Up to max verbs are copied. The verbs are copied as one byte per verb.

Parameters:

max (int) – maximum number to copy into verbs

Returns:

List of skia.Path.Verb

Return type:

List[skia.Path.Verb]

Path.incReserve(self: skia.Path, extraPtCount: int, extraVerbCount: int = 0, extraConicCount: int = 0) None

Grows Path verb array, Point array and comics 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 (int) – number of additional Point to allocate

  • extraVerbCount (int) – number of additional verbs

  • extraConicCount (int) – number of additional conics

Path.interpolate(self: skia.Path, ending: skia.Path, weight: float, out: skia.Path) bool

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 false and leaves out unchanged if Point array is not the same size as ending Point array. Call isInterpolatable() to check Path compatibility prior to calling interpolate().

Parameters:
  • ending (skia.Path) – Point array averaged with this Point array

  • weight (float) – contribution of this Point array, and one minus contribution of ending Point array

  • out (skia.Path) – Path replaced by interpolated averages

Returns:

true if Path contain same number of Point

Path.isConvex(self: skia.Path) bool

Returns true if the path is convex.

If necessary, it will first compute the convexity.

Path.isEmpty(self: skia.Path) bool

Returns if Path is empty.

Empty Path may have FillType but has no Point, Path.Verb, or conic weight. Path`() constructs empty :py:class:`Path; reset() and rewind() make Path empty.

Returns:

true if the path contains no Path.Verb array

Path.isFinite(self: skia.Path) bool

Returns true for finite Point array values between negative SK_ScalarMax and positive SK_ScalarMax.

Returns false for any Point array value of SK_ScalarInfinity, SK_ScalarNegativeInfinity, or SK_ScalarNaN.

Returns:

true if all Point values are finite

Path.isInterpolatable(self: skia.Path, compare: skia.Path) bool

Returns true if Path contain equal verbs and equal weights.

If Path contain one or more conics, the weights must match.

conicTo() 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 (skia.Path) – Path to compare

Returns:

true if Path verb array and weights are equivalent

Path.isInverseFillType(self: skia.Path) bool

Returns if FillType describes area outside Path geometry.

The inverse fill area extends indefinitely.

Returns:

true if FillType is kInverseWinding or kInverseEvenOdd

Path.isLastContourClosed(self: skia.Path) bool

Returns if contour is closed.

Contour is closed if Path Verb array was last modified by close(). When stroked, closed contour draws Join instead of Cap at first and last Point.

Returns:

true if the last contour ends with a kClose_Verb

Path.isLine(self: skia.Path, p0: skia.Point = None, p1: skia.Point = None) bool

Returns true if Path contains only one line; Verb array has two entries: kMove_Verb, kLine_Verb.

If Path contains one line and line is not nullptr, line is set to line start point and line end point. Returns false if Path is not one line; line is unaltered.

Parameters:
  • p0 (skia.Point) – storage for line start. May be nullptr

  • p1 (skia.Point) – storage for line end. May be nullptr

Returns:

true if Path contains exactly one line

Path.isOval(self: skia.Path, oval: skia.Rect = None) bool

Returns true if this path is recognized as an oval or circle.

bounds receives bounds of oval.

bounds is unmodified if oval is not found.

Parameters:

bounds (skia.Rect) – storage for bounding Rect of oval; may be nullptr

Returns:

true if Path is recognized as an oval or circle

Path.isRRect(self: skia.Path, rrect: skia.RRect = None) bool

Returns true if path is representable as RRect.

Returns false if path is representable as oval, circle, or Rect.

rrect receives bounds of RRect.

rrect is unmodified if RRect is not found.

Parameters:

rrect (skia.RRect) – storage for bounding Rect of RRect; may be nullptr

Returns:

true if Path contains only RRect

Path.isRect(self: skia.Path, rect: skia.Rect = None, isClosed: bool = None, direction: skia.PathDirection = None) bool

Returns true if Path is equivalent to Rect when filled.

If false: rect, isClosed, and direction are unchanged. If true: rect, isClosed, and direction are written to if not nullptr.

rect may be smaller than the Path bounds. Path bounds may include kMove_Verb points that do not alter the area drawn by the returned rect.

Parameters:
  • rect – storage for bounds of Rect; may be nullptr

  • isClosed – storage set to true if Path is closed; may be nullptr

  • direction – storage set to Rect direction; may be nullptr

Returns:

true if Path contains Rect

Path.isValid(self: skia.Path) bool

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

Path.isVolatile(self: skia.Path) bool

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

Path.lineTo(*args, **kwargs)

Overloaded function.

  1. lineTo(self: skia.Path, x: float, y: float) -> skia.Path

    Adds line from last point to (x, y).

    If Path is empty, or last Verb is kClose_Verb, last point is set to (0, 0) before adding line.

    lineTo() appends kMove_Verb to verb array and (0, 0) to Point array, if needed. lineTo() then appends kLine_Verb to verb array and (x, y) to Point array.

    x:

    end of added line on x-axis

    y:

    end of added line on y-axis

    return:

    reference to Path

  2. lineTo(self: skia.Path, p: skia.Point) -> skia.Path

    Adds line from last point to Point p.

    If Path is empty, or last Verb is kClose_Verb, last point is set to (0, 0) before adding line.

    lineTo() appends kMove_Verb to verb array and (0, 0) to Point array, if needed. lineTo() then appends kLine_Verb to verb array and p to Point array.

    p:

    end Point of added line

    return:

    reference to Path

Path.moveTo(*args, **kwargs)

Overloaded function.

  1. moveTo(self: skia.Path, x: float, y: float) -> skia.Path

    Adds beginning of contour at Point (x, y).

    x:

    x-axis value of contour start

    y:

    y-axis value of contour start

    return:

    reference to Path

  2. moveTo(self: skia.Path, p: skia.Point) -> skia.Path

    Adds beginning of contour at Point p.

    p:

    contour start

    return:

    reference to Path

Path.offset(self: skia.Path, dx: float, dy: float, dst: skia.Path = None) None

Offsets Point array by (dx, dy).

Offset Path replaces dst. If dst is nullptr, Path is replaced by offset data.

Parameters:
  • dx (float) – offset added to Point array x-axis coordinates

  • dy (float) – offset added to Point array y-axis coordinates

  • dst (skia.Path) – overwritten, translated copy of Path; may be nullptr

Path.quadTo(*args, **kwargs)

Overloaded function.

  1. quadTo(self: skia.Path, x1: float, y1: float, x2: float, y2: float) -> skia.Path

    Adds quad from last point towards (x1, y1), to (x2, y2).

    If Path is empty, or last Path.Verb is kClose_Verb, last point is set to (0, 0) before adding quad.

    Appends kMove_Verb to verb array and (0, 0) to Point array, if needed; then appends kQuad_Verb to verb array; and (x1, y1), (x2, y2) to Point array.

    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

    return:

    reference to Path

  2. quadTo(self: skia.Path, p1: skia.Point, p2: skia.Point) -> skia.Path

    Adds quad from last point towards Point p1, to Point p2.

    If Path is empty, or last Path.Verb is kClose_Verb, last point is set to (0, 0) before adding quad.

    Appends kMove_Verb to verb array and (0, 0) to Point array, if needed; then appends kQuad_Verb to verb array; and Point p1, p2 to Point array.

    p1:

    control Point of added quad

    p2:

    end Point of added quad

    return:

    reference to Path

Path.rArcTo(self: skia.Path, rx: float, ry: float, xAxisRotate: float, largeArc: skia.Path.ArcSize, sweep: skia.PathDirection, dx: float, dy: float) skia.Path

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. arcTo() appends line to end Point if either radii are zero, or if last Path Point equals end Point. arcTo() 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.

arcTo() appends up to four conic curves. arcTo() 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 kCW cast to int is zero.

Parameters:
  • rx (float) – radius before x-axis rotation

  • ry (float) – radius before x-axis rotation

  • xAxisRotate (float) – x-axis rotation in degrees; positive values are clockwise

  • largeArc (skia.ArcSize) – chooses smaller or larger arc

  • sweep (skia.PathDirection) – chooses clockwise or counterclockwise arc

  • dx (float) – x-axis offset end of arc from last Path Point

  • dy (float) – y-axis offset end of arc from last Path Point

Returns:

reference to Path

Path.rConicTo(self: skia.Path, dx1: float, dy1: float, dx2: float, dy2: float, w: float) skia.Path

Adds conic from last point towards vector (dx1, dy1), to vector (dx2, dy2), weighted by w.

If Path is empty, or last Path::Verb is kClose_Verb, last point is set to (0, 0) before adding conic.

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

If w is finite and not one, next appends kConic_Verb to verb array, and w is recorded as conic weight; otherwise, if w is one, appends kQuad_Verb to verb array; or if w is not finite, appends kLine_Verb 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 (float) – offset from last point to conic control on x-axis

  • dy1 (float) – offset from last point to conic control on y-axis

  • dx2 (float) – offset from last point to conic end on x-axis

  • dy2 (float) – offset from last point to conic end on y-axis

  • w (float) – weight of added conic

Returns:

reference to Path

Path.rCubicTo(self: skia.Path, dx1: float, dy1: float, dx2: float, dy2: float, dx3: float, dy3: float) skia.Path

Adds cubic from last point towards vector (dx1, dy1), then towards vector (dx2, dy2), to vector (dx3, dy3).

If Path is empty, or last Path.Verb is kClose_Verb, last point is set to (0, 0) before adding cubic.

Appends kMove_Verb to verb array and (0, 0) to Point array, if needed; then appends kCubic_Verb 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 (float) – offset from last point to first cubic control on x-axis

  • dy1 (float) – offset from last point to first cubic control on y-axis

  • dx2 (float) – offset from last point to second cubic control on x-axis

  • dy2 (float) – offset from last point to second cubic control on y-axis

  • dx3 (float) – offset from last point to cubic end on x-axis

  • dy3 (float) – offset from last point to cubic end on y-axis

Returns:

reference to Path

Path.rLineTo(self: skia.Path, dx: float, dy: float) skia.Path

Adds line from last point to vector (dx, dy).

If Path is empty, or last Verb is kClose_Verb, last point is set to (0, 0) before adding line.

Appends kMove_Verb to verb array and (0, 0) to Point array, if needed; then appends kLine_Verb to 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 (float) – offset from last point to line end on x-axis

  • dy (float) – offset from last point to line end on y-axis

Returns:

reference to Path

Path.rMoveTo(self: skia.Path, dx: float, dy: float) skia.Path

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 (int) – offset from last point to contour start on x-axis

  • dy (int) – offset from last point to contour start on y-axis

Returns:

reference to Path

Path.rQuadTo(self: skia.Path, dx1: float, dy1: float, dx2: float, dy2: float) skia.Path

Adds quad from last point towards vector (dx1, dy1), to vector (dx2, dy2).

If Path is empty, or last Verb is kClose_Verb, last point is set to (0, 0) before adding quad.

Appends kMove_Verb to verb array and (0, 0) to Point array, if needed; then appends kQuad_Verb to 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 (float) – offset from last point to quad control on x-axis

  • dy1 (float) – offset from last point to quad control on y-axis

  • dx2 (float) – offset from last point to quad end on x-axis

  • dy2 (float) – offset from last point to quad end on y-axis

Returns:

reference to Path

Path.readFromMemory(self: skia.Path, buffer: Buffer) int

Initializes Path from buffer of size length.

Returns zero if the buffer is data is inconsistent, or the length is too small.

Reads Path.FillType, verb array, Point array, conic weight, and additionally reads computed information like Path.Convexity and bounds.

Used only in concert with writeToMemory(); the format used for Path in memory is not guaranteed.

Parameters:

buffer (Union[bytes,bytearray,memoryview]) – storage for Path

Returns:

number of bytes read, or zero on failure

Path.reset(self: skia.Path) skia.Path

Sets Path to its initial state.

Removes verb array, Point array, and weights, and sets FillType to kWinding. Internal storage associated with Path is released.

Returns:

reference to Path

Path.reverseAddPath(self: skia.Path, src: skia.Path) skia.Path

Appends src to Path, from back to front.

Reversed src always appends a new contour to Path.

Parameters:

srcPath verbs, Point, and conic weights to add

Returns:

reference to Path

Path.rewind(self: skia.Path) skia.Path

Sets Path to its initial state, preserving internal storage.

Removes verb array, Point array, and weights, and sets FillType 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:

reference to Path

Path.serialize(self: skia.Path) skia.Data

Writes Path to buffer, returning the buffer written to, wrapped in Data.

serialize() writes FillType, verb array, Point array, conic weight, and additionally writes computed information like Convexity and bounds.

serialize() should only be used in concert with readFromMemory(). The format used for Path in memory is not guaranteed.

Returns:

Path data wrapped in Data buffer

Path.setFillType(self: skia.Path, ft: skia.PathFillType) None

Sets FillType, the rule used to fill Path.

While there is no check that ft is legal, values outside of FillType are not supported.

Path.setIsVolatile(self: skia.Path, isVolatile: bool) skia.Path

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 BaseDevice to attach a cache of data which speeds repeated drawing.

Mark temporary paths, discarded or modified after use, as volatile to inform BaseDevice 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 (bool) – true if caller will alter Path after drawing

Path.setLastPt(*args, **kwargs)

Overloaded function.

  1. setLastPt(self: skia.Path, x: float, y: float) -> None

    Sets last point to (x, y).

    If Point array is empty, append kMove_Verb to verb array and append (x, y) to Point array.

    x:

    set x-axis value of last point

    y:

    set y-axis value of last point

  2. setLastPt(self: skia.Path, p: skia.Point) -> None

    Sets the last point on the path.

    If Point array is empty, append kMove_Verb to verb array and append p to Point array.

    p:

    set value of last point

Path.swap(self: skia.Path, other: skia.Path) None

Exchanges the verb array, Point array, weights, and PathFillType with other.

Cached state is also exchanged. swap() internally exchanges pointers, so it is lightweight and does not allocate memory.

Parameters:

other (skia.Path) – Path exchanged by value

Path.toggleInverseFillType(self: skia.Path) None

Replaces FillType with its inverse.

The inverse of FillType describes the area unmodified by the original FillType.

Path.transform(self: skia.Path, matrix: skia.Matrix, dst: skia.Path = None, pc: skia.ApplyPerspectiveClip = skia.ApplyPerspectiveClip.kYes) None

Transforms verb array, Point array, and weight by matrix.

transform may change verbs and increase their number. Transformed Path replaces dst; if dst is nullptr, original data is replaced.

Parameters:
Path.updateBoundsCache(self: skia.Path) None

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.

Path.writeToMemory(self: skia.Path) bytes

Writes Path to buffer, returning bytes.

Writes FillType, verb array, Point array, conic weight, and additionally writes computed information like Convexity and bounds.

Use only be used in concert with readFromMemory(); the format used for Path in memory is not guaranteed.

Returns:

serialized bytes

Attributes

Path.kAppend_AddPathMode = <AddPathMode.kAppend_AddPathMode: 0>
Path.kClose_Verb = <Verb.kClose_Verb: 5>
Path.kConic_SegmentMask = <SegmentMask.kConic_SegmentMask: 4>
Path.kConic_Verb = <Verb.kConic_Verb: 3>
Path.kCubic_SegmentMask = <SegmentMask.kCubic_SegmentMask: 8>
Path.kCubic_Verb = <Verb.kCubic_Verb: 4>
Path.kDone_Verb = <Verb.kDone_Verb: 6>
Path.kExtend_AddPathMode = <AddPathMode.kExtend_AddPathMode: 1>
Path.kLarge_ArcSize = <ArcSize.kLarge_ArcSize: 1>
Path.kLine_SegmentMask = <SegmentMask.kLine_SegmentMask: 1>
Path.kLine_Verb = <Verb.kLine_Verb: 1>
Path.kMove_Verb = <Verb.kMove_Verb: 0>
Path.kQuad_SegmentMask = <SegmentMask.kQuad_SegmentMask: 2>
Path.kQuad_Verb = <Verb.kQuad_Verb: 2>
Path.kSmall_ArcSize = <ArcSize.kSmall_ArcSize: 0>