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.
FIGURE.C
◄Up► ◄Contents► ◄Index► ◄Back►
─────Run-Time Library───────────────────────────────────────────────────────
/* FIGURE.C illustrates graphics drawing functions including:
* _setpixel _lineto _moveto _rectangle _ellipse
* _pie _arc _getarcinfo (DOS-only)
*
* Window versions of graphics drawing functions (such as _rectangle_w,
* _ellipse_wxy, and _lineto_w) are illustrated in WINDOW.C and GEDIT.C.
*/
#include <conio.h>
#include <stdlib.h>
#include <graph.h>
void main()
{
short x, y;
struct _xycoord xystart, xyend, xyfill;
if( !_setvideomode( _MAXRESMODE ) ) /* Find a valid graphics mode */
exit( 1 ); /* No graphics available */
for( x = 10, y = 50; y < 90; x += 2, y += 3 )/* Draw pixels */
_setpixel( x, y );
_getch();
for( x = 60, y = 50; y < 90; y += 3 ) /* Draw lines */
{
_moveto( x, y );
_lineto( x + 20, y );
}
_getch();
x = 110; y = 70; /* Draw rectangles */
_rectangle( _GBORDER, x - 20, y - 20, x, y );
_rectangle( _GFILLINTERIOR, x + 20, y + 20, x, y );
_getch();
x = 160; /* Draw ellipses */
_ellipse( _GBORDER, x - 20, y - 20, x, y );
_ellipse( _GFILLINTERIOR, x + 20, y + 20, x, y );
_getch();
x = 210; /* Draw pies */
_pie( _GBORDER, x - 20, y - 20, x, y,
x - 10, y - 20, x - 20, y - 10 );
_pie( _GFILLINTERIOR, x + 20, y + 20, x, y,
x, y + 10, x + 10, y );
x = 260; /* Draw arcs */
_arc( x - 20, y - 20, x, y, x - 10, y - 20, x - 20, y - 10 );
_arc( x + 20, y + 20, x, y, x, y + 10, x + 10, y );
/* Get endpoints of arc and enclose the figure, then fill it. */
_getarcinfo( &xystart, &xyend, &xyfill );
_moveto( xystart.xcoord, xystart.ycoord );
_lineto( xyend.xcoord, xyend.ycoord );
_floodfill( xyfill.xcoord, xyfill.ycoord, _getcolor() );
_getch();
_setvideomode( _DEFAULTMODE );
}
-♦-