pub struct Path { /* private fields */ }Expand description
A vector path: a sequence of PathVerb. Built in builder style (chainable),
and consumed at render time.
use frus_core::{Path, Point};
let triangle = Path::new()
.move_to(Point::new(0.0, 0.0))
.line_to(Point::new(10.0, 0.0))
.line_to(Point::new(5.0, 8.0))
.close();
assert_eq!(triangle.verbs().len(), 4);Implementations§
Source§impl Path
impl Path
Sourcepub fn with_fill_rule(self, rule: FillRule) -> Self
pub fn with_fill_rule(self, rule: FillRule) -> Self
The same path, filled by rule.
Sourcepub fn quad_to(self, ctrl: Point, to: Point) -> Self
pub fn quad_to(self, ctrl: Point, to: Point) -> Self
A quadratic curve (one control point, ctrl) to to.
Sourcepub fn cubic_to(self, c1: Point, c2: Point, to: Point) -> Self
pub fn cubic_to(self, c1: Point, c2: Point, to: Point) -> Self
A cubic curve (two control points, c1 and c2) to to.
Sourcepub fn append(self, other: Path) -> Self
pub fn append(self, other: Path) -> Self
This path and then other, as one: under the even-odd rule a path inside another
is a hole in it, which is how a band is drawn.
Sourcepub fn arc_to(self, center: Point, radius: f32, start: f32, end: f32) -> Self
pub fn arc_to(self, center: Point, radius: f32, start: f32, end: f32) -> Self
Continues the path along a circular arc, from start to end (radians,
measured from the positive x axis, y downwards), around center.
The current point is assumed to be the arc’s start; nothing moves it there,
because an arc that jumped to its own beginning could not be part of an
outline. Approximated by cubics, split so that no piece spans more than a
quarter turn — which is where the constant used by Path::circle stops
being accurate enough.
Sourcepub fn circle(center: Point, radius: f32) -> Self
pub fn circle(center: Point, radius: f32) -> Self
A circle, approximated by four cubic arcs (the Bézier constant 0.5523,
which is exact at the nodes).
Sourcepub fn oval(r: Rect) -> Self
pub fn oval(r: Rect) -> Self
An ellipse inscribed in r, by the same four-cubic approximation as
Path::circle — which it generalises: a square r gives that circle back.
A circle scaled along one axis, in other words, without needing a transform to say so: it is how a wide, shallow arc (an overscroll glow, a soft highlight) is drawn as a plain filled path.
Sourcepub fn scaled(&self, factor: f32) -> Path
pub fn scaled(&self, factor: f32) -> Path
A copy scaled by factor about the origin — used for logical-to-physical
conversion, or to fit a 24×24 icon to its real size.
Sourcepub fn translated(&self, dx: f32, dy: f32) -> Path
pub fn translated(&self, dx: f32, dy: f32) -> Path
A copy translated by (dx, dy) — used to place an icon inside its box.
Sourcepub fn mirrored_x(&self, axis: f32) -> Path
pub fn mirrored_x(&self, axis: f32) -> Path
A copy reflected in the vertical line x = axis — how an icon that carries a
direction (an arrow, an indent, a reply) is turned round for a right-to-left
reading order.
The reflection reverses each contour’s winding, and reverses every contour, so a shape’s holes stay holes: the non-zero rule cares about the relative direction of the contours, not about their absolute one.
Sourcepub fn rotated(&self, center: Point, radians: f32) -> Path
pub fn rotated(&self, center: Point, radians: f32) -> Path
A copy turned by radians about center, clockwise — y points down here, so a
positive angle turns the way a clock’s hand does.
Unlike a reflection, a rotation keeps each contour’s winding, so a shape’s holes stay holes without anything else being done about it. Bézier control points turn with their curve, which is exact: an affine map of a Bézier’s control polygon is the same Bézier mapped.
The sine and cosine are taken once for the whole path rather than per point.