Better checks for invalid transforms in the transform cage (#831)

* Better checks for invalid transform

* Fix resize cursor

* Do not allow resizing with no width/height

* Fix pivots for 0 width/height layers
This commit is contained in:
0HyperCube
2022-10-27 00:14:32 +01:00
committed by Keavon Chambers
parent e4dc368ecc
commit fa7116133b
3 changed files with 43 additions and 13 deletions

View File

@@ -374,7 +374,16 @@ impl Layer {
}
pub fn layerspace_pivot(&self, font_cache: &FontCache) -> DVec2 {
let [min, max] = self.aabb_for_transform(DAffine2::IDENTITY, font_cache).unwrap_or([DVec2::ZERO, DVec2::ONE]);
let [mut min, max] = self.aabb_for_transform(DAffine2::IDENTITY, font_cache).unwrap_or([DVec2::ZERO, DVec2::ONE]);
// If the layer bounds are 0 in either axis then set them to one (to avoid div 0)
if (max.x - min.x) < f64::EPSILON * 1000. {
min.x = max.x - 1.;
}
if (max.y - min.y) < f64::EPSILON * 1000. {
min.y = max.y - 1.;
}
self.pivot * (max - min) + min
}