这几天接触了easyx,就想用来画图试试
由于上传不了视频,大家可以跑代码试一试
其实没多难的,主要就是
- 动态用到Sleep()函数
- 画各种图案参考easyx官方文档的函数(circle、、、)
- 用到了鼠标事件
- 最重要的是结合PS,确定每个图形的绝对坐标
- 祝大家编程开心
源码如下:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <graphics.h>
void gotoxy(int x,int y)
{
COORD Pos;
HANDLE hCon;
hCon = GetStdHandle(STD_OUTPUT_HANDLE);
Pos.X = x;
Pos.Y = y;
SetConsoleCursorPosition(hCon,Pos);
}
int main()
{
void eye();
void one();
void two();
void three();
initgraph(800,600);
//one();
eye();
two();
Sleep(300);
three();
getchar();
Sleep(5000);
return 0;
}
void eye()
{
int flag=1;
MOUSEMSG m;
FlushMouseMsgBuffer();
void one();
int check_button(int x,int y);
//initgraph(800,600); // 创建绘图窗口,大小为 640x480 像素
//system("color f5");
//setbkcolor(15);
//(5);
setbkcolor(RGB(173,189,202));
cleardevice();
//setfillcolor(RGB(173,189,202));
//solidroundrect(250,160,550,410,150,150);
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
solidroundrect(226,214,362,316,50,50);
solidroundrect(462,214,600,316,50,50);
setfillcolor(RGB(0,0,0));
fillcircle(269,267,25);
fillcircle(505,267,25);
setlinecolor(RGB(125,0,0));
setfillcolor(RGB(125,0,0));
solidroundrect(350,367,481,481,80,80);
settextcolor(WHITE);
setbkcolor(RGB(125,0,0));
settextstyle(32, 16, _T("宋体"));
outtextxy(390,410,"进入");
while(flag)
{
Sleep(600);
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(269,267,25);
fillcircle(505,267,25);
setfillcolor(RGB(0,0,0));
fillcircle(319,267,25);
fillcircle(555,267,25);
Sleep(600);
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(319,267,25);
fillcircle(555,267,25);
setfillcolor(RGB(0,0,0));
fillcircle(269,267,25);
fillcircle(505,267,25);
while (MouseHit())
{
m = GetMouseMsg(); // 获取鼠标消息
if(check_button(m.x,m.y))
{
switch(m.uMsg) // 根据不同的鼠标消息,执行不同的代码
{
case WM_LBUTTONDOWN:
one();
flag=0;
break;
default:
break;
}
}
}
}
}
void one()
{
cleardevice();
setbkcolor(WHITE);
cleardevice();
setfillcolor(RGB(239,90,89));
fillcircle(400,200,50);
setfillcolor(RGB(255,255,255));
fillcircle(400,200,15);
setfillcolor(RGB(0,0,0));
fillcircle(400,200,5);
setfillcolor(RGB(173,188,201));
fillrectangle(250,250,550,300);
setfillcolor(RGB(80,92,133));
setlinecolor(RGB(80,92,133));
arc(300,300,500,500,0,3.14159);
line(300,399,500,399);
floodfill(350,350,RGB(80,92,133));
setfillcolor(RGB(243,169,183));
POINT pts1[] = { {400, 400},{346,400},{314, 470}, {358, 489},{400, 400}};
solidpolygon(pts1, 4);
POINT pts2[] = { {400, 400},{457,400},{488, 470}, {443, 490},{400, 400}};
solidpolygon(pts2, 4);
setfillcolor(RGB(255,255,255));
setlinecolor(RGB(255,255,255));
fillcircle(400,275,4); //little-cicrle-up
Sleep(200);
setfillcolor(RGB(255,255,255));
setlinecolor(RGB(255,255,255));
fillrectangle(250,250,550,300);
setfillcolor(RGB(173,188,201));
POINT pts3[] = { {250,265},{546,234},{550, 283},{253, 314},{250,265}}; //left-arm
solidpolygon(pts3, 4);
setfillcolor(RGB(255,255,255));
setlinecolor(RGB(255,255,255));
fillcircle(400,275,4); //little-cicrle-up
Sleep(300);
setfillcolor(RGB(255,255,255));
setlinecolor(RGB(255,255,255));
fillcircle(400,350,4); //little-cicrle-bottom
setfillcolor(RGB(255,255,255));
setlinecolor(RGB(255,255,255));
//POINT pts3[] = { {250,265},{546,234},{550, 283},{253, 314},{250,265}};
solidpolygon(pts3, 4);
setfillcolor(RGB(173,188,201));
fillrectangle(250,250,550,300);
Sleep(200);
setfillcolor(RGB(255,255,255));
setlinecolor(RGB(255,255,255));
fillrectangle(250,250,550,300);
setfillcolor(RGB(173,188,201));
POINT pts4[] = { {255,230},{550,271},{544, 319},{248, 279},{255,230}}; //right-arm
solidpolygon(pts4, 4);
Sleep(200);
/*小人往下蹲*/
cleardevice();
/*头部三个circle*/
setfillcolor(RGB(239,90,89));
fillcircle(390,210,50);
setfillcolor(RGB(255,255,255));
fillcircle(390,210,15);
setfillcolor(RGB(0,0,0));
fillcircle(390,210,5);
/*手臂*/
setfillcolor(RGB(173,188,201));
POINT right_arm_2[] = { {245,240},{540,281},{534, 329},{238, 289},{245,240}}; //right-arm
solidpolygon(right_arm_2, 4);
/*两条腿*/
setfillcolor(RGB(243,169,183));
//POINT pts1[] = { {400, 400},{346,400},{314, 470}, {358, 489},{400, 400}};
solidpolygon(pts1, 4);
//POINT pts2[] = { {400, 400},{457,400},{488, 470}, {443, 490},{400, 400}};
solidpolygon(pts2, 4);
/*半圆身子*/
setfillcolor(RGB(80,92,133));
setlinecolor(RGB(80,92,133));
arc(290,310,490,510,0,3.14159);
line(290,409,490,409);
floodfill(340,360,RGB(80,92,133));
/*衣服扣子*/
setfillcolor(RGB(255,255,255));
setlinecolor(RGB(255,255,255));
fillcircle(390,360,4); //little-cicrle-bottom
Sleep(200);
/*小人往下蹲2*/
cleardevice();
/*头部三个circle*/
setfillcolor(RGB(239,90,89));
fillcircle(380,220,50);
setfillcolor(RGB(255,255,255));
fillcircle(380,220,15);
setfillcolor(RGB(0,0,0));
fillcircle(380,220,5);
/*手臂*/
setfillcolor(RGB(173,188,201));
POINT right_arm_3[] = { {235,250},{530,291},{524, 339},{228, 299},{235,250}}; //right-arm
solidpolygon(right_arm_3, 4);
/*两条腿*/
setfillcolor(RGB(243,169,183));
//POINT pts1[] = { {400, 400},{346,400},{314, 470}, {358, 489},{400, 400}};
solidpolygon(pts1, 4);
//POINT pts2[] = { {400, 400},{457,400},{488, 470}, {443, 490},{400, 400}};
POINT pts_right_leg[] = { {400, 419},{461,416},{495, 460}, {460, 490},{400, 419}};
solidpolygon(pts_right_leg, 4);
/*半圆身子*/
setfillcolor(RGB(80,92,133));
setlinecolor(RGB(80,92,133));
arc(280,320,480,520,0,3.14159);
line(280,419,480,419);
floodfill(330,350,RGB(80,92,133));
/*衣服扣子*/
setfillcolor(RGB(255,255,255));
setlinecolor(RGB(255,255,255));
fillcircle(380,370,4); //little-cicrle-bottom
Sleep(300);
}
int check_button(int x,int y)
{
if(x>350 && x<481 && y>367 && y<481)
return 1;
else
return 0;
}
void two()
{
setbkcolor(RGB(248,106,89));
cleardevice();
/*little one circle*/
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(321,283,15);
Sleep(300);
setlinecolor(RGB(246,178,175));
setfillcolor(RGB(246,178,175));
fillrectangle(304,179,339,262);
Sleep(300);
cleardevice();
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(321,293,15);
fillcircle(424,283,15);
setlinecolor(RGB(246,178,175));
setfillcolor(RGB(246,178,175));
fillrectangle(304,179,339,262);
Sleep(300);
cleardevice();
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(321,303,15);
fillcircle(424,293,15);
setlinecolor(RGB(246,178,175));
setfillcolor(RGB(246,178,175));
fillrectangle(304,179,339,272);
POINT pts1[] = { {400, 179},{432,173},{450, 264}, {415, 272},{400, 179}};
solidpolygon(pts1, 4);
Sleep(300);
cleardevice();
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(321,323,15);
fillcircle(424,300,15);
setlinecolor(RGB(246,178,175));
setfillcolor(RGB(246,178,175));
fillrectangle(304,189,339,282);
POINT pts2[] = { {400, 189},{432,183},{450, 274}, {415, 282},{400, 189}};
solidpolygon(pts2, 4);
Sleep(200);
cleardevice();
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(321,343,15);
fillcircle(424,320,15);
setlinecolor(RGB(246,178,175));
setfillcolor(RGB(246,178,175));
fillrectangle(304,209,339,322);
POINT pts3[] = { {400, 209},{432,203},{450, 294}, {415, 302},{400, 209}};
solidpolygon(pts3, 4);
setfillcolor(RGB(90,59,70));
setlinecolor(RGB(90,59,70));
arc(296,87,479,278,-0.19,2.949);
line(299,163,479,200);
floodfill(386,127,RGB(90,59,70));
Sleep(200);
cleardevice();
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(321,363,15);
fillcircle(418,360,15);
setlinecolor(RGB(246,178,175));
setfillcolor(RGB(246,178,175));
fillrectangle(304,229,339,342);
fillrectangle(400,229,435,342);
setfillcolor(RGB(90,59,70));
setlinecolor(RGB(90,59,70));
arc(281,97,464,288,0,3.1415);
line(281,191,466,191);
floodfill(395,150,RGB(90,59,70));
Sleep(200);
setfillcolor(RGB(253,177,169));
setlinecolor(RGB(253,177,169));
POINT pts4[] = { {325,0},{375,50},{425,0},{325,0}};
solidpolygon(pts4, 3);
Sleep(100);
setlinecolor(RGB(248,106,89));
setfillcolor(RGB(248,106,89));
fillcircle(321,363,15);
fillcircle(418,360,15);
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(321,493,15);
fillcircle(418,493,15);
Sleep(100);
setlinecolor(RGB(248,106,89));
setfillcolor(RGB(248,106,89));
fillrectangle(304,229,339,342);
fillrectangle(400,229,435,342);
setlinecolor(RGB(246,178,175));
setfillcolor(RGB(246,178,175));
fillrectangle(304,339,339,452);
fillrectangle(400,339,435,452);
Sleep(100);
setfillcolor(RGB(248,106,89));
setlinecolor(RGB(248,106,89));
floodfill(395,150,RGB(248,106,89));
setlinecolor(RGB(109,147,163));
setfillcolor(RGB(109,147,163));
fillrectangle(169,271,350,295);
fillrectangle(402,271,582,294);
setfillcolor(RGB(90,59,70));
setlinecolor(RGB(90,59,70));
arc(281,245,464,436,0,3.1415);
line(281,339,466,339);
floodfill(395,290,RGB(90,59,70));
Sleep(100);
setfillcolor(RGB(248,106,89));
setlinecolor(RGB(248,106,89));
solidpolygon(pts4, 3);
setfillcolor(RGB(253,177,169));
setlinecolor(RGB(253,177,169));
POINT pts5[] = { {378,50},{432,107},{377,161},{323,107},{378,50}};
solidpolygon(pts5, 4);
Sleep(100);
setfillcolor(RGB(248,106,89));
setlinecolor(RGB(248,106,89));
solidpolygon(pts5, 4);
setfillcolor(RGB(253,177,169));
setlinecolor(RGB(253,177,169));
POINT pts6[] = { {378,134},{432,191},{378,245},{323,191},{378,134}};
solidpolygon(pts6, 4);
Sleep(100);
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(378,190,30);
Sleep(100);
setlinecolor(BLACK);
setfillcolor(RGB(0,0,0));
fillcircle(378,190,10);
Sleep(100);
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(141,284,13);
fillcircle(616,284,13);
setlinecolor(RGB(125,123,123));
setfillcolor(RGB(125,123,123));
fillroundrect(125,500,308,508,5,5);
}
void three()
{
setbkcolor(RGB(248,106,89));
cleardevice();
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(141,284,13);
fillcircle(557,175,13);
settextcolor(WHITE);
setbkcolor(RGB(248,106,89));
settextstyle(32, 16, _T("宋体"));
outtextxy(575,139,"Hi~");
setfillcolor(RGB(253,177,169));
setlinecolor(RGB(253,177,169));
POINT pts6[] = { {378,134},{432,191},{378,245},{323,191},{378,134}};
solidpolygon(pts6, 4);
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(378,190,30);
setlinecolor(BLACK);
setfillcolor(RGB(0,0,0));
fillcircle(378,190,10);
setlinecolor(RGB(125,123,123));
setfillcolor(RGB(125,123,123));
fillroundrect(125,500,308,508,5,5);
setlinecolor(RGB(109,147,163));
setfillcolor(RGB(109,147,163));
POINT pts7[] = {{416,281},{531,179},{550,200},{433,300},{416,281}};
solidpolygon(pts7, 4);
fillrectangle(169,271,350,295);
setfillcolor(RGB(90,59,70));
setlinecolor(RGB(90,59,70));
arc(281,245,464,436,0,3.1415);
line(281,339,466,339);
floodfill(395,290,RGB(90,59,70));
setlinecolor(WHITE);
setfillcolor(RGB(255,255,255));
fillcircle(321,493,15);
fillcircle(418,493,15);
setlinecolor(RGB(246,178,175));
setfillcolor(RGB(246,178,175));
fillrectangle(304,339,339,452);
fillrectangle(400,339,435,452);
}