Fix transformation cage centered-scaling to use the center as its pivot (#769)

* Add centre of transformation

* Add alt support

* New breaking file format version

* Spelling

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0HyperCube
2022-08-29 01:30:45 +01:00
committed by Keavon Chambers
co-authored by Keavon Chambers
parent 5afaee1e4b
commit 41c137ed1b
9 changed files with 109 additions and 104 deletions
+6
View File
@@ -367,6 +367,12 @@ impl Document {
Ok(layer.data.bounding_box(layer.transform, font_cache).map(|bounds| (bounds, transform)))
}
/// Compute the center of transformation multiplied with `Document::multiply_transforms`.
pub fn pivot(&self, path: &[LayerId], font_cache: &FontCache) -> Option<DVec2> {
let layer = self.layer(path).ok()?;
Some(self.multiply_transforms(path).unwrap_or_default().transform_point2(layer.layerspace_pivot(font_cache)))
}
pub fn visible_layers_bounding_box(&self, font_cache: &FontCache) -> Option<[DVec2; 2]> {
let mut paths = vec![];
self.visible_layers(&mut vec![], &mut paths).ok()?;