Skip to content

Conversation

@pgilfernandez
Copy link

Hi,

I've been developing a grid and snapping system, it started as an experiment with IA, but I think it turned pretty damn good at the end 😅 (and very useful indeed):

Screenshot 2025-10-23 at 10 40 58
grid_v04e.mp4

It features:

  • snapping system based on pivot points, nodes, tangent handles and special nodes (gradients, rectangle and circle....)
  • snaps to canvas corners, edged midpoints and center
  • snaps to grid points
  • visual grid created with minor and major lines (ala Inkscape) configurable in X and Y
  • snapping radius (threshold)
  • menu entry under View > Grid & snapping
  • grid visual options:
    - hide/show grid
    - snap to grid and/or canvas (independent)
    - draw grid at back or on top
  • grid settings are stored per project (that way each project can have its own settings)
  • settings can be stored as default for new projects
  • grid settings dialog stays always on top while allowing to continue editing in Friction
  • for new projects it is possible to save your preferred defaults
  • Friction remembers your "grid visual options"

It indeed changes Friction document, needed a new version and touches lots of files so feel free to review when you have some spare time.

It works very well and it is so handy (at least for the kind of animations I use to create).
Try it and let me know 😄

@pgilfernandez
Copy link
Author

Would snapping to other objects be doable?

Yes! I'm on it

When scaling (using gizmo) snapping would be nice, also for rotate if possible (if snap to box is enabled).

I can try, but I'm unsure how it would behave...
How it would work for rotation? I don't really understand it...

After testing I think we need to split out box and pivot. Snap to pivot can be a bit irritating at times :)

Hehehe, I agree and I'm introducing "snap to nodes" too when the object is based on them

I'll let you know later

@rodlie
Copy link
Member

rodlie commented Oct 25, 2025

Yes! I'm on it

Awesome 👍

How it would work for rotation? I don't really understand it...

We use the bounding box corners of the object, if in snapping range during rotation calc how much added rotation (based on pivot) is needed before we match the snap target, then apply(?).

Anyway, not important for v1.0, this is something we can look at for v1.1 (or beyond).

@pgilfernandez
Copy link
Author

There it is, a step forward. It works pretty well.
At this state we have all thing optional:

  • Snapping: global switch to activate/deactivate all
  • Snapping points: the available points in the canvas (destination)
    • canvas (corners, midpoints and center)
    • grid
    • pivot
    • bounding box (corners, midpoints and center)
    • nodes
  • Anchors: the available points on the selected object (origin)
    • pivot
    • bounding box (corners, midpoints and center)
    • nodes (in case the object is based on them)
  • Visible grid settings
    • show grid
    • show on top
    • grid settings

It is turning big, at least on available options... I don't know if it still makes sense to place it buried in a menu or we need to think about some buttons/toggles in the main GUI, what do you think?
It not, we can rearrange and group items as you want... any suggestion?

About the scaling I think it won't be able to do it with the current implementation as the gizmos just modify the values of the related parameters, that is, for scaling it just edit the scaling values based on mouse interaction.
If we want to scale an object and snap to other we are going to need to scale it grabbing a bounding box handle as it is done is lot of other softwares, but it would need a new gizmo that is drawn in the bounding box corners. Once we can edit the scale based on them is when we could add it into the snapping system.
I can try but it could be treated as a "different project", hehehe

I guess we should add a shortcut for the global snapping toggle, do you agree?

@rodlie
Copy link
Member

rodlie commented Oct 25, 2025

It is turning big, at least on available options...

That's ok, I will add a new toolbar for grid/snapping with the most relevant options.

@rodlie
Copy link
Member

rodlie commented Oct 25, 2025

Suggestion for buttons in toolbar:

friction-snap-2025-10-25_23.57.18.mp4

click enable/disable, long-click open menu.

@pgilfernandez
Copy link
Author

pgilfernandez commented Oct 25, 2025

I like it! very simple and faster than menus.

Do we need icons for each option or just text? I would bet for no more icons and just checkbox and label

Is the "grid" icon going to behave the same?

  • Click show/hide
  • long press options and settings

Copy link
Member

@rodlie rodlie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments. Don't do anything yet.

I'm a bit confused by the usage of both eSettings and AppSupport settings.

@rodlie
Copy link
Member

rodlie commented Oct 25, 2025

I like it! very simple and faster than menus.

Do we need icons for each option or just text? I would bet for no more icons and just checkbox and label

Is the "grid" icon going to behave the same?

  • Click show/hide
  • long press options and settings

Yes the grid will behave the same. I don't think we need more icons, checkbox are good enough.

@rodlie
Copy link
Member

rodlie commented Oct 26, 2025

Ok, don't do any more changes to the settings stuff, and don't give me AI answers ;) (if you don't know just say so)

I will rewrite the settings stuff.

@pgilfernandez
Copy link
Author

OK, I will.

It's all yours, I'm not touching the code anymore, in case I find any bug or thing that's should be added I will tell you first, so you can work in this PR

@rodlie
Copy link
Member

rodlie commented Oct 26, 2025

in case I find any bug or thing that's should be added

Ok 👍

@pgilfernandez
Copy link
Author

BTW, the settings are supposed to work as the following:

  • store all of them into the document so that if you open a project it loads them as you wanted for that specific one.
  • in case you create a new document don't just load default settings but let users store their own preferred ones, that's why there is a checkbox in Grid Settings dialog

@rodlie
Copy link
Member

rodlie commented Oct 26, 2025

store all of them into the document so that if you open a project it loads them as you wanted for that specific one.

That looks ok, I'm not able to test the XML stuff, since development of the XML file format happens in a dedicated branch. I will mark the XML load/save as TODO or something in the code, so that I remember to check/fix it when I continue on that branch.

in case you create a new document don't just load default settings but let users store their own preferred ones, that's why there is a checkbox in Grid Settings dialog

I understand.

Unsure if I have time today, if not I will fix the settings stuff tomorrow. I will probably also move some code around.

@rodlie
Copy link
Member

rodlie commented Nov 9, 2025

Been a bit busy with other things this last week, but I'm working on getting this ready for merging.

I had to remove most code related to GridSettings, but I should be done in a day or so (depends on how much free time I get).

@pgilfernandez
Copy link
Author

Great! Take your time. I knew GridSetting needed some love and adaptation to Friction system but they are great news 👏🏻

@rodlie
Copy link
Member

rodlie commented Nov 9, 2025

btw, we need on/off icons for grid and gizmo. Similar to the snap icon. (snap_on/snap_off):

Screen.Recording.2025-11-09.at.22.54.16.mp4

@KirbysDarkNebula
Copy link

Hello, I tried to test this branch to see if it was included but since I don't see it in discussion nor am able to compile at this time, and since this seems so close to completion I was wondering if angle snapping was implemented (as in, when rotating the object you can hold down a key / have snapping enabled and you rotate in increments of 5/10/15, whatever, degrees, snapping to the closest one), since that would be a very major use case, thanks.

@pgilfernandez
Copy link
Author

Hello, I tried to test this branch to see if it was included but since I don't see it in discussion nor am able to compile at this time, and since this seems so close to completion I was wondering if angle snapping was implemented (as in, when rotating the object you can hold down a key / have snapping enabled and you rotate in increments of 5/10/15, whatever, degrees, snapping to the closest one), since that would be a very major use case, thanks.

That feature is not implemented here as this PR is all about grid and "point" snapping.

I also feel that "stepped" rotation would be a nice new feature, but, I should be worked and discussed on another PR. BTW, I'll try this weekend to do a fast mockup and see if it can be implemented 😉

@KirbysDarkNebula
Copy link

Alright thanks for letting me know, I wasn't sure because issue #287 was closed in favour of #250, which links here, so it seems there was a loss in functionality along the way from proposals to pr, but that's alright. If you can look into getting it working that would be great, thank you!

@pgilfernandez
Copy link
Author

Alright thanks for letting me know, I wasn't sure because issue #287 was closed in favour of #250, which links here, so it seems there was a loss in functionality along the way from proposals to pr, but that's alright. If you can look into getting it working that would be great, thank you!

It turned to be very easy to implement! at least considering it as a stepped rotation, well, let's see what @rodlie thinks about it, in the meanwhile, if you wait 30-50 minutes from now you will be able to test it with the PR builds #650.

@pgilfernandez
Copy link
Author

I also added the node tangents snapping to the new feature so at the end we have it all:

  • object rotation by steps
  • node tangents snapping to fixed angles (I used 15º but that could be changed indeed)

No way to edit the angles or modifiers but the feature is there. Adding them into Preferences is the easy thing... but I prefer @rodlie to have a look at it and let him tweak or polish it to softly integrate it into Friction.

😄

Everything is in the same PR #650

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Guides/Grid/Snapping

3 participants