Skip to content

Commit 5ca4060

Browse files
committed
Simplify gradient tool distance calculation
1 parent f1b7739 commit 5ca4060

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

editor/src/messages/tool/tool_messages/gradient_tool.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ impl Fsm for GradientToolFsmState {
351351
let (start, end) = (transform.transform_point2(gradient.start), transform.transform_point2(gradient.end));
352352

353353
// Compute the distance from the mouse to the gradient line in viewport space
354-
let distance = (end - start).angle_to(mouse - start).sin() * (mouse - start).length();
354+
let direction = (end - start).normalize_or_zero();
355+
let distance = direction.dot(mouse - start);
355356

356357
// If click is on the line then insert point
357358
if distance < (SELECTION_THRESHOLD * 2.) {

0 commit comments

Comments
 (0)