| snapping with expressions?
• | | | |
 | snapping with expressions?
by sorbet on Oct 24, 2006 at 11:29:13 pm |
This should be easy. I'm trying to figure out a way (through expressions) that I can snap to different px increments. For example, if you keyframed a square to move from left to right, it would snap to 100px increments.
I realize you can snap to guides or the grid, but I'd like to have it snap constantly, even when you animate something.
Any ideas?
| | | | |
• | | | |  | Re: snapping with expressions? by Colin Braley on Oct 25, 2006 at 12:04:04 am |
This should do it for you:
xSnap = 100;
ySnap = 100;
[ Math.round(value[0]/xSnap) * xSnap , Math.round(value[1]/ySnap) * ySnap ]
Just change xSnap and ySnap to whatever increments you want to snap to. However, note that sometimes if you have an object animated near the edge of the comp it might snap to a value out of the comp window. Have fun.
~Colin
| | | | |
• | | | |  | Re: snapping with expressions? by Filip Vandueren on Oct 25, 2006 at 12:08:11 am |
for a hard snap use this:
for a 2D-layer:
[Math.round(value[0]/100),Math.round(value[1]/100)] * 100;
for a 3D layer:
[Math.round(value[0]/100),Math.round(value[1]/100),Math.round(value[2]/100)] * 100;
so it divides each co
| | | | |
• | | | |  | Re: snapping with expressions? by sorbet on Oct 25, 2006 at 12:48:14 am |
Thanks guys! Works perfect!
| | | | |
| |
|