sublime text 配置C语言使用 EGE图形库
最近迷单片机,
C语言学习中,
看到网上有简绍图形库EGE,
下载玩了一下。
喜欢sublime text清爽,方便, 具体配置见下方。
=============================================
基础条件:
一。安装mingw64
二。下载EGE 20.08,解压后,将对应文件放到
将其中的ege.h、graphics.h和ege
\mingw64\x86_64-w64-mingw32\include
graphics64.lib
\mingw64\x86_64-w64-mingw32\lib
下载地址: https://xege.org/install_and_config
库文件API:https://xege.org/manual/api/index.htm
三。配置sublime text:
{
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c++",
"variants":
[
{
"name": "Run application and console",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -lgraphics64 -lgdiplus -luuid -lmsimg32 -lgdi32 -limm32 -lole32 -loleaut32 -lwinmm && \"${file_path}/${file_base_name}\" && DEL \"${file_base_name}.exe\" >> nul"
},
{
"name": "Run application",
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -mwindows -lgraphics64 -lgdiplus -luuid -lmsimg32 -lgdi32 -limm32 -lole32 -loleaut32 -lwinmm && \"${file_path}/${file_base_name}\" && DEL \"${file_base_name}.exe\" >> nul"
}
]
}
=======================================================
画个圆环,,,Ctrl+B 运行,
画个圆环,,,Ctrl+B 运行,
#include <graphics.h>//包含EGE的头文件
#include <math.h> //包含math的头文件
int main()
{
initgraph(640, 480);//初始化图形界面
int x=640/2;
int y=480/2;
int r=200;
setbkcolor(WHITE);
for(int i=0;i<360;i++){
char R=rand()%(0Xff+1);
char G=rand()%(0Xff+1);
char B=rand()%(0Xff+1);
setcolor(EGERGB(R,G,B));//设置绘画颜色为红色
line(x+r*cos(PI*i/180)/2,y+r*sin(PI*i/180)/2,x+r*cos(PI*i/180),y+r*sin(PI*i/180));
}
getch();//暂停,等待键盘按键
closegraph();//关闭图形界面
return 0;
}
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。