skia_safe::path_measure

Type Alias PathMeasure

Source
pub type PathMeasure = Handle<SkPathMeasure>;

Aliased Type§

struct PathMeasure(/* private fields */);

Implementations§

Source§

impl PathMeasure

Warning: Even if you pass in a PathMeasure with multiple contours, most of this struct’s functions, including length only return the value for the first contour on the path (which is why they aren’t const). You must exhaust PathMeasure::next_contour.

use skia_safe::{PathMeasure, Point, Path};
use std::f64::consts::PI;
let mut path = Path::circle((0., 0.), 10.0, None);
path.add_path(&Path::circle((100., 100.), 27.0, None), Point::default(), None);
let mut measure = PathMeasure::new(&path, false, None);
let mut lengths = vec![measure.length()];
while measure.next_contour() {
    lengths.push(measure.length());
}
assert_eq!(*lengths.first().unwrap() as i64, (2. * PI * 10.0) as i64);
assert_eq!(*lengths.get(1).unwrap() as i64, (2. * PI * 27.0) as i64);
eprintln!("Circle lengths: {:?}", &lengths);
Source

pub fn new( path: &Path, force_closed: bool, res_scale: impl Into<Option<scalar>>, ) -> Self

Source

pub fn from_path( path: &Path, force_closed: bool, res_scale: impl Into<Option<scalar>>, ) -> Self

👎Deprecated since 0.48.0: Use PathMeasure::new
Source

pub fn set_path(&mut self, path: &Path, force_closed: bool) -> &mut Self

Source

pub fn length(&mut self) -> scalar

Source

pub fn pos_tan(&mut self, distance: scalar) -> Option<(Point, Vector)>

Source

pub fn matrix( &mut self, distance: scalar, flags: impl Into<Option<MatrixFlags>>, ) -> Option<Matrix>

Source

pub fn segment( &mut self, start_d: scalar, stop_d: scalar, start_with_move_to: bool, ) -> Option<Path>

Source

pub fn is_closed(&mut self) -> bool

Source

pub fn next_contour(&mut self) -> bool

Source

pub fn current_measure(&self) -> &Option<ContourMeasure>

Trait Implementations§

Source§

impl Debug for PathMeasure

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PathMeasure

Source§

fn default() -> Self

Returns the “default value” for a type. Read more