左上第1:
二、设置画笔颜色
3:保存
4:打开
五、设置画笔厚度
6:更改虚线 实线
7:复制粘贴
8:移动
9:填充
10:获得鼠标点击处的颜色
11:画线
$^&%$^%&^^
后面的。
分别是
窗口大小:1000*1000
编译环境:(不知道高版行不行)
语言:C (.cpp)
*
#include<graphics.h> #include<iostream> #include<windows.h> #include<easyx.h> #include<Windows.h> #include <conio.h> #include <conio.h> #include <string> #pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" ) #include <time.h> #include <map> #include <cmath> #include <dos.h> #include<queue> #include<cstring> #include<cmath> #include<math.h> #include<stack> #include<vector> #define HWNDNAMEUP 012FF56D16R0KD1 #define HWNDNAMEDOWN 012FF56D35C02S1 #define HWNDNAMEON 012FF56D35C0Z10 #undef UNICODE #undef _UNICODE #define SEED (int)time(0) int cx=GetSystemMetrics(SM_CXSCREEN); int cy=GetSystemMetrics(SM_CYSCREEN); HWND hwnd=GetForegroundWindow(); using namespace std; #define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0) int _Tstyle=2; bool li=1; COLORREF _Tcolor=RGB(255,255,255); int fp=0,fps=0,sta; bool h=0,nn=0,pp=0; bool rec=0,cir=0,rr=0; MOUSEMSG m; COLORREF filln=RGB(255,255,255); void improveWord(LOGFONT* word, int size, LPCSTR style) { gettextstyle(word); word->lfHeight = size; _tcscpy(word->lfFaceName, style); word->lfQuality = ANTIALIASED_QUALITY; settextstyle(word); } void print(){ LOGFONT f; improveWord(&f, 18, _T("微软雅黑")); outtextxy(0,0,"Press H:Help Press D: setcolor Press S: setstyle Press P: save image Press Q: open image"); outtextxy(0,15,"Press L: dotted line/solid line Press A: draw text Press G: Getcolor Press Y: rectangle"); outtextxy(0,30,"Press C: copy Press M: move Press Mid_button: restore default settings Press Z: circle"); outtextxy(0,45,"Press F: Fill Press R: Line Press F5: debug Press F6: refresh Press J: round retangle"); improveWord(&f, 20, _T("微软雅黑")); } void init(){ srand(SEED); initgraph(1000,1000/*,EW_SHOWCONSOLE*/,EW_DBLCLKS); SetWorkingImage(); LOGFONT initn; improveWord(&initn, 20, _T("微软雅黑")); setorigin(0,0); setbkmode(TRANSPARENT); setrop2(R2_COPYPEN); setbkcolor(RGB(0,0,0); cleardevice(); setlinestyle(PS_SOLID,2); settextcolor(RGB(255,255,255)); setlinestyle(PS_SOLID,2); setlinecolor(RGB(150,150,150); setfillcolor(RGB(100,100,100); solidrectangle(1,979,1000,1000); solidrectangle(0,0,1000,70); line(1,979,1000,979); setlinecolor(WHITE)
print();
std::cout<<"style:"<<&_Tstyle<<endl<<"color:"<<&_Tcolor<<endl<<"line:"<<&li<<endl<<"fps:"<<&fps<<endl<<"fp:"<<&fp<<endl<<"sta:"<<&sta<<endl<<"Filltype:"<<&h<<endl<<"Fillcolor:"<<&filln<<endl;
}
void text(){
outtextxy(0,0,"style:");
setfillcolor(_Tcolor);
TCHAR st[50];
_stprintf(st, _T("%d"),_Tstyle);
outtextxy(0, 17, st);
outtextxy(0,34,"color:");
TCHAR R[50];
_stprintf(R, _T("%d"),GetRValue(_Tcolor));
outtextxy(0, 51, R);
TCHAR G[50];
_stprintf(G, _T("%d"),GetGValue(_Tcolor));
outtextxy(30, 51, G);
TCHAR B[50];
_stprintf(B, _T("%d"),GetBValue(_Tcolor));
outtextxy(60, 51, B);
outtextxy(150, 51, "///");
}
bool lbutton(){
if(MouseHit())m=GetMouseMsg();
switch(m.uMsg){
case WM_LBUTTONUP:
return 1;
}
return 0;
}
bool ldown(){
if(MouseHit())m=GetMouseMsg();
switch(m.uMsg){
case WM_LBUTTONDOWN:
return 1;
}
return 0;
}
bool lclk(){
if(MouseHit())m=GetMouseMsg();
switch(m.uMsg){
case WM_LBUTTONDBLCLK:
return 1;
}
return 0;
}
void painttnt(){
setfillcolor(RGB(100,100,100));solidrectangle(0,0,1000,70);
print();
text();
}
void paint(){
setlinestyle(PS_SOLID,2);
setlinecolor(RGB(150,150,150));
setfillcolor(RGB(100,100,100));
solidrectangle(1,979,1000,1000);
solidrectangle(0,0,100,70);/*
line(1,979,1000,979);
setlinecolor(WHITE);*/
setlinestyle(PS_SOLID, 2);
outtextxy(150, 51, "///");
// setlinestyle(PS_SOLID, _Tstyle);
int xx=m.x,yy=m.y;
if(MouseHit())m=GetMouseMsg();
TCHAR s[5];
_stprintf(s, _T("%d"), m.x);
outtextxy(40, 980, s);
outtextxy(20, 980, "x:");
TCHAR s2[5];
_stprintf(s2, _T("%d"), m.y-71);
outtextxy(100, 980, s2);
outtextxy(80, 980, "y:");
outtextxy(300,980,"Size:1000x910(max: 999x909)");
TCHAR s3[5];
_stprintf(s3, _T("%d"), fps);
outtextxy(180, 980, s3);
outtextxy(140, 980, "fps:");
setfillcolor(RGB(100,100,100));
solidrectangle(900,980,1000,1000);
outtextxy(900, 980, "print...");
if(li==1)setlinestyle(PS_SOLID,_Tstyle*2);
else setlinestyle(PS_DASH|PS_SOLID,_Tstyle*2);
if(!KEY_DOWN('H'))setfillcolor(RGB(100,100,100));solidrectangle(0,0,1000,70);
if(_Tstyle>5){
setfillcolor(RGB(100,100,100));solidrectangle(0,0,1000,70);
}
text();
setlinecolor(_Tcolor);
if(m.y>70 && m.y<979 && yy>70 && yy<979){
if(!h && !nn && !pp && !rec && !cir && !rr){
if(KEY_DOWN(VK_LBUTTON)){
//solidcircle(m.x,m.y,_Tstyle);
line(xx,yy,m.x,m.y);
}
}
if(h){
nn=0;pp=0;rec=0;cir=0;
if(KEY_DOWN(VK_LBUTTON)){
/*char r[50],g[50],b[50];
InputBox(r, 40, "FillRed:");
InputBox(g, 40, "FillGreen:");
InputBox(b, 40, "FillBlue:");
int R,G,B;
sscanf(r, "%d", &R);
sscanf(g, "%d", &G);
sscanf(b, "%d", &B);
filln=RGB(R,G,B);*/
floodfill(m.x,m.y,getpixel(m.x,m.y),FLOODFILLSURFACE);
painttnt();
}
}
if(nn){
if(KEY_DOWN(VK_LBUTTON)){
_sleep(20);
_Tcolor=getpixel(m.x,m.y);
nn=0;
}
}
if(pp && KEY_DOWN(VK_LBUTTON)){
int xs=m.x,ys=m.y;
_sleep(150);
while(!lbutton());
line(xs,ys,m.x,m.y);
}
if(rec && KEY_DOWN(VK_LBUTTON)){
int xs=m.x,ys=m.y;
_sleep(150);
while(!lbutton());
rectangle(xs,ys,m.x,m.y);
}
if(cir && KEY_DOWN(VK_LBUTTON)){
int xs=m.x,ys=m.y;
_sleep(150);
while(!lbutton());
ellipse(xs,ys,m.x,m.y);
}
if(rr && KEY_DOWN(VK_LBUTTON)){
int xs=m.x,ys=m.y;
_sleep(150);
while(!lbutton());
roundrect(xs,ys,m.x,m.y,abs(m.x-xs)/4,abs(m.y-ys)/4);
}
}
if(KEY_DOWN(VK_MBUTTON)){_Tstyle=2;_Tcolor=RGB(255,255,255);li=1;}
}
void paintbutton(){
setfillcolor(RGB(50,50,50));
solidrectangle(50,0,95,50);
solidrectangle(100,0,145,50);
solidrectangle(150,0,195,50);
solidrectangle(200,0,245,50);
solidrectangle(250,0,295,50);
solidrectangle(300,0,345,50);
solidrectangle(350,0,360,50);
solidrectangle(400,0,445,50);
solidrectangle(450,0,495,50);
solidrectangle(450,0,495,50);
if(!h){setfillcolor(RGB(50,50,50));solidrectangle(500,0,545,50);}
if(h){setfillcolor(RGB(150,150,150));solidrectangle(500,0,545,50);}
if(!nn){setfillcolor(RGB(50,50,50));solidrectangle(550,0,595,50);}
if(nn){setfillcolor(RGB(150,150,150));solidrectangle(550,0,595,50);}
if(!pp){setfillcolor(RGB(50,50,50));solidrectangle(600,0,645,50);}
if(pp){setfillcolor(RGB(150,150,150));solidrectangle(600,0,645,50);}
if(!rec){setfillcolor(RGB(50,50,50));solidrectangle(650,0,695,50);}
if(rec){setfillcolor(RGB(150,150,150));solidrectangle(650,0,695,50);}
if(!cir){setfillcolor(RGB(50,50,50));solidrectangle(700,0,745,50);}
if(cir){setfillcolor(RGB(150,150,150));solidrectangle(700,0,745,50);}
if(!rr){setfillcolor(RGB(50,50,50));solidrectangle(750,0,795,50);}
if(rr){setfillcolor(RGB(150,150,150));solidrectangle(750,0,795,50);}
if(KEY_DOWN(VK_LBUTTON)){
if(m.x>50 && m.y>0 && m.x<95 && m.y<50){
char str[10010];
InputBox(str, 10000, "Word:");
char hx[50],hy[50],size[50];
InputBox(hx, 40, "X:");
InputBox(hy, 40, "Y:");
InputBox(size, 40, "Size:");
int HX,HY,SI;
sscanf(hx, "%d", &HX);
sscanf(hy, "%d", &HY);
sscanf(size, "%d", &SI);
settextcolor(_Tcolor);
LOGFONT L;
improveWord(&L, SI, _T("微软雅黑"));
outtextxy(HX,HY+70,str);
improveWord(&L, 20, _T("微软雅黑"));
settextcolor(RGB(255,255,255));
}
if(m.x>100 && m.y>0 && m.x<145 && m.y<50){
char r[50],g[50],b[50];
InputBox(r, 40, "Red:");
InputBox(g, 40, "Green:");
InputBox(b, 40, "Blue:");
int R,G,B;
sscanf(r, "%d", &R);
sscanf(g, "%d", &G);
sscanf(b, "%d", &B);
_Tcolor=RGB(R,G,B);
}
if(m.x>150 && m.y>0 && m.x<195 && m.y<50){
setfillcolor(RGB(100,100,100));
solidrectangle(900,980,1000,1000);
LOGFONT e;
improveWord(&e, 20, _T("微软雅黑"));
outtextxy(900, 980, "save...");
IMAGE img;
getimage(&img, 0, 70, 1000, 908);
saveimage(/*"C:\\Users\C\Desktop\outputimage.bmp"*/"D:\\test.bmp",&img);
}
if(m.x>200 && m.y>0 && m.x<245 && m.y<50){
setfillcolor(RGB(100,100,100));
solidrectangle(900,980,1000,1000);
LOGFONT e;
improveWord(&e, 20, _T("微软雅黑"));
outtextxy(900, 980, "open...");
IMAGE im2;
loadimage(&im2,"D:\\test.bmp");
putimage(0,70,&im2);
}
if(m.x>250 && m.y>0 && m.x<295 && m.y<50){
_Tstyle=1;
char s[10];
InputBox(s, 10, "style:");
int r;
sscanf(s, "%d", &r);
if(r<=0)r=1;
_Tstyle=r;
}
if(m.x>300 && m.y>0 && m.x<345 && m.y<50){
if(li==1)li=0;
else li=1;
_sleep(150);
}
if(m.x>400 && m.y>0 && m.x<445 && m.y<50){
char left[50],top[50],right[50],button[50];
InputBox(left, 40, "Left:");
InputBox(top, 40, "Top:");
InputBox(right, 40, "Right:");
InputBox(button, 40, "Button:");
int LE,TO,RI,BU;
sscanf(left, "%d", &LE);
sscanf(top, "%d", &TO);
sscanf(right, "%d", &RI);
sscanf(button, "%d", &BU);
IMAGE tom;
getimage(&tom, LE, TO+71, RI-LE,BU-TO+71);
char cx[50],cy[50];
InputBox(cx, 40, "Cope X:");
InputBox(cy, 40, "Cope Y:");
int cX,cY;
sscanf(cx, "%d", &cX);
sscanf(cy, "%d", &cY);
putimage(cX,cY+71,&tom);
}
if(m.x>450 && m.y>0 && m.x<495 && m.y<50){
char left2[50],top2[50],right2[50],button2[50];
InputBox(left2, 40, "Left:");
InputBox(top2, 40, "Top:");
InputBox(right2, 40, "Right:");
InputBox(button2, 40, "Button:");
int LE2,TO2,RI2,BU2;
sscanf(left2, "%d", &LE2);
sscanf(top2, "%d", &TO2);
sscanf(right2, "%d", &RI2);
sscanf(button2, "%d", &BU2);
IMAGE tom;
getimage(&tom, LE2, TO2+71, RI2-LE2,BU2-TO2+71);
setfillcolor(RGB(0,0,0));
solidrectangle(LE2,TO2+71,RI2,BU2+71);
char cx2[50],cy2[50];
InputBox(cx2, 40, "Cope X:");
InputBox(cy2, 40, "Cope Y:");
int cX2,cY2;
sscanf(cx2, "%d", &cX2);
sscanf(cy2, "%d", &cY2);
putimage(cX2,cY2+71,&tom);
}
if(m.x>500 && m.y>0 && m.x<545 && m.y<50){
if(h)h=0;
else h=1;
_sleep(150);
}
if(m.x>550 && m.y>0 && m.x<595 && m.y<50){
if(nn)nn=0;
else nn=1;
_sleep(150);
}
if(m.x>600 && m.y>0 && m.x<645 && m.y<50){
if(pp)pp=0;
else pp=1;
_sleep(150);
}
if(m.x>650 && m.y>0 && m.x<695 && m.y<50){
if(rec)rec=0;
else rec=1;
_sleep(150);
}
if(m.x>700 && m.y>0 && m.x<745 && m.y<50){
if(cir)cir=0;
else cir=1;
_sleep(150);
}
if(m.x>750 && m.y>0 && m.x<795 && m.y<50){
if(rr)rr=0;
else rr=1;
_sleep(150);
}
}
if(li){setlinestyle(PS_SOLID, 3);setlinecolor(RGB(255,255,255));line(355,0,355,50);}
else {setlinestyle(PS_DASH|PS_SOLID,3);setlinecolor(RGB(255,255,255));line(355,0,355,50);}
setlinestyle(PS_SOLID, 3);
LOGFONT e;
improveWord(&e, 60, _T("微软雅黑"));
outtextxy(58,-5,"A");
improveWord(&e, 20, _T("微软雅黑"));
for(int i=1;i<=1;i++){
float H = 0;
float S = 1;
float L = 0.5f;
setlinestyle(PS_SOLID, 2);
for(int r = 400; r > 344; r--)
{
H += 5;
setlinecolor( HSLtoRGB(H, S, L) );
circle(110+(r/2.5)-135, 10+(i*10), 5);
}
}
setfillcolor(RGB(100,100,255));
solidrectangle(155,10,185,40);
setfillcolor(RGB(200,200,200));
solidrectangle(160,20,180,35);
setlinecolor(RGB(100,100,100));
line(165,25,175,25);
line(165,30,175,30);
setfillcolor(RGB(255,255,100));
solidrectangle(215,10,240,40);
setfillcolor(RGB(100,70,0));
solidrectangle(210,5,235,35);
setlinecolor(RGB(255,255,255));
setlinestyle(PS_SOLID, 1);
line(252,10,293,10);
setlinestyle(PS_SOLID, 3);
line(254,15,290,15);
setlinestyle(PS_SOLID, 5);
line(260,23,288,23);
setlinestyle(PS_SOLID, 6);
line(262,30,285,30);
setlinestyle(PS_SOLID, 7);
line(265,38,283,38);
setlinestyle(PS_DASH|PS_SOLID,3);
line(305,20,345,20);
setlinestyle(PS_SOLID, 3);
line(305,35,345,35);
outtextxy(405,10,"Copy");
outtextxy(455,10,"Move");
outtextxy(505+5,10,"Fill");
improveWord(&e, 16, _T("微软雅黑"));
outtextxy(555,12,"Getcolor");
improveWord(&e, 20, _T("微软雅黑"));
outtextxy(605+5,10,"Line");
setlinecolor(WHITE);
setlinestyle(PS_SOLID, 1);
rectangle(653,15,692,30);
ellipse(703,15,742,30);
roundrect(753,10,792,35,10,10);
}
COLORREF I2C(int ASCII){return ASCII;}
void load(){
if(KEY_DOWN('H')){setfillcolor(RGB(100,100,100));solidrectangle(0,0,1000,70);print();}
if(KEY_DOWN(VK_F5)){
setfillcolor(RGB(100,100,100));
solidrectangle(900,980,1000,1000);
outtextxy(900, 980, "debuging...");
MessageBox(GetForegroundWindow(),"调试成功","提示",MB_ICONASTERISK | MB_OK | MB_SETFOREGROUND);
}
if(KEY_DOWN(VK_F6)){
setfillcolor(RGB(100,100,100));
solidrectangle(900,980,1000,1000);
outtextxy(900, 980, "refreshing...");
IMAGE imp;
getimage(&imp, 0, 70, 1000, 979);
putimage(0,70,&imp);
MessageBox(GetForegroundWindow(),"刷新成功","提示",MB_ICONASTERISK | MB_OK | MB_SETFOREGROUND);
}
if(KEY_DOWN(VK_ESCAPE))exit(0);
if(KEY_DOWN('D')){
char r[50],g[50],b[50];
InputBox(r, 40, "Red:");
InputBox(g, 40, "Green:");
InputBox(b, 40, "Blue:");
int R,G,B;
sscanf(r, "%d", &R);
sscanf(g, "%d", &G);
sscanf(b, "%d", &B);
_Tcolor=RGB(R,G,B);
}
if(KEY_DOWN('S')){
_Tstyle=1;
char s[10];
InputBox(s, 10, "style:");
int r;
sscanf(s, "%d", &r);
if(r<=0)r=1;
_Tstyle=r;
}
if(KEY_DOWN('P')){
setfillcolor(RGB(100,100,100));
solidrectangle(900,980,1000,1000);
LOGFONT e;
improveWord(&e, 20, _T("微软雅黑"));
outtextxy(900, 980, "save...");
IMAGE img;
getimage(&img, 0, 70, 1000, 908);
saveimage(/*"C:\\Users\C\Desktop\outputimage.bmp"*/"D:\\test.bmp",&img);
}
if(KEY_DOWN('Q')){
setfillcolor(RGB(100,100,100));
solidrectangle(900,980,1000,1000);
LOGFONT e;
improveWord(&e, 20, _T("微软雅黑"));
outtextxy(900, 980, "open...");
IMAGE im2;
loadimage(&im2,"D:\\test.bmp");
putimage(0,70,&im2);
}
if(KEY_DOWN('L')){
if(li==1)li=0;
else li=1;
_sleep(50);
}
if(KEY_DOWN('A')){
char str[10010];
InputBox(str, 10000, "Word:");
char hx[50],hy[50],size[50];
InputBox(hx, 40, "X:");
InputBox(hy, 40, "Y:");
InputBox(size, 40, "Size:");
int HX,HY,SI;
sscanf(hx, "%d", &HX);
sscanf(hy, "%d", &HY);
sscanf(size, "%d", &SI);
settextcolor(_Tcolor);
LOGFONT L;
improveWord(&L, SI, _T("微软雅黑"));
outtextxy(HX,HY+70,str);
improveWord(&L, 20, _T("微软雅黑"));
settextcolor(RGB(255,255,255));
}
if(KEY_DOWN('C')){
char left[50],top[50],right[50],button[50];
InputBox(left, 40, "Left:");
InputBox(top, 40, "Top:");
InputBox(right, 40, "Right:");
InputBox(button, 40, "Button:");
int LE,TO,RI,BU;
sscanf(left, "%d", &LE);
sscanf(top, "%d", &TO);
sscanf(right, "%d", &RI);
sscanf(button, "%d", &BU);
IMAGE tom;
getimage(&tom, LE, TO+71, RI-LE,BU-TO+71);
char cx[50],cy[50];
InputBox(cx, 40, "Cope X:");
InputBox(cy, 40, "Cope Y:");
int cX,cY;
sscanf(cx, "%d", &cX);
sscanf(cy, "%d", &cY);
putimage(cX,cY+71,&tom);
}
if(KEY_DOWN('M')){
char left2[50],top2[50],right2[50],button2[50];
InputBox(left2, 40, "Left:");
InputBox(top2, 40, "Top:");
InputBox(right2, 40, "Right:");
InputBox(button2, 40, "Button:");
int LE2,TO2,RI2,BU2;
sscanf(left2, "%d", &LE2);
sscanf(top2, "%d", &TO2);
sscanf(right2, "%d", &RI2);
sscanf(button2, "%d", &BU2);
IMAGE tom;
getimage(&tom, LE2, TO2+71, RI2-LE2,BU2-TO2+71);
setfillcolor(RGB(0,0,0));
solidrectangle(LE2,TO2+71,RI2,BU2+71);
char cx2[50],cy2[50];
InputBox(cx2, 40, "Cope X:");
InputBox(cy2, 40, "Cope Y:");
int cX2,cY2;
sscanf(cx2, "%d", &cX2);
sscanf(cy2, "%d", &cY2);
putimage(cX2,cY2+71,&tom);
}
if(KEY_DOWN('F')){
if(h)h=0;
else h=1;
_sleep(150);
}
if(KEY_DOWN('G')){
if(nn)nn=0;
else nn=1;
_sleep(150);
}
if(KEY_DOWN('R')){
if(pp)pp=0;
else pp=1;
_sleep(150);
}
if(KEY_DOWN('Y')){
if(rec)rec=0;
else rec=1;
_sleep(150);
}
if(KEY_DOWN('Z')){
if(cir)cir=0;
else cir=1;
_sleep(150);
}
if(KEY_DOWN('J')){
if(rr)rr=0;
else rr=1;
_sleep(150);
}
}
void main(){
init();
sta=(int)time(0);
while(1){
BeginBatchDraw();
paint();
paintbutton();
load();
outtextxy(940,0,"ID:Null");
EndBatchDraw();
fp++;
if((int)time(0)-sta>=1){
fps=fp;
fp=0;
sta=(int)time(0);
}
}
closegraph();
}
0.0.1:
0.0.3:
0.0.16:
0.0.17:
0.0.21:
0.0.38.rc1 & (0.0.38.rc2)高帧率版:
0.0.40:
最新版(0.0.48):