#include "graphics.h"
#include "math.h"
#include "dos.h"
#include "conio.h"
#include "stdlib.h"
#include "stdio.h"
#include "stdarg.h"
#define maxpts 15
#define pi 3.1415926
struct pts {
int x, y;
};
double aspectratio = 0.85;
void linetodemo(void)
{
typedef struct viewporttype vp;
struct pts points[maxpts];
int i, j, h, w, xcenter, ycenter;
int radius, angle, step;
double rads;
printf(" moveto / lineto demonstration");
getviewsettings(&vp);
h = vp.bottom - vp.top;
w = vp.right - vp.left;
xcenter = w / 2; /* determine the center of circle */
ycenter = h / 2;
radius = (h - 30) / (aspectratio * 2);
step = 360 / maxpts; /* determine # of increments */
angle = 0; /* begin at zero degrees */
for (i = 0; irads = (double)angle * pi / 180.0; /* convert angle to radians */
points[i].x = xcenter + (int)(cos(rads) * radius);
points[i].y = ycenter - (int)(sin(rads) * radius * aspectratio);
angle += step; /* move to next increment */
}
circle(xcenter, ycenter, radius); /* draw bounding circle */
for (i = 0; ifor(j = i; jmoveto(points[i].x, points[i].y); /* move to beginning of cord */
lineto(points[j].x, points[j].y); /* draw the cord */
main()
{
int driver, mode;
driver = cga; mode = cgac0;
initgraph(&driver, &mode, "");
setcolor(3);
setbkcolor(green);
linetodemo();
}