pub type PathMeasure = Handle<SkPathMeasure>;
Aliased Type§
struct PathMeasure(/* private fields */);
Implementations§
Source§impl PathMeasure
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);
pub fn new( path: &Path, force_closed: bool, res_scale: impl Into<Option<scalar>>, ) -> Self
pub fn from_path( path: &Path, force_closed: bool, res_scale: impl Into<Option<scalar>>, ) -> Self
👎Deprecated since 0.48.0: Use PathMeasure::new