Type Alias PathMeasure

pub type PathMeasure = Handle<SkPathMeasure>;

Aliased Type§

struct PathMeasure(/* private fields */);

Implementations

§

impl Handle<SkPathMeasure>

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);

pub fn new( path: &Handle<SkPath>, force_closed: bool, res_scale: impl Into<Option<f32>>, ) -> Handle<SkPathMeasure>

pub fn from_path( path: &Handle<SkPath>, force_closed: bool, res_scale: impl Into<Option<f32>>, ) -> Handle<SkPathMeasure>

👎Deprecated since 0.48.0: Use PathMeasure::new

pub fn set_path( &mut self, path: &Handle<SkPath>, force_closed: bool, ) -> &mut Handle<SkPathMeasure>

pub fn length(&mut self) -> f32

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

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

pub fn segment( &mut self, start_d: f32, stop_d: f32, start_with_move_to: bool, ) -> Option<Handle<SkPath>>

pub fn is_closed(&mut self) -> bool

pub fn next_contour(&mut self) -> bool

pub fn current_measure(&self) -> &Option<RCHandle<SkContourMeasure>>

Trait Implementations

§

impl<N> AsRef<Handle<N>> for Handle<N>
where N: NativeDrop,

§

fn as_ref(&self) -> &Handle<N>

Converts this type into a shared reference of the (usually inferred) input type.
§

impl<N> Clone for Handle<N>
where N: NativeDrop + NativeClone,

§

fn clone(&self) -> Handle<N>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Handle<SkPathMeasure>

§

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

Formats the value using the given formatter. Read more
§

impl Default for Handle<SkPathMeasure>

§

fn default() -> Handle<SkPathMeasure>

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

impl<N> Drop for Handle<N>
where N: NativeDrop,

§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

impl<N> Hash for Handle<N>
where N: NativeDrop + NativeHash,

§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl<N> PartialEq for Handle<N>
where N: NativeDrop + NativePartialEq,

§

fn eq(&self, rhs: &Handle<N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<N> RefWrapper<N> for Handle<N>
where N: NativeDrop,

§

fn wrap_ref(native: &N) -> &Handle<N>

§

fn wrap_mut(native: &mut N) -> &mut Handle<N>

§

fn inner(&self) -> &N

§

fn inner_mut(&mut self) -> &mut N

§

impl<N> ValueWrapper<N> for Handle<N>
where N: NativeDrop,

§

fn wrap(native: N) -> Handle<N>
where N: NativeDrop,

§

fn unwrap(self) -> N

§

fn inner(&self) -> &N

§

fn inner_mut(&mut self) -> &mut N