easyx:
#include "iostream"
#include "easyx.h"
#include "cstdio"
using namespace std;
int main() {
initgraph(800, 600);
setorigin(400, 300);
setaspectratio(1, -1);
//绘制多边形:polygon(const POINT *points,int num);
//points 是一个POINT类型的指针,num指明数组中有多少个元素
//结构POINT是easyx中自带的
//原型:
//typedef struct{
// long x;
// long y;
//}POINT;
/*绘制三边型*/POINT points[] = {{0,200},{200,-200},{-200,-200}};
polygon(points, 3);
/*绘制四边型*/POINT points2[] = { {-200,100},{200,100},{200,-100},{-200,-100} };
polygon(points2, 4);
/*绘制梯形*/POINT points3[] = { {-100,100},{100,100},{200,-100},{-200,-100} };
polygon(points3, 4);
getchar();
closegraph();
}
#include "iostream"
#include "easyx.h"
#include "cstdio"
using namespace std;
int main() {
initgraph(800, 600);
setorigin(400, 300);
setaspectratio(1, -1);
//更改描边颜色:setlinecolor(color)
setlinecolor(YELLOW);
circle(0, 0, 200);
//设置画线样式(原型):
//setlinestyle(
//int style;
// int thickness=1;
// const DWORD *puserstyle =NULL;
// DWORD userstylecount=0);
//重点看前两个参数(后面两个可以不设):style:画线样式,thickness(就是粗细):画线宽度,单位为像素,默认1像素
//const DWORD *puserstyle =NULL; 用户自定义样式
//DWORD userstylecount=0 自定义样式数量
//画线样式:style可分为(线型,端点,连接)样式
//线型就是实线,虚线这种
/*粗细为5的实线*/setlinestyle(PS_SOLID, 5);
line(-300, 200, 300, 200);
/*粗细为5的虚线*/setlinestyle(PS_DASH, 5);
line(-300, 100, 300, 100);
//端点就是整个形状
//连接就是做多边形时两边相结合时,结合地方的样式
//填充绘制图形:在描边绘制图形的函数前面加上solid
//例:填充绘制圆形:solidcircle(int x,int y,int radius)
//更改填充颜色:setfillcolor(color)
setfillcolor(RED);
solidcircle(-200, -200, 50);
//既要描边又要填充绘制图形,在函数名前加上fill
setfillcolor(BLUE);
setlinecolor(YELLOW);
setlinestyle(PS_DASH, 12);
fillcircle(0, 0, 200);
getchar();
closegraph();
//线型
/*PS_SOLID(实线)
PS_DASH(虚线)
PS_DOT(点线)
PS_DASHDOT(线与点)
PS_DASHDOTDOT(线点点)
PS_NULL(不可见)*/
//端点
/*PS_ENDCAP_ROUND(端点为圆形)
PS_ENDCAP_SQUARE(端点为方形)
PS_ENDCAP_FLAT(端点为平坦)*/
//连接
/*PS_JOIN_BEVEL(连接处为斜面)
PS_JOIN_MITER(连接处为斜接)
PS_JOIN_ROUND(连接处为圆弧)*/
}
#include "iostream"
#include "easyx.h"
#include "cstdio"
#define PI 3.14
using namespace std;
int main() {
initgraph(1024, 1024);
//更改窗体颜色:setbkcolor(color),只有这个相当于你只有一只白色的笔,还需要填充整个窗体
//清空绘图设备,它会使用当前的背景色填充整个窗体:cleardevice()
setbkcolor(WHITE);
cleardevice();
setlinecolor(BLACK);
setfillcolor(BLUE);
setlinestyle(PS_SOLID, 10);
fillellipse(118, 125, 990, 931);
Sleep(1000);
setlinecolor(BLACK);
setfillcolor(WHITE);
fillellipse(189, 271, 919, 931);
fillellipse(375, 170, 555, 420);
fillellipse(555, 170, 735, 420);
Sleep(1000);
setfillcolor(BLACK);
fillcircle(484, 333, 25);
fillcircle(617, 333, 25);
Sleep(1000);
setfillcolor(WHITE);
setlinecolor(WHITE);
fillcircle(484, 333, 10);
fillcircle(617, 333, 10);
Sleep(1000);
setfillcolor(RED);
setlinecolor(BLACK);
fillcircle(554, 420, 35);
line(554, 460, 554, 828);
Sleep(1000);
arc(320, 510, 789, 827, PI, 2 * PI); //因为一开始没有翻转y轴,所以起始角度为180,结束为360
Sleep(1000);
line(125,313,296,410);
line(83,444,270,474);
line(83,595,262,537);
line(819,414,990,320);
line(845,478,1029,448);
line(853,542,1029,660);
Sleep(1000);
getchar();
closegraph();
}