mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-26 08:48:12 +08:00
* 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
53 lines
1.1 KiB
Rust
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>>())
|
|
}
|
|
}
|