Some GUI Improvements
Pygmy has always had a basic GUI lib, even before I decided to move from the MSP430s to the ARM Cortex M3s. Now with the new color graphic LCD Shield for the Nebula, it’s time to revisit the GUI code. Just tonight I added animated sprite support. Just today I added support for animated sprites. Pygmy has support for a wide variety of images, including raster fonts and image strips ( sequences of images, or collections of images within one file ). The sprites leverage this pre-existing code. A sprite, in this context, is a sequence of images stored as an image strip that is drawn with a specified delay between frames, thereby producing an animation. Sprites in Pygmy may be any number of frames up to 65535 and any resolution ( practically limited by the screen ) and color depth. Further, sprites may be drawn in any number and in multiple locations on the screen. Each sprite is created with a mutable array of coordinates for each frame. When the sprite is drawn, each coordinate pair is iterated through. So, for a row of sprites representing waving grass, only one sprite need be created, with the coordinate pairs for each block of waving grass stored in the array. If the sprites are intended to move, only the coordinates need to be updated. To create such a sprite, only two function calls are necessary. First, the file or resource must be loaded. Second, the file handle is passed to guiCreateSprite() with the coordinate array and desired time between frames. Each sprite runs as a separate thread. Each thread is spawned by guiCreateSprite() and drawing is handled in the background by the OS. In short, Pygmy Sprites make is painless to draw animated graphics with any supported LCD.