use crate::Point;
pub const DEFAULT_TENSION: f64 = 0.5;
pub const DEFAULT_SEGMENTS: u32 = 16;
#[derive(Clone)]
pub struct SplineOpts {
tension: f64,
num_of_segments: u32,
hidden_point_at_start: Option<Point>,
hidden_point_at_end: Option<Point>,
}
impl SplineOpts {
pub fn new() -> Self {
SplineOpts::default()
}
pub fn tension(mut self, val: f64) -> Self {
self.tension = val;
self
}
pub fn num_of_segments(mut self, val: u32) -> Self {
self.num_of_segments = val;
self
}
pub fn hidden_point_at_start<T: Into<Point>>(mut self, val: T) -> Self {
self.hidden_point_at_start = Some(val.into());
self
}
pub fn hidden_point_at_end<T: Into<Point>>(mut self, val: T) -> Self {
self.hidden_point_at_end = Some(val.into());
self
}
pub fn get_tension(&self) -> f64 {
self.tension
}
pub fn get_num_of_segments(&self) -> u32 {
self.num_of_segments
}
pub fn get_hidden_point_at_start(&self) -> Option<&Point> {
self.hidden_point_at_start.as_ref()
}
pub fn get_hidden_point_at_end(&self) -> Option<&Point> {
self.hidden_point_at_end.as_ref()
}
}
impl Default for SplineOpts {
fn default() -> Self {
SplineOpts {
tension: DEFAULT_TENSION,
num_of_segments: DEFAULT_SEGMENTS,
hidden_point_at_start: None,
hidden_point_at_end: None,
}
}
}