|The AG_Anim structure describes an animation in uncompressed packed-pixel or indexed format.|
The AG_AnimNew() function allocates and initializes a new AG_Anim of the specified dimensions w, h (given in pixels). fmt is a pointer to a AG_PixelFormat structure describing the way pixels are to be encoded in memory (see PIXEL FORMATS section below). The pixel data is left uninitialized. Acceptable values for type include:
Acceptable flags include:
The AG_AnimEmpty() function creates a new zero-sized animation.
AG_AnimStdRGB() and AG_AnimStdRGBA() create an animation in the recommended standard format, as determined by Agar on initialization time. Usually, this is a packed-pixel format with an alpha component.
The AG_AnimIndexed() function creates a new animation of w by h pixels using indexed pixel format. This involves the allocation of a palette. The size of this palette is determined by bitsPerPixel. All entries in the palette are initialized to black, except in the 2-bpp case, where color 0 is initialized to white and color 1 is initialized to black.
The AG_AnimRGB() function creates a new animation of w by h pixels using the specified packed-pixel format. In memory, pixels are encoded as contiguous blocks of bitsPerPixel bits, and the bitmasks specified in [RGB]mask are used to retrieve the individual red, green and blue components. The AG_AnimRGBA() variant adds an alpha-channel component and implicitely sets the AG_SRCALPHA flag.
The AG_AnimFromPNGs() and AG_AnimFromJPEGs() functions attempt to load the contents of a series of image files (specified as a path name with a numerical format string) into a newly-allocated animation. AG_AnimFromPNGs() and AG_AnimFromJPEGs() will return an error unless Agar was compiled with support for libpng and libjpeg, respectively.
The AG_AnimDup() function returns a duplicate of the specified animation, or NULL if insufficient memory is available. The source animation must be locked (src->lock).
The AG_AnimSetOrigFPS() sets the original frame rate associated with the animation. The default is 30.0. This frame rate can be overriden under playback contexts (see PLAYBACK section below).
The AG_AnimSetPalette() function copies count color entries from the colors array, to count slots (starting at offs) in the palette of indexed surface su.
AG_AnimResize() attempts to resize an animation to the specified dimensions. If insufficient memory is available, the function fails returning -1. When size is increased, the new pixels are left in an uninitialized state. The current clipping rectangle is overwritten by a rectangle covering the entire surface.
The AG_AnimFree() function releases all resources allocated by the given animation.
The playback state of an animation is described by a separate structure from AG_Anim, the AG_AnimState structure. This allows a same animation to be played back, for example, by different widgets. The AG_AnimState structure is as follows:
The AG_AnimInitState() function initializes an AG_AnimState structure. The structure should be subsequently freed by a call to AG_AnimStateDestroy().
The AG_AnimPlay() function starts playback. This is done by spawning a new thread which is responsible for incrementing the f member of AG_AnimState at a suitable rate. Unless looping is requested, the thread exits once the playback is finished.
AG_AnimStop() immediately stops playback. If the animation is not currently playing, the function is a no-op.
The AG_AnimSetFPS() function sets the frame rate for an animation playback context. The default frame rate is inherited from the AG_Anim structure (see AG_AnimSetOrigFPS()).
The AG_AnimSetLoop() and AG_AnimSetPingPong() functions enable or disable looping.
For the AG_AnimFrame structure:
|AG_Intro(3), AG_Rect(3), AG_Surface(3)|
|The AG_Anim structure first appeared in Agar 1.4.1.|