Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 15.6 ('Green Screen Saver')
Instant purchase and download via GumRoad!

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):

Download Icon 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 a canvas 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.