⭐10.画 扇形
pie(x1,y1,x2,y2,stangle,endangle);
//x,y看图片, stangle:扇形起始角的弧度,endangle:扇形终止角的弧度
#define PI 3.14 //把3.14当作360°
#include<stdio.h> #include<easyx.h> #include<graphics.h> #define PI 3.14 int main() { initgraph(400, 400); setbkcolor(RGB(164, 225, 202)); setaspectratio(1, -1); setorigin(200, 200); cleardevice(); pie(-50, 50, -150, -150, 0, PI / 1); getchar(); closegraph(); return 0; }
⭐11.画 圆弧
arc(x1,y1,x2,y2,stangle,enangle);//定义与扇形一样,不同的是圆弧就是一个弧
#include<stdio.h> #include<easyx.h> #include<graphics.h> #define PI 3.14 int main() { initgraph(400, 400); setbkcolor(RGB(164, 225, 202)); setaspectratio(1, -1); setorigin(200, 200); cleardevice(); arc(-50, 50, -150, -150, 0, PI / 1); getchar(); closegraph(); return 0; }
⭐12.把所有的点都连起来
ploygon用法(比如画三角形)
POINT points[]= { {0,100},{100,-100},{-100,-100} };//POINT结构数组,并传入三个点的坐标
polygon(points, 3);有多少个坐标,后面的数字就是多少
#include<stdio.h> #include<easyx.h> #include<graphics.h> int main() { initgraph(400, 400); setbkcolor(RGB(164, 225, 202)); setaspectratio(1, -1); setorigin(200, 200); cleardevice(); POINT points[] = { {0,100},{100,-100},{-100,-100} }; polygon(points, 3); getchar(); closegraph(); return 0; }
⭐13.不 把所有点都连起来
ployline();//不会连接首尾两个点,其他的与polygn一样
#include<stdio.h> #include<easyx.h> #include<graphics.h> #include<math.h> #define PI 3.14 int main() { initgraph(400, 400); setbkcolor(RGB(164, 225, 202)); cleardevice(); setaspectratio(1, -1); setorigin(200, 200); POINT points[3] = { {100,100},{0,0},{-100,100} }; polyline(points, 3); getchar(); closegraph(); return 0; }
⭐14. 设置图形边缘的颜色
setlinecolor();
#include<stdio.h> #include<easyx.h> #include<graphics.h> int main() { initgraph(400, 400); setbkcolor(RGB(164, 225, 202)); cleardevice(); setaspectratio(1, -1); setorigin(200, 200); setlinecolor(YELLOW);//先写setlinecolor circle(0, 0, 100); getchar(); closegraph(); return 0; }
⭐15.填充样式+填充的颜色
样式 在前面加上solid
circle-----soliodcircle
rectangle------solidrectangle
颜色 使用setfillcolor
#include<stdio.h> #include<easyx.h> #include<graphics.h> int main() { initgraph(400, 400); setbkcolor(RGB(164, 225, 202)); cleardevice(); setaspectratio(1, -1); setorigin(200, 200); setfillcolor(YELLOW);//先写setfillcolor solidcircle(0, 0, 100); getchar(); closegraph(); return 0; }
✨16.注意,填充颜色不包括描边
如果实现 填充颜色+描边 加上fill
circle-----fillcircle
#include<stdio.h> #include<easyx.h> #include<graphics.h> int main() { initgraph(400, 400); setbkcolor(RGB(164, 225, 202)); cleardevice(); setaspectratio(1, -1); setorigin(200, 200); setfillcolor(YELLOW); setlinecolor(RED); fillcircle(0,0,100); getchar(); closegraph(); return 0; }
如果写成circle而不是fillcircle
⭐ 17.设置描边的样式
setlinestyle(a,num);//a是样式 num是描边的粗细
#include<stdio.h> #include<easyx.h> #include<graphics.h> int main() { initgraph(400, 400); setbkcolor(RGB(164, 225, 202)); cleardevice(); setaspectratio(1, -1); setorigin(200, 200); setlinestyle(PS_ENDCAP_ROUND, 40);//圆形 round num=40 line(-100, 100, 100, 100); setlinestyle(PS_ENDCAP_SQUARE, 40);//方形 square line(-100, 50, 100, 50); setlinestyle(PS_ENDCAP_FLAT, 40);//平坦 flat line(-100, 0, 100, 0); getchar(); closegraph(); return 0; }