Path
Category | refcounted |
Type | hime_path_t |
Inherits | Object |
A ref-counted wrapper of SkPath.
SkPath contain geometry. SkPath may be empty, or contain one or more verbs that outline a figure. SkPath 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. SkPath may contain any number of contours, each beginning with a move verb.
SkPath contours may contain only a move verb, or may also contain lines, quadratic beziers, conics, and cubic beziers. SkPath contours may be open or closed.
When used to draw a filled area, SkPath describes whether the fill is inside or outside the geometry. SkPath also describes the winding rule used to fill overlapping contours.
Constructors
hime_path_t hime_path_create()
Create an empty SkPath.
By default, SkPath has no verbs, no SkPoint, and no weights. FillType is set to kWinding.
Return
hime_path_t
Methods
void hime_path_reset(self)
Set SkPath to its initial state.
Remove verb array, SkPoint array, and weights, and sets FillType to kWinding. Internal storage associated with SkPath is released.
Parameters
hime_path_t
self
Return
void
bool hime_path_is_empty(self)
Return if SkPath is empty.
Parameters
hime_path_t
self
Return
bool
void hime_path_close(self)
Append kClose_Verb to SkPath.
Parameters
hime_path_t
self
Return
void
void hime_path_move_to(self, point)
Add beginning of contour at point
.
Parameters
hime_path_t
selfhime_pointf_t
point
Return
void
void hime_path_line_to(self, point)
Add line from last point to point
.
Parameters
hime_path_t
selfhime_pointf_t
point
Return
void
void hime_path_quad_to(self, point1, point2)
Add quad from last point towards point1
, to point2
.
Parameters
hime_path_t
selfhime_pointf_t
point1hime_pointf_t
point2
Return
void
void hime_path_conic_to(self, point1, point2, weight)
Add conic from last point towards point1
, to point2
, weighted by
weight
.
Parameters
hime_path_t
selfhime_pointf_t
point1hime_pointf_t
point2float
weight
Return
void
void hime_path_cubic_to(self, point1, point2, point3)
Add cubic from last point towards point1
, then towards point2
, ending
at point3
.
Parameters
hime_path_t
selfhime_pointf_t
point1hime_pointf_t
point2hime_pointf_t
point3
Return
void
void hime_path_arc_to(self, point, rx, ry, rotate, arc_size, sweep)
Append arc to SkPath.
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 SkPath point
, choosing one of four possible routes: clockwise or
counterclockwise, and smaller or larger.
Arc sweep is always less than 360 degrees. arcTo() appends line to (x, y) if either radii are zero, or if last SkPath SkPoint equals (x, y). arcTo() scales radii (rx, ry) to fit last SkPath SkPoint and (x, y) if both are greater than zero but too small.
Parameters
hime_path_t
selfhime_pointf_t
point - End of arc.float
rx - Radius on x-axis before x-axis rotation.float
ry - Radius on y-axis before x-axis rotation.float
rotate - X-axis rotation in degrees; positive values are clockwise.hime_path_arc_size_t
arc_size - Choose smaller or larger arc.hime_path_direction_t
sweep - Choose clockwise or counterclockwise arc.
Return
void
void hime_path_arc_to_with_oval(self, oval, start_angle, sweep_angle, force_move_to)
Parameters
hime_path_t
selfhime_rectf_t
oval - Bounds of ellipse containing arc.float
start_angle - Starting angle of arc in degrees.float
sweep_angle - Sweep in degrees. Positive is clockwise.bool
force_move_to - Set true to start a new contour with arc.
Return
void
void hime_path_arc_to_with_points(self, point1, point2, weight)
Append arc to SkPath, after appending line if needed. Arc is implemented
by conic weighted to describe part of circle. Arc is contained by tangent
from last SkPath point to point1
, and tangent from point1
to point2
.
Arc is part of circle sized to radius
, positioned so it touches both
tangent lines.
Parameters
hime_path_t
selfhime_pointf_t
point1hime_pointf_t
point2float
weight
Return
void
void hime_path_add_rect(self, rect, direction, start)
Add a new contour to the path, defined by the rect, and wound in the specified direction. The verbs added to the path will be:
kMove, kLine, kLine, kLine, kClose
start specifies which corner to begin the contour: 0: upper-left corner 1: upper-right corner 2: lower-right corner 3: lower-left corner
This start point also acts as the implied beginning of the subsequent, contour, if it does not have an explicit moveTo().
Parameters
hime_path_t
selfhime_rectf_t
rect - The rectangel to add as a closed contour.hime_path_direction_t
direction - Direction to orient the new contour.unsigned
start - Initial corner of rect to add.
Return
void
void hime_path_add_oval(self, oval, direction, start)
Add oval to SkPath.
Oval is upright ellipse bounded by SkRect oval with radii equal to half
oval width and half oval height. Oval begins at start and continues
clockwise if direction
is CW
, counterclockwise if direction
is
CCW
.
Parameters
hime_path_t
selfhime_rectf_t
oval - Bounds of ellipse added.hime_path_direction_t
direction - Direction to wind ellipse.unsigned
start - Index of initial point of ellipse.
Return
void
void hime_path_add_circle(self, center, radius, direction)
Add circle centered at (x, y) of size radius to SkPath.
Circle begins at (x + radius, y), continuing clockwise if direction
is
CW
, and counterclockwise if direction
is CCW
.
Has no effect if radius is zero or negative.
Parameters
hime_path_t
selfhime_pointf_t
center - Center of circle.float
radius - Distance from center to edge.hime_path_direction_t
direction - Direction to wind circle.
Return
void
void hime_path_add_arc(self, oval, start_angle, sweep_angle)
Append arc to SkPath, as the start of new contour.
Arc added is part of ellipse bounded by oval, from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees is aligned with the positive x-axis, and positive sweeps extends arc clockwise.
If sweepAngle <= -360, or sweepAngle >= 360; and startAngle modulo 90 is nearly zero, append oval instead of arc. Otherwise, sweepAngle values are treated modulo 360, and arc may or may not draw depending on numeric rounding.
Parameters
hime_path_t
selfhime_rectf_t
oval - Bounds of ellipse containing arc.float
start_angle - Starting angle of arc in degrees.float
sweep_angle - Sweep in degrees. Positive is clockwise.
Return
void
void hime_path_add_round_rect(self, rect, rx, ry, direction)
Append SkRRect to SkPath, creating a new closed contour.
SkRRect has bounds equal to rect; each corner is 90 degrees of an
ellipse with radii (rx, ry). If direction
is CW
, SkRRect starts at
top-left of the lower-left corner and winds clockwise. If direction
is
CCW
, SkRRect starts at the bottom-left of the upper-left corner and
winds counterclockwise.
If either rx
or ry
is too large, rx
and ry
are scaled uniformly
until the corners fit. If rx
or ry
is less than or equal to zero,
AddRoundRect
appends SkRect rect to SkPath.
After appending, SkPath may be empty, or may contain SkRect, oval, or SkRRect.
Parameters
hime_path_t
selfhime_rectf_t
rect - The rectangel to add as a closed contour.float
rx - X-axis radius of rounded corners on the SkRRect.float
ry - Y-axis radius of rounded corners on the SkRRect.hime_path_direction_t
direction - Direction to wind SkRRect.
Return
void