mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
* Move the Subpath type to graphene-std * Add the transform subpath node * Delete selected nodes * Inserting node list on right click * Add several bitmap manipulator nodes * Convert add node to use f64 * Add posterize node * Rename names randomly * Fix naming * Exposure node * Fix typo * Adjust exposure node range * Comment out vector nodes * Adjust exposure range again * Posterise as ints * Rename input * Use >= in the to hsl function
49 lines
1.1 KiB
Rust
49 lines
1.1 KiB
Rust
use std::ops::{Index, IndexMut};
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[repr(usize)]
|
|
#[derive(PartialEq, Eq, Clone, Debug, Copy, Serialize, Deserialize)]
|
|
pub enum ManipulatorType {
|
|
Anchor,
|
|
InHandle,
|
|
OutHandle,
|
|
}
|
|
|
|
impl ManipulatorType {
|
|
pub fn from_index(index: usize) -> ManipulatorType {
|
|
match index {
|
|
0 => ManipulatorType::Anchor,
|
|
1 => ManipulatorType::InHandle,
|
|
2 => ManipulatorType::OutHandle,
|
|
_ => ManipulatorType::Anchor,
|
|
}
|
|
}
|
|
|
|
pub fn opposite_handle(self) -> ManipulatorType {
|
|
match self {
|
|
ManipulatorType::Anchor => ManipulatorType::Anchor,
|
|
ManipulatorType::InHandle => ManipulatorType::OutHandle,
|
|
ManipulatorType::OutHandle => ManipulatorType::InHandle,
|
|
}
|
|
}
|
|
}
|
|
|
|
// Allows us to use ManipulatorType for indexing
|
|
impl<T> Index<ManipulatorType> for [T; 3] {
|
|
type Output = T;
|
|
fn index(&self, mt: ManipulatorType) -> &T {
|
|
&self[mt as usize]
|
|
}
|
|
}
|
|
|
|
// Allows us to use ManipulatorType for indexing, mutably
|
|
impl<T> IndexMut<ManipulatorType> for [T; 3] {
|
|
fn index_mut(&mut self, mt: ManipulatorType) -> &mut T {
|
|
&mut self[mt as usize]
|
|
}
|
|
}
|
|
|
|
// Remove when no longer needed
|
|
pub const SELECTION_THRESHOLD: f64 = 10.;
|