Skip to content

Add anchor sliding along adjacent segments in the Path tool #2682

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
merged 20 commits into from
Jun 14, 2025

Conversation

4adex
Copy link
Collaborator

@4adex 4adex commented Jun 1, 2025

Partly closes #2715

This is currently implemented with CtrlShift drag, but will move to GG in a followup PR.

@Keavon Keavon changed the title Add sliding anchor along adjacent segments in path tool Add sliding anchor along adjacent segments in the Path tool Jun 7, 2025
@Keavon
Copy link
Member

Keavon commented Jun 8, 2025

  • Please add Esc/RMB cancellation.
  • And the hint, which can be "+ CtrlShift Slide" added to "[RMB] Drag Selected" that should show up only when there is zero or one anchor, and zero handles, currently selected.

@Keavon Keavon marked this pull request as draft June 8, 2025 08:04
@otdavies
Copy link
Member

Caught an error when working with this new feature (very cool btw! I think it should be double tap G like blender though)

panicked at editor/src/messages/tool/tool_messages/path_tool.rs:2266:117:
called `Option::unwrap()` on a `None` value

Error
    at https://5f6ef0f3.graphite.pages.dev/assets/index-DVDznk7q.js:943:1179
    at g (https://5f6ef0f3.graphite.pages.dev/assets/index-DVDznk7q.js:929:64934)
    at Object.handleJsMessage (https://5f6ef0f3.graphite.pages.dev/assets/index-DVDznk7q.js:929:65082)
    at https://5f6ef0f3.graphite.pages.dev/assets/index-DVDznk7q.js:929:65475
    at https://5f6ef0f3.graphite.pages.dev/assets/index-DVDznk7q.js:929:12694
    at vt (https://5f6ef0f3.graphite.pages.dev/assets/index-DVDznk7q.js:928:6130)
    at o.wbg.__wbg_call_833bed5770ea2041 (https://5f6ef0f3.graphite.pages.dev/assets/index-DVDznk7q.js:929:12664)
    at graphite_wasm.wasm._ZN13graphite_wasm10editor_api12EditorHandle27send_frontend_message_to_js17h0668831c386ddb67E (https://5f6ef0f3.graphite.pages.dev/assets/graphite_wasm_bg-Cw88cXvm.wasm:wasm-function[3717]:0x8b8a38)
    at graphite_wasm.wasm._ZN4core3ops8function2Fn4call17h7e50954c4596dc1dE (https://5f6ef0f3.graphite.pages.dev/assets/graphite_wasm_bg-Cw88cXvm.wasm:wasm-function[14276]:0xbb570d)
    at graphite_wasm.wasm._ZN3std9panicking20rust_panic_with_hook17h1f8226e239ffaa71E (https://5f6ef0f3.graphite.pages.dev/assets/graphite_wasm_bg-Cw88cXvm.wasm:wasm-function[7593]:0xa9f925)
    at graphite_wasm.wasm._ZN4core9panicking9panic_fmt17hb6c28595a1feee80E (https://5f6ef0f3.graphite.pages.dev/assets/graphite_wasm_bg-Cw88cXvm.wasm:wasm-function[11808]:0xb8b6cd)
    at graphite_wasm.wasm._ZN4core9panicking5panic17h6d53c7d07dcdab1eE (https://5f6ef0f3.graphite.pages.dev/assets/graphite_wasm_bg-Cw88cXvm.wasm:wasm-function[11308]:0xb83404)
    at graphite_wasm.wasm._ZN4core6option13unwrap_failed17h1b26bbcca9c2733dE (https://5f6ef0f3.graphite.pages.dev/assets/graphite_wasm_bg-Cw88cXvm.wasm:wasm-function[13818]:0xba3df8)
    at graphite_wasm.wasm._ZN285_$LT$graphite_editor..messages..tool..tool_messages..path_tool..PathTool$u20$as$u20$graphite_editor..utility_traits..MessageHandler$LT$graphite_editor..messages..tool..tool_message..ToolMessage$C$$RF$mut$u20$graphite_editor..messages..tool..utility_types..ToolActionHandlerData$GT$$GT$15process_message17h57cc7359c7418186E (https://5f6ef0f3.graphite.pages.dev/assets/graphite_wasm_bg-Cw88cXvm.wasm:wasm-function[1382]:0x5d0821)
    at graphite_wasm.wasm._ZN280_$LT$graphite_editor..messages..tool..tool_message_handler..ToolMessageHandler$u20$as$u20$graphite_editor..utility_traits..MessageHandler$LT$graphite_editor..messages..tool..tool_message..ToolMessage$C$graphite_editor..messages..tool..tool_message_handler..ToolMessageData$GT$$GT$15process_message17hb9f008b410d7f07aE (https://5f6ef0f3.graphite.pages.dev/assets/graphite_wasm_bg-Cw88cXvm.wasm:wasm-function[428]:0x246a39)
    at graphite_wasm.wasm._ZN15graphite_editor10dispatcher10Dispatcher14handle_message17hef80e4234270813cE (https://5f6ef0f3.graphite.pages.dev/assets/graphite_wasm_bg-Cw88cXvm.wasm:wasm-function[440]:0x25a86f)
    at graphite_wasm.wasm._ZN13graphite_wasm10editor_api12EditorHandle8dispatch17hfd01dc31199e82deE (https://5f6ef0f3.graphite.pages.dev/assets/graphite_wasm_bg-Cw88cXvm.wasm:wasm-function[4376]:0x94a297)
    at graphite_wasm.wasm.editorhandle_onMouseUp (https://5f6ef0f3.graphite.pages.dev/assets/graphite_wasm_bg-Cw88cXvm.wasm:wasm-function[5015]:0x99ae9a)
    at G2.onMouseUp (https://5f6ef0f3.graphite.pages.dev/assets/index-DVDznk7q.js:929:5974)
    at $ (https://5f6ef0f3.graphite.pages.dev/assets/index-DVDznk7q.js:932:3674)
    at action (https://5f6ef0f3.graphite.pages.dev/assets/index-DVDznk7q.js:932:809)

@Keavon
Copy link
Member

Keavon commented Jun 14, 2025

Ok, yeah, one more request please: instead of Ctrl+Shift, let's make this double-G. So when you're in GRS grabbing mode, just as you can hit keys like X, Y, etc. it should also accept G which will discard any existing translation that was applied and reset to the translation when G was first hit (in case the user moves the mouse between the two G presses), then it should enter sliding mode until LMB/Enter (confirm) or RMB/Esc (cancel) which exits GRS mode.

@Keavon
Copy link
Member

Keavon commented Jun 14, 2025

I'm actually going to merge this now and that, plus the crash fix, can be a followup PR.

@Keavon Keavon changed the title Add sliding anchor along adjacent segments in the Path tool Add anchor sliding along adjacent segments in the Path tool Jun 14, 2025
@Keavon Keavon merged commit 5c25129 into master Jun 14, 2025
4 checks passed
@Keavon Keavon deleted the point_sliding branch June 14, 2025 20:40
Keavon pushed a commit that referenced this pull request Jun 18, 2025
Keavon added a commit that referenced this pull request Jun 20, 2025
* Improved comments

* Add point sliding with approximate t value

* Add similarity calculation

* Numerical approach to fit the curve

* Reliable point sliding for cubic segments

* Fix formatting and clean comments

* Fix cubic with one handle logic

* Cancel on right click and escape

* Two parameter optimization

* Esc/ Right click cancellation

* Code review

* Fix dynamic hints

* Revert selected_points_counts and fix comments

* Code review

---------

Co-authored-by: Keavon Chambers <[email protected]>
Keavon pushed a commit that referenced this pull request Jun 20, 2025
Moharum1 pushed a commit to Moharum1/Graphite that referenced this pull request Jun 23, 2025
…Editor#2682)

* Improved comments

* Add point sliding with approximate t value

* Add similarity calculation

* Numerical approach to fit the curve

* Reliable point sliding for cubic segments

* Fix formatting and clean comments

* Fix cubic with one handle logic

* Cancel on right click and escape

* Two parameter optimization

* Esc/ Right click cancellation

* Code review

* Fix dynamic hints

* Revert selected_points_counts and fix comments

* Code review

---------

Co-authored-by: Keavon Chambers <[email protected]>
Keavon added a commit that referenced this pull request Jun 26, 2025
…spacing based on separation or quantity (#2727)

* Added Count point Radio button to property pannel

* Implemented on Count radio button functionality

* Fixed linting and Title case problem

* Fixing more linting problem

* Instance tables refactor part 8: Make repeater nodes use pivot not bbox and output instance type not group; rename 'Flatten Vector Elements' to 'Flatten Path' and add 'Flatten Vector' (#2697)

Make repeater nodes use pivot not bbox and output instance type not group; rename 'Flatten Vector Elements' to 'Flatten Path' and add 'Flatten Vector'

* Refactor the 'Bounding Box' node to use Kurbo instead of Bezier-rs (#2662)

* use kurbo's default accuracy constant

* fix append_bezpath() method

* refactor bounding box node

* fix append bezpath implementation.

* comments

---------

Co-authored-by: Keavon Chambers <[email protected]>

* Add overlays for free-floating anchors on hovered/selected vector layers (#2630)

* Add selection overlay for free-floating anchors

* Add hover overlay for free-floating anchors

* Refactor outline_free_floating anchor

* Add single-anchor click targets on VectorData

* Modify ClickTarget to adapt for Subpath and PointGroup

* Fix Rust formatting

* Remove debug statements

* Add point groups support in VectorDataTable::add_upstream_click_targets

* Improve overlay for free floating anchors

* Remove datatype for nodes_to_shift

* Fix formatting in select_tool.rs

* Lints

* Code review

* Remove references to point_group

* Refactor ManipulatorGroup for FreePoint in ClickTargetGroup

* Rename ClickTargetGroup to ClickTargetType

* Refactor outline_free_floating_anchors into outline

* Adapt TransformCage to disable dragging and rotating on a single anchor layer

* Fix hover on single points

* Fix comments

* Lints

* Code review pass

---------

Co-authored-by: Keavon Chambers <[email protected]>

* Add anchor sliding along adjacent segments in the Path tool (#2682)

* Improved comments

* Add point sliding with approximate t value

* Add similarity calculation

* Numerical approach to fit the curve

* Reliable point sliding for cubic segments

* Fix formatting and clean comments

* Fix cubic with one handle logic

* Cancel on right click and escape

* Two parameter optimization

* Esc/ Right click cancellation

* Code review

* Fix dynamic hints

* Revert selected_points_counts and fix comments

* Code review

---------

Co-authored-by: Keavon Chambers <[email protected]>

* Fix Sample Points node to avoid duplicating endpoints instead of closing its sampled paths (#2714)

* Skip duplicate endpoint and close sampled paths in Sample Points node
Closes #2713

* Comment

---------

Co-authored-by: Keavon Chambers <[email protected]>

* Implemented on Count radio button functionality

* Fixed linting and Title case problem

* The sample count can now work with adaptive spacing

* Readying for production

* Rename to 'Sample Polyline' and add migration

* Upgrade demo artwork

* Add monomorphization

---------

Co-authored-by: Keavon Chambers <[email protected]>
Co-authored-by: Priyanshu <[email protected]>
Co-authored-by: seam0s <[email protected]>
Co-authored-by: Adesh Gupta <[email protected]>
Co-authored-by: Ezbaze <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Point sliding with G G
3 participants