File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
editor/src/messages/tool/common_functionality Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -206,7 +206,22 @@ impl SelectedEdges {
206
206
}
207
207
let snapped_bounds = bounds_to_doc. inverse ( ) . transform_point2 ( snapped. snapped_point_document ) ;
208
208
209
- let mut scale_factor = ( snapped_bounds - pivot) / ( updated - pivot) ;
209
+ let new_from_pivot = snapped_bounds - pivot; // The new vector from the snapped point to the pivot
210
+ let original_from_pivot = updated - pivot; // The original vector from the point to the pivot
211
+ let mut scale_factor = new_from_pivot / original_from_pivot;
212
+
213
+ // Constrain should always scale by the same factor in x and y
214
+ if constrain {
215
+ // When the point is on the pivot, we simply copy the other axis.
216
+ if original_from_pivot. x . abs ( ) < 1e-5 {
217
+ scale_factor. x = scale_factor. y ;
218
+ } else if original_from_pivot. y . abs ( ) < 1e-5 {
219
+ scale_factor. y = scale_factor. x ;
220
+ }
221
+
222
+ debug_assert ! ( ( scale_factor. x - scale_factor. y) . abs( ) < 1e-5 ) ;
223
+ }
224
+
210
225
if !( self . left || self . right || constrain) {
211
226
scale_factor. x = 1.
212
227
}
You can’t perform that action at this time.
0 commit comments