Files
Graphite/libraries/bezier-rs/src/bezier/mod.rs
T
Hannah Li 49c236fcc2 Divide the large Bezier-rs implementation file into smaller ones (#751)
* Refactor bezier lib file into a separate folder

* Add better implementation comments

* Update import of Subpath from bezier-rs

* Add comment to describe compare.rs

* Remove printlns and adjust spacing
2022-08-18 18:47:36 -04:00

53 lines
1.1 KiB
Rust

#[cfg(test)]
pub(super) mod compare;
mod core;
mod lookup;
mod manipulators;
mod solvers;
mod structs;
mod transform;
use crate::consts::*;
use crate::utils;
pub use structs::*;
use glam::DVec2;
use std::fmt::{Debug, Formatter, Result};
/// Representation of the handle point(s) in a bezier segment.
#[derive(Copy, Clone, PartialEq)]
enum BezierHandles {
Linear,
/// Handles for a quadratic curve.
Quadratic {
/// Point representing the location of the single handle.
handle: DVec2,
},
/// Handles for a cubic curve.
Cubic {
/// Point representing the location of the handle associated to the start point.
handle_start: DVec2,
/// Point representing the location of the handle associated to the end point.
handle_end: DVec2,
},
}
/// Representation of a bezier curve with 2D points.
#[derive(Copy, Clone, PartialEq)]
pub struct Bezier {
/// Start point of the bezier curve.
start: DVec2,
/// Start point of the bezier curve.
end: DVec2,
/// Handles of the bezier curve.
handles: BezierHandles,
}
impl Debug for Bezier {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "{:?}", self.get_points().collect::<Vec<DVec2>>())
}
}