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. CallPath.updateBoundsCache()
to makePath
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
Members:
Members:
Iterates through verb array, and associated
Point
array and conic weight.Iterates through verb array, and associated
Point
array and conic weight.Members:
Members:
Methods
Approximates conic with quad array.
Tests if cubic is degenerate.
Tests if line between
Point
pair is degenerate.Tests if quad is degenerate.
Create a new path with the specified segments.
Overloaded function.
Overloaded function.
Appends arc to
Path
, as the start of new contour.Adds circle centered at (x, y) of size radius to
Path
, appendingPathVerb.kMove
, fourPathVerb.kConic
, andPathVerb.kClose
.Overloaded function.
Overloaded function.
Adds contour created from pts.
Overloaded function.
Overloaded function.
Overloaded function.
Returns the approximate byte size of the SkPath in memory.
Overloaded function.
Appends
Path.Verb.kClose
toPath
.Returns minimum and maximum axes values of the lines and curves in
Path
.Overloaded function.
Returns true if rect is contained by
Path
.Returns true if the point (x, y) is contained by
Path
, taking into account FillType.Returns the number of points in
Path
.Returns the number of verbs:
kMove_Verb
,kLine_Verb
,kQuad_Verb
,kConic_Verb
,kCubic_Verb
, andkClose_Verb
; added toPath
.Overloaded function.
Overloaded function.
Writes text representation of
Path
to standard output.Returns minimum and maximum axes values of
Point
array.Returns
PathFillType
, the rule used to fillPath
.(See Skia bug 1762.) Returns a non-zero, globally unique value.
Returns last point on
Path
in lastPt.Returns number of points in
Path
.Returns a mask, where each set bit corresponds to a
SegmentMask
constant ifPath
contains one or more verbs of that type.Returns verbs in the path.
Grows
Path
verb array,Point
array and comics to contain extraPtCount additionalPoint
.Returns true if the path is convex.
Returns if
Path
is empty.Returns true for finite
Point
array values between negative SK_ScalarMax and positive SK_ScalarMax.Returns true if
Path
contain equal verbs and equal weights.Returns if FillType describes area outside
Path
geometry.Returns if contour is closed.
Returns true if
Path
contains only one line;Verb
array has two entries:kMove_Verb
,kLine_Verb
.Returns true if this path is recognized as an oval or circle.
Returns true if path is representable as
RRect
.Returns if
Path
data is consistent.Returns true if the path is volatile; it will not be altered or discarded by the caller after it is drawn.
Overloaded function.
Overloaded function.
Offsets
Point
array by (dx, dy).Overloaded function.
Adds conic from last point towards vector (dx1, dy1), to vector (dx2, dy2), weighted by w.
Adds cubic from last point towards vector (dx1, dy1), then towards vector (dx2, dy2), to vector (dx3, dy3).
Adds line from last point to vector (dx, dy).
Adds beginning of contour relative to last point.
Adds quad from last point towards vector (dx1, dy1), to vector (dx2, dy2).
Initializes
Path
from buffer of size length.Sets
Path
to its initial state.Appends src to
Path
, from back to front.Sets
Path
to its initial state, preserving internal storage.Writes
Path
to buffer, returning the buffer written to, wrapped inData
.Sets FillType, the rule used to fill
Path
.Specifies whether
Path
is volatile; whether it will be altered or discarded by the caller after it is drawn.Overloaded function.
Exchanges the verb array,
Point
array, weights, andPathFillType
with other.Replaces FillType with its inverse.
Transforms verb array,
Point
array, and weight by matrix.Updates internal bounds so that subsequent calls to
getBounds()
are instantaneous.Writes
Path
to buffer, returning 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
Point
p0, controlPoint
p1, endPoint
p2, and weight w. Maximum quad count is 2 to the pow2. Every third point in array shares lastPoint
of previous quad and firstPoint
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:
p0 (skia.Point) – conic start
Point
p1 (skia.Point) – conic control
Point
p2 (skia.Point) – conic end
Point
w (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
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:
- 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,
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.
- 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) –
PathDirection
to 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
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 iskCW
, counterclockwise if dir iskCCW
.- oval:
bounds of ellipse added
- dir:
PathDirection
to 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
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 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,Point
array, 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
Point
array x-axis coordinates- dy:
offset added to src
Point
array y-axis coordinates- mode:
refe:return: rence to
Path
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 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,Point
array, 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
Point
in pts. If close is true, appendskClose_Verb
toPath
, connecting last and firstPoint
in pts.If pts is empty, append
kMove_Verb
to 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,
Path
may 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
Rect
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
addRect(self: skia.Path, rect: skia.Rect, dir: skia.PathDirection, start: int) -> skia.Path
Adds
Rect
toPath
, appendingkMove_Verb
, threekLine_Verb
, and k:py:attr:~skia.Path.Verb.Close.If dir is
kCW
,Rect
corners are added clockwise; if dir iskCCW
,Rect
corners 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
RRect
toPath
, 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 iskCW
,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.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()
appendsRect
rect toPath
.After appending,
Path
may 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 connectingPath
lastPoint
to initial arcPoint
if forceMoveTo is false andPath
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
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
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 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 lastPath
Point
to 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
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 lastPath
Point
equals (x, y).arcTo()
scales radii (rx, ry) to fit lastPath
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, whilekCW
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
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 lastPath
Point
equals (xy.fX, xy.fY).arcTo()
scales radii r to fit lastPath
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, whilekCW
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
toPath
.A closed contour connects the first and last
Point
with line, forming a continuous loop. Open and closed contour draw the same withPaint.kFill_Style
. WithPaint.kStroke_Style
, open contour drawsPaint.Cap
at contour start and end; closed contour drawsPaint.Join
at contour start and end.close()
has no effect ifPath
is empty or lastPath
Verb
isPath.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 whenPath
is drawn.Includes
Point
associated with kMove_Verb that define empty contours.Behaves identically to
getBounds()
whenPath
contains only lines. IfPath
contains curves, computed bounds includes the maximum extent of the quad, conic, or cubic; is slower thangetBounds()
; and unlikegetBounds()
, does not cache the result.- Returns:
tight bounds of curves in
Path
- 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
Path
is empty, or lastPath.Verb
iskClose_Verb
, last point is set to (0, 0) before adding conic.Appends
kMove_Verb
to verb array and (0, 0) toPoint
array, if needed.If w is finite and not one, appends
kConic_Verb
to verb array; and (x1, y1), (x2, y2) toPoint
array; and w to conic weights.If w is one, appends
kQuad_Verb
to verb array, and (x1, y1), (x2, y2) toPoint
array.If w is not finite, appends
kLine_Verb
twice to verb array, and (x1, y1), (x2, y2) toPoint
array.conicTo(self: skia.Path, p1: skia.Point, p2: skia.Point, w: float) -> skia.Path
Adds conic from last point towards
Point
p1, toPoint
p2, weighted by w.If
Path
is empty, or lastPath.Verb
iskClose_Verb
, last point is set to (0, 0) before adding conic.Appends
kMove_Verb
to verb array and (0, 0) toPoint
array, if needed.If w is finite and not one, appends
kConic_Verb
to verb array; andPoint
p1, p2 toPoint
array; and w to conic weights.If w is one, appends
kQuad_Verb
to verb array, andPoint
p1, p2 toPoint
array.If w is not finite, appends
kLine_Verb
twice to verb array, andPoint
p1, p2 toPoint
array.
- 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 withPath
and be contained. Returns true if rect is empty, that is, it has zero width or height; and thePoint
or 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
.Point
count 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
Path
is empty, or lastPath.Verb
iskClose_Verb
, last point is set to (0, 0) before adding cubic.Appends
kMove_Verb
to verb array and (0, 0) toPoint
array, if needed; then appendskCubic_Verb
to verb array; and (x1, y1), (x2, y2), (x3, y3) toPoint
array.cubicTo(self: skia.Path, p1: skia.Point, p2: skia.Point, p3: skia.Point) -> skia.Path
Adds cubic from last point towards
Point
p1, then towardsPoint
p2, ending atPoint
p3.If
Path
is empty, or lastPath.Verb
iskClose_Verb
, last point is set to (0, 0) before adding cubic.Appends
kMove_Verb
to verb array and (0, 0) toPoint
array, if needed; then appendskCubic_Verb
to verb array; andPoint
p1, p2, p3 toPoint
array.
- 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
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 whenPath
is drawn.Rect
returned includes allPoint
added toPath
, includingPoint
associated withkMove_Verb
that define empty contours.
- Path.getFillType(self: skia.Path) skia.PathFillType
Returns
PathFillType
, the rule used to fillPath
.- 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
inPoint
array; may be nullptr- Returns:
- Path.getPoint(self: skia.Path, index: int) skia.Point
Returns
Point
at index inPoint
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 ifPath
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 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
Point
to 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
Path
withPoint
array of equal size.Copy verb array and weights to out, and set out
Point
array to a weighted average of thisPoint
array and endingPoint
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 ifPoint
array is not the same size as endingPoint
array. CallisInterpolatable()
to checkPath
compatibility 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
Path
is empty.Empty
Path
may have FillType but has noPoint
,Path.Verb
, or conic weight.Path`() constructs empty :py:class:`Path
;reset()
andrewind()
makePath
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 ofPath
containing conics with different conic weight values.
- 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
orkInverseEvenOdd
- Path.isLastContourClosed(self: skia.Path) bool
Returns if contour is closed.
Contour is closed if
Path
Verb
array was last modified byclose()
. When stroked, closed contour drawsJoin
instead ofCap
at 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
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 ifPath
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.
- 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
ofRRect
; may be nullptr- Returns:
- Path.isRect(self: skia.Path, rect: skia.Rect = None, isClosed: bool = None, direction: skia.PathDirection = None) bool
Returns true if
Path
is equivalent toRect
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 includekMove_Verb
points that do not alter the area drawn by the returned 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, allowingSurface
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.
lineTo(self: skia.Path, x: float, y: float) -> skia.Path
Adds line from last point to (x, y).
If
Path
is empty, or lastVerb
iskClose_Verb
, last point is set to (0, 0) before adding line.lineTo() appends
kMove_Verb
to verb array and (0, 0) toPoint
array, if needed. lineTo() then appendskLine_Verb
to verb array and (x, y) toPoint
array.- 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
Point
p.If
Path
is empty, or lastVerb
iskClose_Verb
, last point is set to (0, 0) before adding line.lineTo() appends
kMove_Verb
to verb array and (0, 0) toPoint
array, if needed. lineTo() then appendskLine_Verb
to verb array and p toPoint
array.
- 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
Point
array by (dx, dy).Offset
Path
replaces dst. If dst is nullptr,Path
is 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
Path
is empty, or lastPath.Verb
iskClose_Verb
, last point is set to (0, 0) before adding quad.Appends
kMove_Verb
to verb array and (0, 0) toPoint
array, if needed; then appendskQuad_Verb
to verb array; and (x1, y1), (x2, y2) toPoint
array.quadTo(self: skia.Path, p1: skia.Point, p2: skia.Point) -> skia.Path
Adds quad from last point towards
Point
p1, toPoint
p2.If
Path
is empty, or lastPath.Verb
iskClose_Verb
, last point is set to (0, 0) before adding quad.Appends
kMove_Verb
to verb array and (0, 0) toPoint
array, if needed; then appendskQuad_Verb
to verb array; andPoint
p1, p2 toPoint
array.
- 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 lastPath
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 endPoint
: (dx, dy), choosing one of four possible routes: clockwise or counterclockwise, and smaller or larger. IfPath
is empty, the start arcPoint
is (0, 0).Arc sweep is always less than 360 degrees.
arcTo()
appends line to endPoint
if either radii are zero, or if lastPath
Point
equals endPoint
.arcTo()
scales radii (rx, ry) to fit lastPath
Point
and endPoint
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, whilekCW
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
- 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 lastPath
::Verb iskClose_Verb
, last point is set to (0, 0) before adding conic.Appends
kMove_Verb
to verb array and (0, 0) toPoint
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, appendskQuad_Verb
to verb array; or if w is not finite, appendskLine_Verb
twice to verb array.In all cases appends
Point
control and end toPoint
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 lastPath.Verb
iskClose_Verb
, last point is set to (0, 0) before adding cubic.Appends
kMove_Verb
to verb array and (0, 0) toPoint
array, if needed; then appendskCubic_Verb
to verb array; and appends cubic control and cubic end toPoint
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 lastVerb
iskClose_Verb
, last point is set to (0, 0) before adding line.Appends
kMove_Verb
to verb array and (0, 0) toPoint
array, if needed; then appendskLine_Verb
to verb array and line end toPoint
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 lastVerb
iskClose_Verb
, last point is set to (0, 0) before adding quad.Appends
kMove_Verb
to verb array and (0, 0) toPoint
array, if needed; then appendskQuad_Verb
to verb array;and appends quad control and quad end toPoint
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 likePath.Convexity
and bounds.Used only in concert with
writeToMemory()
; the format used forPath
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 withPath
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
.
- 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 withPath
is retained.Use
rewind()
instead ofreset()
ifPath
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 inData
.serialize()
writesFillType
, verb array,Point
array, conic weight, and additionally writes computed information likeConvexity
and bounds.serialize()
should only be used in concert withreadFromMemory()
. The format used forPath
in 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
Path
is volatile; whether it will be altered or discarded by the caller after it is drawn.Path
by default have volatile set false, allowingBaseDevice
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 unchangingPath
non-volatile to improve repeated rendering.raster surface
Path
draws are affected by volatile for some shadows. GPU surfacePath
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.
setLastPt(self: skia.Path, x: float, y: float) -> None
Sets last point to (x, y).
If
Point
array is empty, appendkMove_Verb
to verb array and append (x, y) toPoint
array.- 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
Point
array is empty, appendkMove_Verb
to verb array and append p toPoint
array.- p:
set value of last point
- Path.swap(self: skia.Path, other: skia.Path) None
Exchanges the verb array,
Point
array, weights, andPathFillType
with 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,
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:
matrix (skia.Matrix) –
Matrix
to apply toPath
dst (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
Path
may also access cached bounds throughgetBounds()
.For now, identical to calling
getBounds()
and ignoring the returned value.Call to prepare
Path
subsequently drawn from multiple threads, to avoid a race condition where each draw separately computes the bounds.
- 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 likeConvexity
and bounds.Use only be used in concert with
readFromMemory()
; the format used forPath
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>