mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 01:28:12 +08:00
Bézier-rs: Add ids to manipulator groups (#1054)
* Add ids to manipulator groups * Fix tests * Rename trait from ManipulatorGroupId to Identifier * Rename EmptyManipulatorGroupId to EmptyId
This commit is contained in:
@@ -12,19 +12,19 @@ use std::ops::{Index, IndexMut};
|
||||
|
||||
/// Structure used to represent a path composed of [Bezier] curves.
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct Subpath {
|
||||
manipulator_groups: Vec<ManipulatorGroup>,
|
||||
pub struct Subpath<ManipulatorGroupId: crate::Identifier> {
|
||||
manipulator_groups: Vec<ManipulatorGroup<ManipulatorGroupId>>,
|
||||
closed: bool,
|
||||
}
|
||||
|
||||
/// Iteration structure for iterating across each curve of a `Subpath`, using an intermediate `Bezier` representation.
|
||||
pub struct SubpathIter<'a> {
|
||||
pub struct SubpathIter<'a, ManipulatorGroupId: crate::Identifier> {
|
||||
index: usize,
|
||||
sub_path: &'a Subpath,
|
||||
sub_path: &'a Subpath<ManipulatorGroupId>,
|
||||
}
|
||||
|
||||
impl Index<usize> for Subpath {
|
||||
type Output = ManipulatorGroup;
|
||||
impl<ManipulatorGroupId: crate::Identifier> Index<usize> for Subpath<ManipulatorGroupId> {
|
||||
type Output = ManipulatorGroup<ManipulatorGroupId>;
|
||||
|
||||
fn index(&self, index: usize) -> &Self::Output {
|
||||
assert!(index < self.len(), "Index out of bounds in trait Index of SubPath.");
|
||||
@@ -32,14 +32,14 @@ impl Index<usize> for Subpath {
|
||||
}
|
||||
}
|
||||
|
||||
impl IndexMut<usize> for Subpath {
|
||||
impl<ManipulatorGroupId: crate::Identifier> IndexMut<usize> for Subpath<ManipulatorGroupId> {
|
||||
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
|
||||
assert!(index < self.len(), "Index out of bounds in trait IndexMut of SubPath.");
|
||||
&mut self.manipulator_groups[index]
|
||||
}
|
||||
}
|
||||
|
||||
impl Iterator for SubpathIter<'_> {
|
||||
impl<ManipulatorGroupId: crate::Identifier> Iterator for SubpathIter<'_, ManipulatorGroupId> {
|
||||
type Item = Bezier;
|
||||
|
||||
// Returns the Bezier representation of each `Subpath` segment, defined between a pair of adjacent manipulator points.
|
||||
|
||||
Reference in New Issue
Block a user