SourceClass Path
from skia import Pathclass 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 convexity.
Constants§
AddMode: Final[type]§
ArcSize: Final[type]§
Direction: Final[type]§
FillType: Final[type]§
Properties§
Source@property
def fill_type(self, /) -> PathFillType§
Returns PathFillType, the rule used to fill Path.
Returns: current PathFillType setting
Source@fill_type.setter
def fill_type(self, /, value: 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.
Methods§
def clone(self, /) -> Path§
Sourcedef compute_tight_bounds(self, /) -> 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 Point2d associated with Verb.Move that define empty
contours.
Behaves identically to bounds() when Path contains
only lines. If Path contains curves, computed bounds includes
the maximum extent of the quad, conic, or cubic; is slower than bounds();
and unlike bounds(), does not cache the result.
Returns: tight bounds of curves in Path
Example (C++): https://fiddle.skia.org/c/@Path_computeTightBounds
Sourcedef contains(self, /, x: float, y: float) -> bool§
Returns True if the point is contained by Path, taking into
account PathFillType.
Sourcedef count_points(self, /) -> int§
Sourcedef count_verbs(self, /) -> int§
@classmethod
def from_svg(cls, /, text: str) -> Path§
def get_bounds(self, /) -> Rect§
def get_last_point(self, /) -> Any |None§
Sourcedef get_point(self, /, index: int) -> Any |None§
Sourcedef get_points(self, /) -> list[Any]§
Returns number of points in Path.
Copies N points from the path into the span, where N = min(#points, span capacity)
DEPRECATED
Returns: the number of points in the path
Sourcedef is_convex(self, /) -> bool§
Returns True if the path is convex. If necessary, it will first compute the convexity.
Sourcedef is_empty(self, /) -> bool§
Sourcedef is_line(self, /) -> tuple[tuple[float, float], tuple[float, float]] |None§
Returns True if Path contains only one line;
Verb array has two entries: Verb.Move, Verb.Line.
If Path contains one line and line is not None, line is set to
line start point and line end point.
Returns False if Path is not one line; line is unaltered.
line- storage for line. May beNone
Returns: True if Path contains exactly one line
Example (C++): https://fiddle.skia.org/c/@Path_isLine
Sourcedef is_oval(self, /) -> Rect |None§
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.
bounds- storage for boundingRectof oval; may beNone
Returns: True if Path is recognized as an oval or circle
Example (C++): https://fiddle.skia.org/c/@Path_isOval
Sourcedef is_rect(self, /) -> tuple[Rect, bool, PathDirection] |None§
Returns Some(Rect, bool, PathDirection) if Path is equivalent to Rect when filled.
If False: rect, is_closed, and direction are unchanged.
If True: rect, is_closed, and direction are written to.
rect may be smaller than the Path bounds. Path bounds may include Verb.Move points
that do not alter the area drawn by the returned rect.
Returns: Some(rect, is_closed, direction) if Path contains Rect
* rect - bounds of Rect
* is_closed - set to True if Path is closed
* direction - to Rect direction
Example (C++): https://fiddle.skia.org/c/@Path_isRect
Sourcedef is_rrect(self, /) -> RoundRect |None§
Sourcedef reset(self, /) -> None§
Sets Path to its initial state.
Removes verb array, Point2d array, and weights, and sets FillType to Winding.
Internal storage associated with Path is released.
Returns: reference to Path
Example (C++): https://fiddle.skia.org/c/@Path_reset