-
-
Notifications
You must be signed in to change notification settings - Fork 588
Add Path tool support for Ctrl-dragging to pull out zero-length handles with angle locking #2620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Keavon
merged 14 commits into
GraphiteEditor:master
from
0SlowPoke0:path-tool-angle-lock
May 17, 2025
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0d139d2
implement check-drag and angle-lock
0SlowPoke0 be3d48f
track bool
0SlowPoke0 a2f96b1
flip-smooth-sharp
0SlowPoke0 3061953
Merge remote-tracking branch 'origin/master' into path-tool-angle-lock
0SlowPoke0 5eed472
Merge branch 'master' into path-tool-angle-lock
0SlowPoke0 13c5db1
fixed bugs
0SlowPoke0 4bc7f91
Merge branch 'path-tool-angle-lock' of https://github.com/0SlowPoke0/…
0SlowPoke0 0aa6a11
Merge branch 'master' into path-tool-angle-lock
Keavon bc6cbc1
fixed flip-smooth jump bug and random angle locking bug
0SlowPoke0 eaaa719
Merge branch 'path-tool-angle-lock' of https://github.com/0SlowPoke0/…
0SlowPoke0 8bf6cb0
ctrl-alt 90 case
0SlowPoke0 401d333
aligned flip-smooth sharp and fixed arbitrary handle-length when flipped
0SlowPoke0 6305d0a
code-review change
0SlowPoke0 d36accd
0.5 instead of 0.8
Keavon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -728,7 +728,7 @@ impl ShapeState { | |
return; | ||
}; | ||
let handles = vector_data.all_connected(point_id).take(2).collect::<Vec<_>>(); | ||
|
||
let non_zero_handles = handles.iter().filter(|handle| handle.length(vector_data) > 1e-6).count(); | ||
Keavon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Grab the next and previous manipulator groups by simply looking at the next / previous index | ||
let points = handles.iter().map(|handle| vector_data.other_point(handle.segment, point_id)); | ||
let anchor_positions = points | ||
|
@@ -762,20 +762,35 @@ impl ShapeState { | |
handle_direction *= -1.; | ||
} | ||
|
||
// Push both in and out handles into the correct position | ||
for ((handle, sign), other_anchor) in handles.iter().zip([1., -1.]).zip(&anchor_positions) { | ||
// To find the length of the new tangent we just take the distance to the anchor and divide by 3 (pretty arbitrary) | ||
let Some(length) = other_anchor.map(|position| (position - anchor_position).length() / 3.) else { | ||
continue; | ||
if non_zero_handles != 0 { | ||
let [a, b] = handles.as_slice() else { return }; | ||
let (non_zero_handle, zero_handle) = if a.length(vector_data) > 1e-6 { (a, b) } else { (b, a) }; | ||
let Some(direction) = non_zero_handle | ||
.to_manipulator_point() | ||
.get_position(&vector_data) | ||
.and_then(|position| (position - anchor_position).try_normalize()) | ||
else { | ||
return; | ||
}; | ||
let new_position = handle_direction * length * sign; | ||
let modification_type = handle.set_relative_position(new_position); | ||
let new_position = non_zero_handle.length(vector_data) * direction * -1.; | ||
Keavon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let modification_type = zero_handle.set_relative_position(new_position); | ||
responses.add(GraphOperationMessage::Vector { layer, modification_type }); | ||
|
||
// Create the opposite handle if it doesn't exist (if it is not a cubic segment) | ||
if handle.opposite().to_manipulator_point().get_position(vector_data).is_none() { | ||
let modification_type = handle.opposite().set_relative_position(DVec2::ZERO); | ||
} else { | ||
// Push both in and out handles into the correct position | ||
for ((handle, sign), other_anchor) in handles.iter().zip([1., -1.]).zip(&anchor_positions) { | ||
// To find the length of the new tangent we just take the distance to the anchor and divide by 3 (pretty arbitrary) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What changes with different values than |
||
let Some(length) = other_anchor.map(|position| (position - anchor_position).length() / 3.) else { | ||
continue; | ||
Keavon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
let new_position = handle_direction * length * sign; | ||
let modification_type = handle.set_relative_position(new_position); | ||
responses.add(GraphOperationMessage::Vector { layer, modification_type }); | ||
|
||
// Create the opposite handle if it doesn't exist (if it is not a cubic segment) | ||
if handle.opposite().to_manipulator_point().get_position(vector_data).is_none() { | ||
let modification_type = handle.opposite().set_relative_position(DVec2::ZERO); | ||
responses.add(GraphOperationMessage::Vector { layer, modification_type }); | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -1503,13 +1518,13 @@ impl ShapeState { | |
|
||
let (id, anchor) = result?; | ||
let handles = vector_data.all_connected(id); | ||
let mut positions = handles | ||
let positions = handles | ||
.filter_map(|handle| handle.to_manipulator_point().get_position(&vector_data)) | ||
.filter(|&handle| !anchor.abs_diff_eq(handle, 1e-5)); | ||
.filter(|&handle| anchor.abs_diff_eq(handle, 1e-5)) | ||
.count(); | ||
|
||
// Check by comparing the handle positions to the anchor if this manipulator group is a point | ||
let already_sharp = positions.next().is_none(); | ||
if already_sharp { | ||
if positions != 0 { | ||
self.convert_manipulator_handles_to_colinear(&vector_data, id, responses, layer); | ||
} else { | ||
for handle in vector_data.all_connected(id) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.