Add boolean operations (#1759)

This commit is contained in:
Keavon Chambers
2024-05-25 22:02:00 -07:00
committed by GitHub
parent c80de41d28
commit d40fb6caad
19 changed files with 409 additions and 55 deletions

View File

@@ -9,3 +9,44 @@ pub enum CentroidType {
/// The center of mass for the arc length of a curved shape's perimeter, as if made out of an infinitely thin wire.
Length,
}
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, Hash, DynAny, specta::Type)]
pub enum BooleanOperation {
#[default]
Union,
SubtractFront,
SubtractBack,
Intersect,
Difference,
Divide,
}
impl BooleanOperation {
pub fn list() -> [BooleanOperation; 6] {
[
BooleanOperation::Union,
BooleanOperation::SubtractFront,
BooleanOperation::SubtractBack,
BooleanOperation::Intersect,
BooleanOperation::Difference,
BooleanOperation::Divide,
]
}
pub fn icons() -> [&'static str; 6] {
["BooleanUnion", "BooleanSubtractFront", "BooleanSubtractBack", "BooleanIntersect", "BooleanDifference", "BooleanDivide"]
}
}
impl core::fmt::Display for BooleanOperation {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
BooleanOperation::Union => write!(f, "Union"),
BooleanOperation::SubtractFront => write!(f, "Subtract Front"),
BooleanOperation::SubtractBack => write!(f, "Subtract Back"),
BooleanOperation::Intersect => write!(f, "Intersect"),
BooleanOperation::Difference => write!(f, "Difference"),
BooleanOperation::Divide => write!(f, "Divide"),
}
}
}