该库要使用c++
easyx库下载即文档查看请点此处.
//原型
HWND initgraph(
int width,
int height,
int flag = NULL
);
值 | 含义 |
---|---|
EW_DBLCLKS | 在绘图窗口中支持鼠标双击事件。 |
EW_NOCLOSE | 禁用绘图窗口的关闭按钮。 |
EW_NOMINIMIZE | 禁用绘图窗口的最小化按钮。 |
EW_SHOWCONSOLE | 显示控制台窗口。 |
#include
#include
//或#include
int main()
{
initgraph(520, 520,0);
//也可写成initgraph(520, 520);
while (1);
return 0;
}
//原型
void outtextxy(
int x,
int y,
LPCTSTR str
);
void outtextxy(
int x,
int y,
TCHAR c
);
//参数:
//x 字符串输出时头字母的 x 轴的坐标值。
//y 字符串输出时头字母的 y 轴的坐标值。
//str 待输出的字符串的指针。
//c 待输出的字符。
//函数原型:
int sprintf(char* const _Buffer,char const* const _Format)
int sprintf_s(char* const _Buffer,size_t const _BufferCount,char const* const _Format)
//_Buffer 打印的位置
#include
#include
//或#include
void outtextxy_int(int x, int y, int data)
{
char str[20] = "";
sprintf_s(str, 20, "%d", data);
outtextxy(x, y, str);
}
void outtextxy_double(int x, int y, double data)
{
char str[20] = "";
sprintf_s(str, 20, "%lf", data);
outtextxy(x, y, str);
}
int main()
{
initgraph(520, 520);
outtextxy_int(100, 100, 1314);
outtextxy_double(100, 120, 1314.520);
while (1);
return 0;
}
格式控制
//函数原型:
void settextstyle(
int nHeight,
int nWidth,
LPCTSTR lpszFace
);
//函数原型:
void settextcolor(COLORREF color);
//函数原型:
COLORREF RGB(
BYTE byRed, // 颜色的红色部分
BYTE byGreen, // 颜色的绿色部分
BYTE byBlue // 颜色的蓝色部分
);
//以下代码实现一个圆从左向右移动,会有比较明显的闪烁。
//请取消 main 函数中的三个注释,以实现批绘图功能,可以消除闪烁。
#include
int main()
{
initgraph(640, 480);
// BeginBatchDraw();
setlinecolor(WHITE);
setfillcolor(RED);
for (int i = 50; i < 600; i++)
{
circle(i, 100, 40);
floodfill(i, 100, WHITE);
// FlushBatchDraw();
Sleep(10);
cleardevice();
}
// EndBatchDraw();
closegraph();
}