use crate::Path;
use skia_rs_core::{Matrix, Point, Scalar};
#[derive(Debug)]
pub struct PathMeasure {
path: Path,
contour_lengths: Vec<Scalar>,
total_length: Scalar,
}
impl PathMeasure {
pub fn new(path: &Path) -> Self {
let mut measure = Self {
path: path.clone(),
contour_lengths: Vec::new(),
total_length: 0.0,
};
measure.compute_lengths();
measure
}
#[inline]
pub fn length(&self) -> Scalar {
self.total_length
}
#[inline]
pub fn contour_count(&self) -> usize {
self.contour_lengths.len()
}
pub fn contour_length(&self, index: usize) -> Option<Scalar> {
self.contour_lengths.get(index).copied()
}
pub fn get_point_at(&self, distance: Scalar) -> Option<Point> {
if distance < 0.0 || distance > self.total_length {
return None;
}
let _ = distance;
None
}
pub fn get_tangent_at(&self, distance: Scalar) -> Option<Point> {
if distance < 0.0 || distance > self.total_length {
return None;
}
let _ = distance;
None
}
pub fn get_matrix_at(&self, distance: Scalar) -> Option<Matrix> {
if distance < 0.0 || distance > self.total_length {
return None;
}
let _ = distance;
None
}
pub fn get_segment(&self, start: Scalar, end: Scalar) -> Option<Path> {
if start >= end || start < 0.0 || end > self.total_length {
return None;
}
let _ = (start, end);
None
}
fn compute_lengths(&mut self) {
self.total_length = 0.0;
}
}