展示效果
所用工具
编译器:Visual Studio 2022
函数库:Easyx
展示代码
#include <stdio.h>
#include <easyx.h>
int main()
{
initgraph(800, 600);
setbkcolor(RGB(169, 92, 10));
cleardevice();
setfillcolor(RGB(130, 64, 4));
solidcircle(200, 130, 90);
solidcircle(600, 130, 90);
setfillcolor(RGB(255, 178, 50));
solidcircle(200, 120, 90);
solidcircle(600, 120, 90);
HRGN leftEarClip =
CreateEllipticRgn(110, 30, 290, 210); //创建剪切区域
HRGN rightEarClip =
CreateEllipticRgn(510, 30, 690, 210);
HRGN earsClip =
CreateRectRgn(0,0,0,0); //创建一个空目标
CombineRgn(earsClip, leftEarClip, rightEarClip, RGN_OR); //并集组合区域
setcliprgn(earsClip); //设置剪切区域
setfillcolor(RGB(243, 154, 2));
solidcircle(200, 130, 90);
solidcircle(600, 130, 90);
setfillcolor(RGB(255, 178, 50));
solidcircle(200, 210, 90);
solidcircle(600, 210, 90);
DeleteObject(leftEarClip); //释放之前创建的剪切区域
DeleteObject(rightEarClip);
DeleteObject(earsClip);
setcliprgn(NULL); //将剪切区域设置为空
setfillcolor(RGB(255,178,50));
solidcircle(400, 300, 250);
HRGN headClip =
CreateEllipticRgn(150, 50, 650, 550);
setcliprgn(headClip);
setfillcolor(RGB(243, 154, 2));
solidcircle(400, 320, 250);
DeleteObject(headClip);
setcliprgn(NULL);
setfillcolor(RGB(51, 34, 8));
solidcircle(275, 300, 25);
solidcircle(525, 300, 25);
setfillcolor(RGB(130, 69, 4));
solidellipse(310, 385, 490, 485);
setfillcolor(WHITE);
solidellipse(310, 380, 490, 480);
setfillcolor(RGB(51, 34, 8));
solidcircle(400, 420, 15);
setlinestyle(PS_SOLID, 5);
setlinecolor(RGB(51, 34, 8));
line(400, 420,370,450);
line(400, 420, 430, 450);
getchar();
closegraph();
return 0;
}