//导入Easyx图形库
#include<graphics.h>
#include<Windows.h>
int main(void) {
//初始化画布
initgraph(640, 480);//长640 宽380
//画一个圆
circle(320, 240, 200);//长320 宽 240 半径200
system("pause");
closegraph();//关闭图形库
return 0;
}
EasyX 图形库的进阶实现小案例
实现如图的例子:
#include<iostream>
#include<Windows.h>
#include<graphics.h>
int main(void) {
initgraph(640, 480);
setbkcolor(RGB(64, 128, 128));//设置背景颜色 采用RGB
cleardevice();//用背景色清空整个屏幕(整个画布)
//设置划线(画笔)颜色
setlinecolor(RGB(255, 0, 0));
setlinestyle(PS_SOLID, 10);//线段粗细
circle(320, 240, 200);
//在屏幕制定位置输入文字
settextcolor(RGB(255, 255, 0));//设置文本颜色
settextstyle(100, 0, _T("微软雅黑"));//字体大小
outtextxy(170, 190, _T("无码高清"));//输出文字 文字位置
//画一条斜线
line(180, 380, 460, 100);
system("pause");
closegraph();
return 0;
}
实现如图的例子:
#include<iostream>
#include<Windows.h>
#include<graphics.h>
int main(void) {
initgraph(600, 400);
loadimage(0, _T("bg.jpg"));
settextcolor(RGB(255, 255, 0));
settextstyle(30, 0, _T("微软雅黑"));
//矩形
rectangle(300, 40, 550, 80);
outtextxy(310, 45, _T("1-网站 404 攻击"));
rectangle(300, 100, 550, 140);
outtextxy(310, 105, _T("2-网站篡改攻击"));
rectangle(300, 160, 550, 200);
outtextxy(310, 165, _T("3-网站攻击修改"));
rectangle(300, 220, 550, 260);
outtextxy(310, 225, _T("4-查看攻击记录"));
rectangle(300, 280, 550, 320);
outtextxy(310, 285, _T("5-退出"));
system("pause");
closegraph();
return 0;
}
实现音频播放
#include<graphics.h>
#include<Windows.h>
#include<mmsystem.h>
#pragma comment(lib,"winmm.lib")
int main(void) {
initgraph(800, 513);
loadimage(0, _T("_0000_图层-148.jpg"));
mciSendString(_T("play 极乐净土.mp3 repeat"), 0, 0, 0);
system("pause");
closegraph();
}