C Language and Libraries Help (clang.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
ANIMATE.C
◄Up► ◄Contents► ◄Index► ◄Back►
─────Run-Time Library───────────────────────────────────────────────────────
/* ANIMATE.C illustrates animation functions including:
* _getimage _putimage (DOS-only)
* _imagesize _grstatus
*/
#include <conio.h>
#include <stddef.h>
#include <stdlib.h>
#include <malloc.h>
#include <graph.h>
short action[5] = { _GPSET, _GPRESET, _GXOR, _GOR, _GAND };
char *descrip[5] = { "PSET ", "PRESET", "XOR ", "OR ", "AND " };
void exitfree( char __huge *buffer );
void main()
{
char __huge *buffer;
long imsize;
short i, x, y = 30;
if( !_setvideomode( _MAXRESMODE ) )
exit( 1 );
/* Measure the image to be drawn and allocate memory for it. */
imsize = _imagesize( -16, -16, +16, +16 );
buffer = _halloc( imsize, 1 );
if( buffer == NULL )
exit( 1 );
_setcolor( 3 );
for ( i = 0; i < 5; i++ )
{
/* Draw ellipse at new position and get a copy of it. */
x = 50; y += 40;
_ellipse( _GFILLINTERIOR, x - 15, y - 15, x + 15, y + 15 );
_getimage( x - 16, y - 16, x + 16, y + 16, buffer );
if( _grstatus() )
exitfree( buffer ); /* Quit on error */
/* Display action type and copy a row of ellipses with that type. */
_settextposition( 1, 1 );
_outtext( descrip[i] );
while( x < 260 )
{
x += 5;
_putimage( x - 16, y - 16, buffer, action[i] );
if( _grstatus() < 0 ) /* Ignore warnings, quit on errors */
exitfree( buffer );
}
_getch();
}
exitfree( buffer );
}
void exitfree( char __huge *buffer )
{
_hfree( buffer );
exit( !_setvideomode( _DEFAULTMODE ) );
}
-♦-