Article Preview
Buy Now
FEATURE
Move, Rectangle, Move!
A Xojo Animation class
Issue: 15.6 (November/December 2017)
Author: Sam Rowlands
Author Bio: Sam is a pixelMancer and codeWeaver at Ohanaware.
Article Description: No description available.
Article Length (in bytes): 15,804
Starting Page Number: 57
Article Number: 15606
Resource File(s):
project15606.zip Updated: 2017-11-01 11:55:30
Related Web Link(s):
http://machdr.com
Excerpt of article text...
In the past, we've talked about taking advantage of Apple's animation subsystem to animate the placement and opacity of controls. If you've ever used App Wrapper, I used this solution to animate the open window, move controls around, and such.
However, what if you want to provide animation for Windows or Linux, or animate the contents of
canvas
? While animating the contents of acanvas
is possible with Apple's system, it's quite a bit of work to bridge their solution to Xojo, and it still means that you'd need to create a secondary solution for other platforms.At the moment, I'm not very impressed by the reliability of Apple's recent OS updates. I'm also seeing, in my chosen industry, more and more customers migrating away from Apple products (for a variety of reasons, but the common belief is that Apple doesn't care), so I, too, am trying to shift my mindset to a more platform-neutral way of thinking. This is a great time to start. So we'll build a solution that can be used across all platforms.
We're going to be using the time-based animation principle. Meaning, that when you start the animation, you specify the what, its starting value, ending value, and the duration of the animation.
In turn, when it's time to update the animation, the values we use are based upon a "blend" of the start and the end values, using the position as a blending percent. The advantage of this approach is that animation is more consistent across newer hardware, rather than ending more quickly on faster machines.
This way, if an animation is set to take a third of a second, it will take a third of second; faster machines will make the animation smoother, rather than complete the animation in less time.
...End of Excerpt. Please purchase the magazine to read the full article.