void setlinecolor(COLORREF color); //设置线条描边颜色
cleardevice(); //清屏操作
void setorigin(int x,inty); //int x int y表示远点在物理坐标上的x和y坐标
void setaspectratio(float xasp, float yasp); //float xasp在x方向上的缩放因子float yasp,在y方向上的缩放因子
void putpixel(int x, int y, COLORREF color); //像素点的绘制
void line(int x1,int y1,int x2,int y2); //画直线(x1,y1)起始坐标(y1,y2)终点坐标
void rectangle(int left,int top,int right,int bottom); //(left,top)矩形左上角坐标,(right,bottom)矩形右下角坐标
void ellipse(int left,int top,int right,int bottom); //(left,top)内切圆矩形左上角坐标,(right,bottom)内切圆矩形右下角坐标
void roundrect(int left,int top,int right,int bottom,int ellipsewidth);//(left,top)圆角矩形左上角坐标,(right,bottom)圆角矩形右下角坐标,
ellipsewidth表示构成圆角矩形的圆角的椭圆宽度,
ellipseheight表示构成圆角矩形的圆角的椭圆高度
void pie(//绘制扇形
int left,
int top,
int right,
int bottom
double stangle,//扇形的起始角度的弧度
double endangle//扇形的终止的弧度
);
void arc(//绘制圆弧
int left,
int top,
int right,
int bottom
double stangle,//圆弧的起始角度的弧度
double endangle//圆弧的终止角的弧度
);
绘制多边形(封闭的)
void polygon(
const POINT *points,//POINT类型的指针,指向结构POINT数组的首元素表示每个点的坐标
int num //表示数组中有多少个元素
);
绘制不封闭的图形
void polyline(
const POINT *points,//POINT类型的指针,指向结构POINT数组的首元素表示每个点的坐标
int num //表示数组中有多少个元素
);
//播放音乐
MCIEROR mciSendString(
LPCTSTR lpszCommand,//mci命令符
LPTSTR lpszReturnString,//null
UINT cchReturn, //0
HANDLE hwndCallback //null
);
总结
播放音乐 mciSendString
绘制点 putpixel
绘制直线 line
绘制圆 circle
绘制矩形 retangle
绘制椭圆 ellipse
绘制圆角矩形roundrect
绘制扇形 pie
绘制圆弧 arc
绘制多边形
polygon 函数绘制封闭的函数
polyline函数绘制不封闭的图形
void main() {
initgraph(WIDTH, HEIGHT);
//以物理坐标为准设置逻辑坐标的原点
setorigin(200, 200);
//x,y轴的反转 -1y轴旋转一百八十度,相当于数学中的坐标系
setaspectratio(1, -1);
//设置线条描边颜色
setlinecolor(RED);
//绘制像素点,
putpixel(0, 0, RED);
//画直线,坐标轴
line(-100, 0, 100, 0);
line(0, 100, 0, -100);
//画矩形
rectangle(0, 0, 100, -100);
//画矩形的内切圆
ellipse(0, 0, 100, -100);
//绘制圆角矩形
roundrect(100, 100, -100, -100, 100, 100);
//绘制扇形
pie(-200, 200, -100, 100, 0, 3.14 / 2);
//绘制圆弧
arc(200, 200, 100, 100, 0, 3.14 / 2);
getchar();//暂停
//绘制多边形
POINT points[] = { {0,100},{100,-100},{-100,-100} };
POINT points1[4] = { {200,200},{-200,200},{-200,-200},{200,-200} };
polygon(points, 3);
polygon(points1, 4);
//绘制多边形(不封闭的w)
POINT points2[5] = { {-200,200},{-100,-100},{0,50},{100,-100},{200,200} };
polyline(points2, 5);
getchar();//暂停
}