Select and move shapes

This commit is contained in:
Skyler Lehmkuhl
2025-11-18 00:22:28 -05:00
parent afda2d9d4f
commit 67724c944c
18 changed files with 3868 additions and 19 deletions
@@ -5,6 +5,7 @@
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use vello::kurbo::Shape as KurboShape;
/// 2D transform for an object
#[derive(Clone, Debug, Serialize, Deserialize)]
@@ -170,6 +171,20 @@ impl Object {
self.transform.set_position(x, y);
self
}
/// Convert object transform to affine matrix
pub fn to_affine(&self) -> kurbo::Affine {
self.transform.to_affine()
}
/// Get the bounding box of this object given its shape
///
/// Returns the bounding box in the object's parent coordinate space
/// (i.e., with the object's transform applied).
pub fn bounding_box(&self, shape: &crate::shape::Shape) -> kurbo::Rect {
let path_bbox = shape.path().bounding_box();
self.to_affine().transform_rect_bbox(path_bbox)
}
}
#[cfg(test)]