[C] C语言绘制皮卡丘 →→→→→进入此内容的聊天室

来自 Colossal Crocodile, 2024-03-07, 写在 C, 查看 18 次.
URL http://www.code666.cn/view/cd5be0b6
  1. #include<graphics.h>
  2. #include<math.h>
  3. #define PI 3.141592654
  4. int main() {
  5.     initwindow(600, 450); // 创建画布
  6.     // 画右耳朵
  7.     setfillstyle(SOLID_FILL, YELLOW);
  8.     circle(325, 135, 40);
  9.     floodfill(325, 135, WHITE);
  10.     // 画右耳朵轮廓
  11.     setcolor(BLACK);
  12.     arc(325, 135, 50, 140, 40);
  13.     arc(345, 109, 315, 160, 35);
  14.     // 画左耳朵
  15.     setfillstyle(SOLID_FILL, YELLOW);
  16.     circle(225, 135, 40);
  17.     floodfill(225, 135, WHITE);
  18.     // 画左耳朵轮廓
  19.     setcolor(BLACK);
  20.     arc(225, 135, 40, 130, 40);
  21.     arc(195, 109, 20, 50, 35);
  22.     // 画脸
  23.     setfillstyle(SOLID_FILL, YELLOW);
  24.     circle(325, 220, 70);
  25.     floodfill(325, 220, WHITE);
  26.     // 画下巴
  27.     setcolor(BLACK);
  28.     arc(325, 230, 0, 180, 35);
  29.     arc(325, 230, 180, 360, 35);
  30.     // 画左眼
  31.     setcolor(BLACK);
  32.     circle(276, 189, 7);
  33.     circle(276, 189, 2);
  34.     setfillstyle(SOLID_FILL, WHITE);
  35.     circle(276, 189, 6);
  36.     floodfill(276, 189, BLACK);
  37.     setcolor(BLACK);
  38.     circle(276, 189, 4);
  39.      // 画右眼
  40.     setcolor(BLACK);
  41.     circle(374, 189, 7);
  42.     circle(374, 189, 2);
  43.     setfillstyle(SOLID_FILL, WHITE);
  44.     circle(374, 189, 6);
  45.     floodfill(374, 189, BLACK);
  46.     setcolor(BLACK);
  47.     circle(374, 189, 4);
  48.     // 画眼皮
  49.     setfillstyle(SOLID_FILL,RGB(250, 195, 165));
  50.     pieslice(276, 208, 267, 293, 25);
  51.     pieslice(374, 208, 247, 272, 25);
  52.     setfillstyle(SOLID_FILL,BLACK);
  53.     pieslice(276, 215, 267, 293, 25);
  54.     pieslice(374, 215, 247, 272, 25);
  55.      // 画嘴巴
  56.     setfillstyle(SOLID_FILL, RGB(248, 118, 91));
  57.     pieslice(325, 250, 0, 180, 32);
  58.     setcolor(BLACK);
  59.     arc(325, 250, 0, 180, 32);
  60.     // 画嘴唇
  61.     setfillstyle(SOLID_FILL, RGB(241, 65, 103));
  62.     pieslice(325, 250, 0, 90, 32);
  63.     pieslice(325, 250, 180, 270, 32);
  64.     // 画左手臂
  65.     setcolor(BLACK);
  66.     moveto(250, 270);
  67.     for(int i = 0; i <= 90; i++) {
  68.         double angle = i * PI / 180.0;
  69.         int x = (int)(250 + 40 * cos(angle));
  70.         int y = (int)(270 + 30 * sin(angle));
  71.         lineto(x, y);
  72.     }
  73.     // 画右手臂
  74.     moveto(400, 270);
  75.     for(int i = 0; i <= 90; i++) {
  76.         double angle = i * PI / 180.0;
  77.         int x = (int)(400 + 40 * cos(angle));
  78.         int y = (int)(270 + 30 * sin(angle));
  79.         lineto(x, y);
  80.     }
  81.     // 连接左右手臂
  82.     moveto(250, 270);
  83.     lineto(400, 270);
  84.     // 画左腿
  85.     moveto(300, 340);
  86.     for(int i = 0; i <= 90; i++) {
  87.         double angle = i * PI / 180.0;
  88.         int x = (int)(300 + 20 * cos(angle));
  89.         int y = (int)(340 + 30 * sin(angle));
  90.         lineto(x, y);
  91.     }
  92.     // 画右腿
  93.     moveto(350, 340);
  94.     for(int i = 0; i <= 90; i++) {
  95.         double angle = i * PI / 180.0;
  96.         int x = (int)(350 + 20 * cos(angle));
  97.         int y = (int)(340 + 30 * sin(angle));
  98.         lineto(x, y);
  99.     }
  100.     // 连接左右腿
  101.     moveto(300, 340);
  102.     lineto(350, 340);
  103.     // 画尾巴
  104.     setcolor(BLACK);
  105.     moveto(150, 310);
  106.     lineto(180, 297);
  107.     lineto(190, 310);
  108.     lineto(190, 320);
  109.     lineto(180, 333);
  110.     lineto(150, 320);
  111.     getch();
  112.     closegraph(); // 关闭画布    
  113.     return 0;
  114. }

回复 "C语言绘制皮卡丘"

这儿你可以回复上面这条便签

captcha