C语言绘制小恐龙吹泡泡

教育   2024-11-05 07:03   宁夏  

效果图

源码

///////////////////////////////////////////////////// 程序名称:C语言绘制小恐龙吹泡泡// 编译环境:Mictosoft Visual Studio 2022, EasyX_20200315(beta)// 作  者:luoyh <2864292458@qq.com>// 公 众 号:C语言研究// 最后修改:2024-11-5//
#include<graphics.h>#include<conio.h>#include<math.h>
#define PI acos(-1.0)double th = PI / 180;void DrawEllipse(int x0, int y0, int a, int b, int k, COLORREF color); // 绘制倾斜椭圆
int main(){ initgraph(1080, 570); setbkcolor(WHITE); cleardevice(); DrawEllipse(540, 74, 40, 60, 0, BLACK); DrawEllipse(656, 140, 40, 60, -30, BLACK); DrawEllipse(706, 250, 35, 50, -90, BLACK); DrawEllipse(677, 362, 35, 50, -100, BLACK); // 背部 setfillcolor(RGB(80, 185, 56)); floodfill(540, 74, BLACK); floodfill(656, 140, BLACK); floodfill(706, 250, BLACK); floodfill(677, 362, BLACK); // 填充背部 setfillcolor(RGB(127, 227, 105)); setlinecolor(BLACK); setlinestyle(PS_SOLID, 8); fillcircle(510, 270, 210); setlinestyle(PS_SOLID, 5); arc(460, 272, 480, 290, 0.78, 4.47); arc(460, 290, 480, 305, 2.057, 0); // 嘴 setfillcolor(RGB(237, 154, 148)); solidcircle(600, 305, 20); solidcircle(338, 305, 20); // 脸蛋 setfillcolor(BLACK); solidcircle(362,284,20); solidcircle(578,284,20); // 眼睛 setlinecolor(WHITE); circle(396,292,65); _getch(); return 0;}
void DrawEllipse(int x0, int y0, int a, int b, int k, COLORREF color){ double i; double x, y, tx, ty; for (i = -180; i <= 180; i = i + 0.5) { x = a * cos(i * th); y = b * sin(i * th); tx = x; ty = y; x = tx * cos(k * th) - ty * sin(k * th) + x0; y = y0 - (ty * cos(k * th) + tx * sin(k * th)); setfillcolor(color); solidcircle((int)x, (int)y, 4); }}

C语言研究
写给自己的笔记,时常写写,时常看看,仅此而已。