Path
- class Path
Pathcontain geometry.Pathmay be empty, or contain one or more verbs that outline a figure.Pathalways 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.Pathmay contain any number of contours, each beginning with a move verb.Pathcontours may contain only a move verb, or may also contain lines, quadratic beziers, conics, and cubic beziers.Pathcontours may be open or closed.When used to draw a filled area,
Pathdescribes whether the fill is inside or outside the geometry.Pathalso describes the winding rule used to fill overlapping contours.Internally,
Pathlazily computes metrics likes bounds and convexity. CallPath.updateBoundsCache()to makePaththread safe.Example:
path = skia.Path() path.addCircle(25, 25, 10) path.addRect((50, 60, 70, 70)) for verb, points in path: print(verb)
Classes
Members:
Members:
Iterates through verb array, and associated
Pointarray and conic weight.Iterates through verb array, and associated
Pointarray and conic weight.Members:
Members:
Methods
Circle(center_x: float, center_y: float, radius: float, pathDirection: skia.PathDirection = skia.PathDirection.kCW) -> skia.Path
ConvertConicToQuads(p0: skia.Point, p1: skia.Point, p2: skia.Point, w: float, pow2: int) -> list[skia.Point]
IsCubicDegenerate(p1: skia.Point, p2: skia.Point, p3: skia.Point, p4: skia.Point, exact: bool) -> bool
IsLineDegenerate(p1: skia.Point, p2: skia.Point, exact: bool) -> bool
IsQuadDegenerate(p1: skia.Point, p2: skia.Point, p3: skia.Point, exact: bool) -> bool
Line(a: skia.Point, b: skia.Point) -> skia.Path
Make(points: list[skia.Point], verbs: list[int], conicWeights: list[float], fillType: skia.PathFillType, isVolatile: bool = False) -> skia.Path
Oval(rect: skia.Rect, pathDirection: skia.PathDirection = skia.PathDirection.kCW, startIndex: int = 0) -> skia.Path
Polygon(points: list[skia.Point], isClosed: bool, fillType: skia.PathFillType = skia.PathFillType.kWinding, isVolatile: bool = False) -> skia.Path
Rect(rect: skia.Rect, pathDirection: skia.PathDirection = skia.PathDirection.kCW, startIndex: int = 0) -> skia.Path
addArc(self: skia.Path, oval: skia.Rect, startAngle: float, sweepAngle: float) -> skia.Path
addCircle(self: skia.Path, x: float, y: float, radius: float, dir: skia.PathDirection = skia.PathDirection.kCW) -> skia.Path
addPoly(self: skia.Path, pts: list[skia.Point], close: bool) -> skia.Path
approximateBytesUsed(self: skia.Path) -> int
close(self: skia.Path) -> skia.Path
computeTightBounds(self: skia.Path) -> skia.Rect
conservativelyContainsRect(self: skia.Path, rect: skia.Rect) -> bool
contains(self: skia.Path, x: float, y: float) -> bool
countPoints(self: skia.Path) -> int
countVerbs(self: skia.Path) -> int
dumpHex(self: skia.Path) -> None
getBounds(self: skia.Path) -> skia.Rect
getFillType(self: skia.Path) -> skia.PathFillType
getGenerationID(self: skia.Path) -> int
getLastPt(self: skia.Path, lastPt: skia.Point = None) -> bool
getPoint(self: skia.Path, index: int) -> skia.Point
getPoints(self: skia.Path, max: int = 0) -> list[skia.Point]
getSegmentMasks(self: skia.Path) -> int
getVerbs(self: skia.Path, max: int = 0) -> list[skia.Path.Verb]
incReserve(self: skia.Path, extraPtCount: int, extraVerbCount: int = 0, extraConicCount: int = 0) -> None
interpolate(self: skia.Path, ending: skia.Path, weight: float, out: skia.Path) -> bool
isConvex(self: skia.Path) -> bool
isEmpty(self: skia.Path) -> bool
isFinite(self: skia.Path) -> bool
isInterpolatable(self: skia.Path, compare: skia.Path) -> bool
isInverseFillType(self: skia.Path) -> bool
isLastContourClosed(self: skia.Path) -> bool
isLine(self: skia.Path, p0: skia.Point = None, p1: skia.Point = None) -> bool
isOval(self: skia.Path, oval: skia.Rect = None) -> bool
isRRect(self: skia.Path, rrect: skia.RRect = None) -> bool
isRect(self: skia.Path, rect: skia.Rect = None, isClosed: bool = None, direction: skia.PathDirection = None) -> bool
isValid(self: skia.Path) -> bool
isVolatile(self: skia.Path) -> bool
offset(self: skia.Path, dx: float, dy: float, dst: skia.Path = None) -> None
rArcTo(self: skia.Path, rx: float, ry: float, xAxisRotate: float, largeArc: skia.Path.ArcSize, sweep: skia.PathDirection, dx: float, dy: float) -> skia.Path
rConicTo(self: skia.Path, dx1: float, dy1: float, dx2: float, dy2: float, w: float) -> skia.Path
rCubicTo(self: skia.Path, dx1: float, dy1: float, dx2: float, dy2: float, dx3: float, dy3: float) -> skia.Path
rLineTo(self: skia.Path, dx: float, dy: float) -> skia.Path
rMoveTo(self: skia.Path, dx: float, dy: float) -> skia.Path
rQuadTo(self: skia.Path, dx1: float, dy1: float, dx2: float, dy2: float) -> skia.Path
readFromMemory(self: skia.Path, buffer: Buffer) -> int
reset(self: skia.Path) -> skia.Path
reverseAddPath(self: skia.Path, src: skia.Path) -> skia.Path
rewind(self: skia.Path) -> skia.Path
serialize(self: skia.Path) -> skia.Data
setFillType(self: skia.Path, ft: skia.PathFillType) -> None
setIsVolatile(self: skia.Path, isVolatile: bool) -> skia.Path
swap(self: skia.Path, other: skia.Path) -> None
toggleInverseFillType(self: skia.Path) -> None
transform(self: skia.Path, matrix: skia.Matrix, dst: skia.Path = None, pc: skia.ApplyPerspectiveClip = skia.ApplyPerspectiveClip.kYes) -> None
updateBoundsCache(self: skia.Path) -> None
writeToMemory(self: skia.Path) -> bytes
Attributes
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
Pointp0, controlPointp1, endPointp2, and weight w. Maximum quad count is 2 to the pow2. Every third point in array shares lastPointof previous quad and firstPointof 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:
p0 (skia.Point) – conic start
Pointp1 (skia.Point) – conic control
Pointp2 (skia.Point) – conic end
Pointw (float) – conic weight
pow2 (int) – quad count, as power of two, normally 0 to 5 (1 to 32 quad curves)
- 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:
- 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
Pointpair 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:
- 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.
RRect(rrect: skia.RRect, pathDirection: skia.PathDirection = skia.PathDirection.kCW, startIndex: int = 0) -> skia.Path
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.
__init__(self: skia.Path) -> None
__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,
Pointarray and weights are copied when modified.Creating a
Pathcopy is very efficient and never allocates memory.Pathare always copied by value from the interface; the underlying shared pointers are not exposed.- path:
Pathto 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.
- 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, appendingPathVerb.kMove, fourPathVerb.kConic, andPathVerb.kClose.Circle begins at: (x + radius, y), continuing clockwise if dir is
PathDirection.kCW, and counterclockwise if dir isPathDirection.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) –
PathDirectionto wind circle
- Return type:
- Path.addOval(*args, **kwargs)
Overloaded function.
addOval(self: skia.Path, oval: skia.Rect, dir: skia.PathDirection = skia.PathDirection.kCW) -> skia.Path
Adds oval to path, appending
kMove_Verb, fourkConic_Verb, andkClose_Verb.Oval is upright ellipse bounded by
Rectoval with radii equal to half oval width and half oval height. Oval begins at (oval.fRight, oval.centerY()) and continues clockwise if dir iskCW, counterclockwise if dir iskCCW.- oval:
bounds of ellipse added
- dir:
PathDirectionto wind ellipse- return:
reference to
Path
addOval(self: skia.Path, oval: skia.Rect, dir: skia.PathDirection, start: int) -> skia.Path
Adds oval to path, appending
kMove_Verb, fourkConic_Verb, andkClose_Verb.Oval is upright ellipse bounded by
Rectoval 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 iskCW, counterclockwise if dir iskCCW.
- Path.addPath(*args, **kwargs)
Overloaded function.
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,Pointarray, and conic weights are added unaltered. If mode iskExtend_AddPathMode, add line before appending verbs,Point, and conic weights.- src:
- dx:
offset added to src
Pointarray x-axis coordinates- dy:
offset added to src
Pointarray y-axis coordinates- mode:
refe:return: rence to
PathaddPath(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,Pointarray, and conic weights are added unaltered. If mode iskExtend_AddPathMode, add line before appending verbs,Point, and conic weights.- src:
- mode:
- return:
reference to
Path
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,Pointarray, and conic weights are added unaltered. If mode iskExtend_AddPathMode, add line before appending verbs,Point, and conic weights.- src:
- matrix:
transform applied to src
- mode:
- 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
Pointin pts. If close is true, appendskClose_VerbtoPath, connecting last and firstPointin pts.If pts is empty, append
kMove_Verbto path.
- Path.addRRect(*args, **kwargs)
Overloaded function.
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 iskCCW, rrect starts at the bottom-left of the upper-left corner and winds counterclockwise.After appending,
Pathmay be empty, or may contain:Rect, oval, orRRect.addRRect(self: skia.Path, rrect: skia.RRect, dir: skia.PathDirection, start: int) -> skia.Path
- Path.addRect(*args, **kwargs)
Overloaded function.
addRect(self: skia.Path, rect: skia.Rect, dir: skia.PathDirection = skia.PathDirection.kCW) -> skia.Path
Adds
RecttoPath, appendingkMove_Verb, threekLine_Verb, andkClose_Verb, starting with top-left corner ofRect; followed by top-right, bottom-right, and bottom-left if dir iskCW; or followed by bottom-left, bottom-right, and top-right if dir iskCCWaddRect(self: skia.Path, rect: skia.Rect, dir: skia.PathDirection, start: int) -> skia.Path
Adds
RecttoPath, appendingkMove_Verb, threekLine_Verb, and k:py:attr:~skia.Path.Verb.Close.If dir is
kCW,Rectcorners are added clockwise; if dir iskCCW,Rectcorners are added counterclockwise. start determines the first corner added.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) toPath, appendingkMove_Verb, threekLine_Verb, andkClose_Verb, starting with top-left corner ofRect; followed by top-right, bottom-right, and bottom-left if dir iskCW; or followed by bottom-left, bottom-right, and top-right if dir iskCCW.
- Path.addRoundRect(*args, **kwargs)
Overloaded function.
addRoundRect(self: skia.Path, rect: skia.Rect, rx: float, ry: float, dir: skia.PathDirection = skia.PathDirection.kCW) -> skia.Path
Appends
RRecttoPath, creating a new closed contour.RRecthas bounds equal to rect; each corner is 90 degrees of an ellipse with radii (rx, ry). If dir iskCW,RRectstarts at top-left of the lower-left corner and winds clockwise. If dir iskCCW,RRectstarts 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()appendsRectrect toPath.After appending,
Pathmay be empty, or may contain:Rect, oval, orRRect.addRoundRect(self: skia.Path, rect: skia.Rect, radii: Iterable, dir: skia.PathDirection = skia.PathDirection.kCW) -> skia.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.
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 connectingPathlastPointto initial arcPointif forceMoveTo is false andPathis 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
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
Pathpoint 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
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
Pathpoint 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
PathPointdoes not start arc,arcTo()appends connecting line toPath. 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 lastPathPointto p1.arcTo()appends at most one line and one conic.arcTo()implements the functionality of PostScript arct and HTML Canvas arcTo.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
PathPointto (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 lastPathPointequals (x, y).arcTo()scales radii (rx, ry) to fit lastPathPointand (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, whilekCWcast 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
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
PathPointto (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 lastPathPointequals (xy.fX, xy.fY).arcTo()scales radii r to fit lastPathPointand 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, whilekCWcast 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.kClosetoPath.A closed contour connects the first and last
Pointwith line, forming a continuous loop. Open and closed contour draw the same withPaint.kFill_Style. WithPaint.kStroke_Style, open contour drawsPaint.Capat contour start and end; closed contour drawsPaint.Joinat contour start and end.close()has no effect ifPathis empty or lastPathVerbisPath.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
Pathcontains no points. Returned bounds width and height may be larger or smaller than area affected whenPathis drawn.Includes
Pointassociated with kMove_Verb that define empty contours.Behaves identically to
getBounds()whenPathcontains only lines. IfPathcontains curves, computed bounds includes the maximum extent of the quad, conic, or cubic; is slower thangetBounds(); and unlikegetBounds(), does not cache the result.- Returns:
tight bounds of curves in
Path
- Path.conicTo(*args, **kwargs)
Overloaded function.
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
Pathis empty, or lastPath.VerbiskClose_Verb, last point is set to (0, 0) before adding conic.Appends
kMove_Verbto verb array and (0, 0) toPointarray, if needed.If w is finite and not one, appends
kConic_Verbto verb array; and (x1, y1), (x2, y2) toPointarray; and w to conic weights.If w is one, appends
kQuad_Verbto verb array, and (x1, y1), (x2, y2) toPointarray.If w is not finite, appends
kLine_Verbtwice to verb array, and (x1, y1), (x2, y2) toPointarray.conicTo(self: skia.Path, p1: skia.Point, p2: skia.Point, w: float) -> skia.Path
Adds conic from last point towards
Pointp1, toPointp2, weighted by w.If
Pathis empty, or lastPath.VerbiskClose_Verb, last point is set to (0, 0) before adding conic.Appends
kMove_Verbto verb array and (0, 0) toPointarray, if needed.If w is finite and not one, appends
kConic_Verbto verb array; andPointp1, p2 toPointarray; and w to conic weights.If w is one, appends
kQuad_Verbto verb array, andPointp1, p2 toPointarray.If w is not finite, appends
kLine_Verbtwice to verb array, andPointp1, p2 toPointarray.
- 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
Pathhas one contour and is convex. rect may share points and edges withPathand be contained. Returns true if rect is empty, that is, it has zero width or height; and thePointor line described by rect is contained byPath.
- 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.
- Path.countPoints(self: skia.Path) int
Returns the number of points in
Path.Pointcount is initially zero.
- Path.countVerbs(self: skia.Path) int
Returns the number of verbs:
kMove_Verb,kLine_Verb,kQuad_Verb,kConic_Verb,kCubic_Verb, andkClose_Verb; added toPath.- Returns:
length of verb array
- Path.cubicTo(*args, **kwargs)
Overloaded function.
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
Pathis empty, or lastPath.VerbiskClose_Verb, last point is set to (0, 0) before adding cubic.Appends
kMove_Verbto verb array and (0, 0) toPointarray, if needed; then appendskCubic_Verbto verb array; and (x1, y1), (x2, y2), (x3, y3) toPointarray.cubicTo(self: skia.Path, p1: skia.Point, p2: skia.Point, p3: skia.Point) -> skia.Path
Adds cubic from last point towards
Pointp1, then towardsPointp2, ending atPointp3.If
Pathis empty, or lastPath.VerbiskClose_Verb, last point is set to (0, 0) before adding cubic.Appends
kMove_Verbto verb array and (0, 0) toPointarray, if needed; then appendskCubic_Verbto verb array; andPointp1, p2, p3 toPointarray.
- Path.dump(*args, **kwargs)
Overloaded function.
dump(self: skia.Path, stream: skia.WStream, dumpAsHex: bool) -> None
dump(self: skia.Path) -> None
- Path.dumpHex(self: skia.Path) None
Writes text representation of
Pathto 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
Pointarray.Returns (0, 0, 0, 0) if
Pathcontains no points. Returned bounds width and height may be larger or smaller than area affected whenPathis drawn.Rectreturned includes allPointadded toPath, includingPointassociated withkMove_Verbthat define empty contours.
- Path.getFillType(self: skia.Path) skia.PathFillType
Returns
PathFillType, the rule used to fillPath.- Returns:
current
PathFillTypesetting
- 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,
Pointarray, or conic weight changes.Setting
Path.FillTypedoes not change generation identifier.Each time the path is modified, a different generation identifier will be returned.
Path.FillTypedoes 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
Pathin lastPt.Returns false if
Pointarray is empty, storing (0, 0) if lastPt is not nullptr.- Parameters:
lastPt (skia.Point) – storage for final
PointinPointarray; may be nullptr- Returns:
- Path.getPoint(self: skia.Path, index: int) skia.Point
Returns
Pointat index inPointarray.Valid range for index is 0 to countPoints() - 1. Returns (0, 0) if index is out of range.
- Parameters:
index (skia.Point) –
Pointarray element selector- Returns:
Pointarray 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
SegmentMaskconstant ifPathcontains one or more verbs of that type.Returns zero if
Pathcontains 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
Pathverb array,Pointarray and comics to contain extraPtCount additionalPoint.May improve performance and use less memory by reducing the number and size of allocations when creating
Path.- Parameters:
extraPtCount (int) – number of additional
Pointto allocateextraVerbCount (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
PathwithPointarray of equal size.Copy verb array and weights to out, and set out
Pointarray to a weighted average of thisPointarray and endingPointarray, using the formula: (Path Point * weight) + ending Point * (1 - weight).weight is most useful when between zero (ending
Pointarray) and one (this Point_Array); will work with values outside of this range.interpolate()returns false and leaves out unchanged ifPointarray is not the same size as endingPointarray. CallisInterpolatable()to checkPathcompatibility prior to callinginterpolate().
- 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
Pathis empty.Empty
Pathmay have FillType but has noPoint,Path.Verb, or conic weight.Path`() constructs empty :py:class:`Path;reset()andrewind()makePathempty.- Returns:
true if the path contains no
Path.Verbarray
- Path.isFinite(self: skia.Path) bool
Returns true for finite
Pointarray values between negative SK_ScalarMax and positive SK_ScalarMax.Returns false for any
Pointarray value of SK_ScalarInfinity, SK_ScalarNegativeInfinity, or SK_ScalarNaN.- Returns:
true if all
Pointvalues are finite
- Path.isInterpolatable(self: skia.Path, compare: skia.Path) bool
Returns true if
Pathcontain equal verbs and equal weights.If
Pathcontain 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 ofPathcontaining conics with different conic weight values.
- Path.isInverseFillType(self: skia.Path) bool
Returns if FillType describes area outside
Pathgeometry.The inverse fill area extends indefinitely.
- Returns:
true if FillType is
kInverseWindingorkInverseEvenOdd
- Path.isLastContourClosed(self: skia.Path) bool
Returns if contour is closed.
Contour is closed if
PathVerbarray was last modified byclose(). When stroked, closed contour drawsJoininstead ofCapat first and lastPoint.- 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
Pathcontains only one line;Verbarray has two entries:kMove_Verb,kLine_Verb.If
Pathcontains one line and line is not nullptr, line is set to line start point and line end point. Returns false ifPathis 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
Pathcontains 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.
- 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
RRectis not found.- Parameters:
rrect (skia.RRect) – storage for bounding
RectofRRect; may be nullptr- Returns:
- Path.isRect(self: skia.Path, rect: skia.Rect = None, isClosed: bool = None, direction: skia.PathDirection = None) bool
Returns true if
Pathis equivalent toRectwhen 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
Pathbounds.Pathbounds may includekMove_Verbpoints that do not alter the area drawn by the returned rect.
- Path.isValid(self: skia.Path) bool
Returns if
Pathdata is consistent.Corrupt
Pathdata is detected if internal values are out of range or internal storage does not match array dimensions.- Returns:
true if
Pathdata 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.
Pathby default have volatile set false, allowingSurfaceto attach a cache of data which speeds repeated drawing. If true,Surfacemay not speed repeated drawing.- Returns:
true if caller will alter
Pathafter drawing
- Path.lineTo(*args, **kwargs)
Overloaded function.
lineTo(self: skia.Path, x: float, y: float) -> skia.Path
Adds line from last point to (x, y).
If
Pathis empty, or lastVerbiskClose_Verb, last point is set to (0, 0) before adding line.lineTo() appends
kMove_Verbto verb array and (0, 0) toPointarray, if needed. lineTo() then appendskLine_Verbto verb array and (x, y) toPointarray.- x:
end of added line on x-axis
- y:
end of added line on y-axis
- return:
reference to
Path
lineTo(self: skia.Path, p: skia.Point) -> skia.Path
Adds line from last point to
Pointp.If
Pathis empty, or lastVerbiskClose_Verb, last point is set to (0, 0) before adding line.lineTo() appends
kMove_Verbto verb array and (0, 0) toPointarray, if needed. lineTo() then appendskLine_Verbto verb array and p toPointarray.
- Path.moveTo(*args, **kwargs)
Overloaded function.
moveTo(self: skia.Path, x: float, y: float) -> skia.Path
moveTo(self: skia.Path, p: skia.Point) -> skia.Path
- Path.offset(self: skia.Path, dx: float, dy: float, dst: skia.Path = None) None
Offsets
Pointarray by (dx, dy).Offset
Pathreplaces dst. If dst is nullptr,Pathis replaced by offset data.
- Path.quadTo(*args, **kwargs)
Overloaded function.
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
Pathis empty, or lastPath.VerbiskClose_Verb, last point is set to (0, 0) before adding quad.Appends
kMove_Verbto verb array and (0, 0) toPointarray, if needed; then appendskQuad_Verbto verb array; and (x1, y1), (x2, y2) toPointarray.quadTo(self: skia.Path, p1: skia.Point, p2: skia.Point) -> skia.Path
Adds quad from last point towards
Pointp1, toPointp2.If
Pathis empty, or lastPath.VerbiskClose_Verb, last point is set to (0, 0) before adding quad.Appends
kMove_Verbto verb array and (0, 0) toPointarray, if needed; then appendskQuad_Verbto verb array; andPointp1, p2 toPointarray.
- 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 lastPathPoint.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
PathPointto relative endPoint: (dx, dy), choosing one of four possible routes: clockwise or counterclockwise, and smaller or larger. IfPathis empty, the start arcPointis (0, 0).Arc sweep is always less than 360 degrees.
arcTo()appends line to endPointif either radii are zero, or if lastPathPointequals endPoint.arcTo()scales radii (rx, ry) to fit lastPathPointand endPointif 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, whilekCWcast 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
- 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
Pathis empty, or lastPath::Verb iskClose_Verb, last point is set to (0, 0) before adding conic.Appends
kMove_Verbto verb array and (0, 0) toPointarray, if needed.If w is finite and not one, next appends
kConic_Verbto verb array, and w is recorded as conic weight; otherwise, if w is one, appendskQuad_Verbto verb array; or if w is not finite, appendskLine_Verbtwice to verb array.In all cases appends
Pointcontrol and end toPointarray. 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
Pathis empty, or lastPath.VerbiskClose_Verb, last point is set to (0, 0) before adding cubic.Appends
kMove_Verbto verb array and (0, 0) toPointarray, if needed; then appendskCubic_Verbto verb array; and appends cubic control and cubic end toPointarray. 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
Pathis empty, or lastVerbiskClose_Verb, last point is set to (0, 0) before adding line.Appends
kMove_Verbto verb array and (0, 0) toPointarray, if needed; then appendskLine_Verbto verb array and line end toPointarray. 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
Pathis 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
Pathis empty, or lastVerbiskClose_Verb, last point is set to (0, 0) before adding quad.Appends
kMove_Verbto verb array and (0, 0) toPointarray, if needed; then appendskQuad_Verbto verb array;and appends quad control and quad end toPointarray. 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
Pathfrom buffer of size length.Returns zero if the buffer is data is inconsistent, or the length is too small.
Reads
Path.FillType, verb array,Pointarray, conic weight, and additionally reads computed information likePath.Convexityand bounds.Used only in concert with
writeToMemory(); the format used forPathin 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
Pathto its initial state.Removes verb array,
Pointarray, and weights, and sets FillType to kWinding. Internal storage associated withPathis 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.
- Path.rewind(self: skia.Path) skia.Path
Sets
Pathto its initial state, preserving internal storage.Removes verb array,
Pointarray, and weights, and sets FillType to kWinding. Internal storage associated withPathis retained.Use
rewind()instead ofreset()ifPathstorage will be reused and performance is critical.- Returns:
reference to
Path
- Path.serialize(self: skia.Path) skia.Data
Writes
Pathto buffer, returning the buffer written to, wrapped inData.serialize()writesFillType, verb array,Pointarray, conic weight, and additionally writes computed information likeConvexityand bounds.serialize()should only be used in concert withreadFromMemory(). The format used forPathin memory is not guaranteed.
- 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
Pathis volatile; whether it will be altered or discarded by the caller after it is drawn.Pathby default have volatile set false, allowingBaseDeviceto attach a cache of data which speeds repeated drawing.Mark temporary paths, discarded or modified after use, as volatile to inform
BaseDevicethat the path need not be cached.Mark animating
Pathvolatile to improve performance. Mark unchangingPathnon-volatile to improve repeated rendering.raster surface
Pathdraws are affected by volatile for some shadows. GPU surfacePathdraws are affected by volatile for some shadows and concave geometries.- Parameters:
isVolatile (bool) – true if caller will alter
Pathafter drawing
- Path.setLastPt(*args, **kwargs)
Overloaded function.
setLastPt(self: skia.Path, x: float, y: float) -> None
Sets last point to (x, y).
If
Pointarray is empty, appendkMove_Verbto verb array and append (x, y) toPointarray.- x:
set x-axis value of last point
- y:
set y-axis value of last point
setLastPt(self: skia.Path, p: skia.Point) -> None
Sets the last point on the path.
If
Pointarray is empty, appendkMove_Verbto verb array and append p toPointarray.- p:
set value of last point
- Path.swap(self: skia.Path, other: skia.Path) None
Exchanges the verb array,
Pointarray, weights, andPathFillTypewith other.Cached state is also exchanged.
swap()internally exchanges pointers, so it is lightweight and does not allocate memory.
- 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,
Pointarray, and weight by matrix.transform may change verbs and increase their number. Transformed
Pathreplaces dst; if dst is nullptr, original data is replaced.- Parameters:
matrix (skia.Matrix) –
Matrixto apply toPathdst (skia.Path) – overwritten, transformed copy of
Path; may be nullptrpc (skia.ApplyPerspectiveClip) – whether to apply perspective clipping
- Path.updateBoundsCache(self: skia.Path) None
Updates internal bounds so that subsequent calls to
getBounds()are instantaneous.Unaltered copies of
Pathmay also access cached bounds throughgetBounds().For now, identical to calling
getBounds()and ignoring the returned value.Call to prepare
Pathsubsequently drawn from multiple threads, to avoid a race condition where each draw separately computes the bounds.
- Path.writeToMemory(self: skia.Path) bytes
Writes
Pathto buffer, returning bytes.Writes
FillType, verb array,Pointarray, conic weight, and additionally writes computed information likeConvexityand bounds.Use only be used in concert with
readFromMemory(); the format used forPathin 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>