Hacker News new | ask | show | jobs
by Breakthrough 4297 days ago
One trick I've noticed to make animations/transitions "snappier" and more natural is to use quadratic/square (power of 2) scaling. For fun I did it on this clock just saving it locally - you can do it by modifying line 140 of `bezier_clock.pde` to square the ratio instead of simply assign it:

    animationRatio = ratio * ratio;  // can also replace with sqrt(ratio)
Again, just makes it a little bit 'snappier' (remember you have to hit spacebar to turn on continual animation), and scales it so you can determine the numbers a bit more clear earlier in the cycle because of the scaling on (0.0, 1.0]. This is certainly a fun piece of code to play with.
3 comments

I've updated it with quad, cubic and sinusoidal modes. They all look good. Only problem is that because it's no longer linear, the various points can change at different rates and thus create 'kinks' in the curve. When it's linear, the 'line points' and the associated 'control points' are always in a line locally tangential to the curve (don't know the proper terminology but hopefully you understand).
That shouldn't happen if you do the motion transform uniformly on all axes. It should just be equivalent to changing the speed of time, rather than actually changing the trajectories.
There are many interesting easing functions to play with, primarily due to Robert Penner:

http://www.robertpenner.com/easing/

Cool. That's actually fun to try out. http://plnkr.co/edit/JybIMrHpUzGyr39cV5oz?p=preview
Where did you find bezier_clock.pde to modify? I would like to try a few things as well.
ah right ... my webprogramming is a bit lacking

edit: thanks