mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 00:58:12 +08:00
Bézier-rs: Add utils to subpath (#1058)
* Add utils to bezier-rs subpath * Apply code review changes * Remove tan from constant * Fix compile * Fix tests
This commit is contained in:
committed by
Keavon Chambers
parent
7254c008f9
commit
66ec85a3c9
@@ -2,6 +2,8 @@ use super::*;
|
||||
use crate::utils::SubpathTValue;
|
||||
use crate::utils::TValue;
|
||||
|
||||
use glam::DAffine2;
|
||||
|
||||
/// Helper function to ensure the index and t value pair is mapped within a maximum index value.
|
||||
/// Allows for the point to be fetched without needing to handle an additional edge case.
|
||||
/// - Ex. Via `subpath.iter().nth(index).evaluate(t);`
|
||||
@@ -263,6 +265,13 @@ impl<ManipulatorGroupId: crate::Identifier> Subpath<ManipulatorGroupId> {
|
||||
closed: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Apply a transformation to all of the [ManipulatorGroup]s in the [Subpath].
|
||||
pub fn apply_transform(&mut self, affine_transform: DAffine2) {
|
||||
for manipulator_group in &mut self.manipulator_groups {
|
||||
manipulator_group.apply_transform(affine_transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -719,4 +728,10 @@ mod tests {
|
||||
assert!(result.manipulator_groups[0].out_handle.is_none());
|
||||
assert_eq!(result.manipulator_groups.len(), 1);
|
||||
}
|
||||
|
||||
fn transform_subpath() {
|
||||
let mut subpath = set_up_open_subpath();
|
||||
subpath.apply_transform(glam::DAffine2::IDENTITY);
|
||||
assert_eq!(subpath, set_up_open_subpath());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user