Difference between revisions of "AN1001 - Animation in SHIP"

From Serious Documentation
Jump to: navigation, search
(Animation Images)
Line 18: Line 18:
  
 
== Animation Images ==
 
== Animation Images ==
 
Each animation image should be exactly the same size -- in this example project the fan images are all exactly 75 pixels square. 
 
  
 
Just like the cartoon drawings you might have drawn as a child on a corner of a book and "flipped" through to animate, these images will be sequentially shown within the runtime [[SHIPEngine]] environment.  Therefore, as you create the images in Photoshop or your graphics design program of choice, ensure that each image transitions to the next in exactly the right location within the borders of the image boundary.   
 
Just like the cartoon drawings you might have drawn as a child on a corner of a book and "flipped" through to animate, these images will be sequentially shown within the runtime [[SHIPEngine]] environment.  Therefore, as you create the images in Photoshop or your graphics design program of choice, ensure that each image transitions to the next in exactly the right location within the borders of the image boundary.   
  
Here is an example of three fan images, all in fully transparent alpha-blended .png format:
+
Each animation image should be exactly the same size -- in this example project the fan images are all exactly 75 pixels square.  Here they are, all in fully transparent alpha-blended .png format:
  
 
[[File:FanA75.png|75px|border|Example Rotating Fan Image, Part 1/3]][[File:FanB75.png|75px|border|Example Rotating Fan Image, Part 2/3]][[File:FanC75.png|75px|border|Example Rotating Fan Image, Part 3/3]]
 
[[File:FanA75.png|75px|border|Example Rotating Fan Image, Part 1/3]][[File:FanB75.png|75px|border|Example Rotating Fan Image, Part 2/3]][[File:FanC75.png|75px|border|Example Rotating Fan Image, Part 3/3]]

Revision as of 07:34, 4 January 2013

Animation in SHIP

Animation is a common element of many GUIs. Whether a rotating fan, slowly filling indicator, or a glowing element, subtle animations can enhance a GUI and make it more professional and modern.

At the core of every animation is a series of images that, when rotated through in-place one after another, form the impression of an animated object.

Animation in SHIP is the process of cycling through a series of images at a certain rate, making each one visible in sequence with the others invisible.

SHIPTide Project Files for AN1001

Assuming you've downloaded and installed the SHIPTide Rapid GUI Development Environment, pick a target platform and download one of the following projects. Unzip the project to a directory of your choice and open up the project in SHIPTide.

There are many ways to implement animation in SHIP; the attached project uses the concept of "grouped images" and demonstrates 4 different timer modes.

Animation Images

Just like the cartoon drawings you might have drawn as a child on a corner of a book and "flipped" through to animate, these images will be sequentially shown within the runtime SHIPEngine environment. Therefore, as you create the images in Photoshop or your graphics design program of choice, ensure that each image transitions to the next in exactly the right location within the borders of the image boundary.

Each animation image should be exactly the same size -- in this example project the fan images are all exactly 75 pixels square. Here they are, all in fully transparent alpha-blended .png format:

Example Rotating Fan Image, Part 1/3Example Rotating Fan Image, Part 2/3Example Rotating Fan Image, Part 3/3

In this example the three fan images are not only the same size (75 x 75 pixels), but the actual drawings within the image boundaries are in exactly the same location just rotated. If one of the fan images were shifted to the right (for example) you would see horizontal jitter in the animation.

This may be a desired effect, for example if you wish to animate an arrow moving from left to right towards a target. But for many animations you will want to pick a drawing center-point and ensure the various versions of the image are centered on that point within the image boundaries.

In addition, you will typically use .png or .gif images with transparency so that the animation can alpha-blend on top of any background. While the example project uses a fixed color background, you can change this background color or even layer a background image underneath the fan animation and the fan will rotate and "float" over the background with the background showing through the non-blade part of the fan images. Here is the same fan image over top of an image where you can see the underlying image coming through:

AN1001 - A PNG Image with Transparency on a Background

In SHIPTide, look in the Project Resources pane and find the three fan images. Click on one of them and examine the properties of the image in the Properties pane:

AN1001 - Examining an Image

Grouping the Images

The three fan images, instead of being placed flat in the resources/images area, are placed in a named group. Exploring the project in SHIPTide the group looks like this:

AN1001 - Grouped Images

When you group resources like this, you can now use the getChildCount() function in Sail to easily select and assign each of the images in turn to a container at a beat rate driven by a timer.