Easyx基本使用(三)
——绘制简单图形
1. 绘制点(putpixel)
void putpixel(int x,int y,COLORREF color
);
- x:点的x坐标
- y:点的y坐标
- color:点的颜色
- 返回值:无
#include <easyx.h>
#include <conio.h>int main(void) {// 1. 初始化图形设备initgraph(400, 400);// 2. to do....putpixel(10, 30, 0xffffff);putpixel(30, 30, 0xffffff);putpixel(50, 30, 0xffffff);putpixel(70, 30, 0xffffff);_getch();// 3. 关闭图形化设备,并释放资源closegraph();return 0;
}
2. 绘制直线(line)
void line(int x1,int y1,int x2,int y2
);
- x1:直线起始点x坐标
- y1:直线起始点y坐标
- x2:直线终止点x坐标
- y2:直线终止点y坐标
- 返回值:无
#include <easyx.h>
#include <conio.h>int main(void) {// 1. 初始化图形设备initgraph(400, 400);// 2. to do....line(10, 10, 300, 20);line(30, 100, 340, 100);line(200, 30, 200, 300);_getch();// 3. 关闭图形化设备,并释放资源closegraph();return 0;
}
3. 绘制扇形(pie)
void pie(int left,int top,int right,int bottom,double stangle,double endangle
);
- left:扇形所在椭圆的外切矩形的左上角x坐标
- top:扇形所在椭圆的外切矩形的左上角y坐标
- right:扇形所在椭圆的外切矩形的右下角x坐标
- bottom:扇形所在椭圆的外切矩形的右下角y坐标
- stangle:扇形的起始角弧度
- endangel:扇形的终止角弧度
- 返回值:无
#include <easyx.h>
#include <conio.h>int main(void) {// 1. 初始化图形设备initgraph(400, 400);// 2. to do....pie(100, 100, 300, 300, 0.2, 3);_getch();// 3. 关闭图形化设备,并释放资源closegraph();return 0;
}
4. 绘制椭圆弧(arc)
void arc(int left,int top,int right,int bottom,double stangle,double endangle
);
- left:扇形所在椭圆的外切矩形的左上角x坐标
- top:扇形所在椭圆的外切矩形的左上角y坐标
- right:扇形所在椭圆的外切矩形的右下角x坐标
- bottom:扇形所在椭圆的外切矩形的右下角y坐标
- stangle:扇形的起始角弧度
- endangel:扇形的终止角弧度
- 返回值:无
#include <easyx.h>
#include <conio.h>int main(void) {// 1. 初始化图形设备initgraph(400, 400);// 2. to do....arc(100, 100, 300, 300, 4, 2);_getch();// 3. 关闭图形化设备,并释放资源closegraph();return 0;
}
5. 绘制椭圆(ellipse)
void ellipse(int left,int top,int right,int bottom
);
-
left:椭圆的外切矩形的左上角x坐标
-
top:椭圆的外切矩形的左上角y坐标
-
right:椭圆的外切矩形的右下角x坐标
-
bottom:椭圆的外切矩形的右下角y坐标
-
返回值:无
#include <easyx.h>
#include <conio.h>int main(void) {// 1. 初始化图形设备initgraph(400, 400);// 2. to do,,,...ellipse(100, 100, 300, 200);_getch();// 3. 关闭图形化设备,并释放资源closegraph();return 0;
}
6. 绘制矩形(rectangle)
void rectangle(int left,int top,int right,int bottom
);
- left:矩形的左上角x坐标
- top:矩形的左上角y坐标
- right:矩形的右下角x坐标
- bottom:矩形的右下角y坐标
- 返回值:无
#include <easyx.h>
#include <conio.h>int main(void) {// 1. 初始化图形设备initgraph(400, 400);// 2. to do,,,...rectangle(100, 100, 300, 200);_getch();// 3. 关闭图形化设备,并释放资源closegraph();return 0;
}
7. 绘制圆形(fillcircle)
void fillcircle(int x,int y,int radius
);
- x:圆心的x坐标
- y:圆心的y坐标
- radius:圆的半径
- 返回值:无
#include <easyx.h>
#include <conio.h>int main(void) {// 1. 初始化图形设备initgraph(400, 400);// 2. to do,,,...circle(100, 200, 50); // 无填充圆// 设置填充颜色setfillcolor(0x123123);fillcircle(200, 200, 50); // 填充圆_getch();// 3. 关闭图形化设备,并释放资源closegraph();return 0;
}
8. 其他绘图函数
传送门