在C中如何绘图

来源:百度知道 编辑:UC知道 时间:2024/06/07 06:13:55

在头文件graphics.h中有许多绘图函数。可以直接用这些绘图函数画图
比如:moveto(points[i].x, points[i].y); lineto(points[j].x, points[j].y);
这两个函数就是画条直线
这个函数就是画个圆
circle(xcenter,ycenter,radius );
xcenter,ycenter,radius 分别表示圆心,半径

#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)
{
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)/