mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-24 14:18:11 +08:00
Fix crash when scaling something with 0 width or height (#1078)
* resolve NaN value when trying to change scale value from zero to other numbers * resolve NaN value when trying to change scale value from zero to other numbers --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
committed by
Keavon Chambers
co-authored by
Keavon Chambers
parent
d6ab417bcb
commit
dbcb854cd2
@@ -59,7 +59,7 @@ impl LayerData for ShapeLayer {
|
|||||||
|
|
||||||
fn bounding_box(&self, transform: glam::DAffine2, _render_data: &RenderData) -> Option<[DVec2; 2]> {
|
fn bounding_box(&self, transform: glam::DAffine2, _render_data: &RenderData) -> Option<[DVec2; 2]> {
|
||||||
let mut subpath = self.shape.clone();
|
let mut subpath = self.shape.clone();
|
||||||
if transform.matrix2 == DMat2::ZERO {
|
if transform.matrix2 == DMat2::ZERO || !transform.is_finite() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
subpath.apply_affine(transform);
|
subpath.apply_affine(transform);
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ pub fn apply_transform_operation(layer: &Layer, transform_op: TransformOp, value
|
|||||||
|
|
||||||
// Find the delta transform
|
// Find the delta transform
|
||||||
let mut delta = layer.transform.inverse() * transform;
|
let mut delta = layer.transform.inverse() * transform;
|
||||||
|
if !delta.is_finite() {
|
||||||
|
return layer.transform.to_cols_array();
|
||||||
|
}
|
||||||
|
|
||||||
// Preserve aspect ratio
|
// Preserve aspect ratio
|
||||||
if matches!(transform_op, TransformOp::ScaleX | TransformOp::Width) && layer.preserve_aspect {
|
if matches!(transform_op, TransformOp::ScaleX | TransformOp::Width) && layer.preserve_aspect {
|
||||||
|
|||||||
Reference in New Issue
Block a user