/* Program LINE_1.C
**
** Illustrates how to draw a line. Note that xy screen coords are
** 0,0 (upper left) to 500,700 (lower right).
**
** Cheryl Melvin, 27 Sept, 30
** P. H. Anderson, 30 Sept 93
**
*/
#include <stdio.h>
#include <graphics.h>
#include <dos.h>
void main(void)
{
int graphdriver = DETECT, graphmode, linestyle=0;
int i, x, y;
initgraph(&graphdriver, &graphmode, "c:\\turboc");
/* detect and initialize graphics system
** Note that when graphdriver is DETECT, the graphmode is auto
** set to the highest resolution available.
** "c:\\tc\\bgi" is the path full path name to the graphics
** driver
setcolor(RED); /* see program COLOR for full listing of colors*/
outtextxy(10, 10, "Line Demo");
/* outputs text at x, y using default font and size */
setcolor(GREEN);
/* draw some horizontal lines */
for (i=0, y=0; i<10; i++)
{
setlinestyle(SOLID_LINE, linestyle, NORM_WIDTH);
/* options are SOLID_LINE, DOTTED_LINE, CENTER_LINE
** and DASHED_LINE. linestyle is for user defined line
** styles.
** widths are NORM_WIDTH and THICK_WIDTH
*/
moveto(0,y);
lineto(700,y);
y += 50;
}
sleep(5); /* pause to admire */
setcolor(MAGENTA);
for (i=0, x=0; i<10; i++)
{
setlinestyle(DASHED_LINE, linestyle, THICK_WIDTH);
/* options are SOLID_LINE, DOTTED_LINE, CENTER_LINE
** and DASHED_LINE. linestyle is for user defined line
** styles.
** widths are NORM_WIDTH and THICK_WIDTH
*/
moveto(x,0);
lineto(x, 50+i*50);
x += 70;
}
sleep(10);
closegraph();
}