📜  C程序使用图形绘制奥林匹克标志

📅  最后修改于: 2021-05-25 21:09:04             🧑  作者: Mango

在本文中,我们将讨论如何使用图形设计奥运会徽标。

方法:

  • 使用函数circle()根据徽标中的位置绘制五个圆圈。
  • 要获得轮廓效果,请在其上绘制5个较小的圆圈。
  • 徽标中也有一个黑色圆圈,为防止其混入,请更改背景颜色。
  • 使用setfillstyle()和Floodfill()函数将所有圆和背景着色为各自的颜色。

下面是上述方法的实现:

C
// C program for the above approach
  
#include 
#include 
#include 
  
// Driver Code
void main()
{
    int gd = DETECT, gm;
  
    // Initialize of gdriver
    initgraph(&gd, &gm, "C:\\turboc3\\bgi");
  
    // Create Background color as Grey
    setfillstyle(SOLID_FILL, DARKGRAY);
    floodfill(50, 50, 15);
  
    // Create two circles in each
    // another & color Blue
    setfillstyle(SOLID_FILL, BLUE);
    circle(300, 300, 100);
    circle(300, 300, 90);
    floodfill(202, 300, 15);
  
    // Create two circles in each
    // another & color Yellow
    setfillstyle(SOLID_FILL, YELLOW);
    circle(400, 400, 100);
    circle(400, 400, 90);
    floodfill(322, 350, 15);
    floodfill(302, 400, 15);
  
    // Create two circles in each
    // another & color Black
    setfillstyle(SOLID_FILL, BLACK);
    circle(520, 300, 100);
    circle(520, 300, 90);
    floodfill(442, 350, 15);
    floodfill(422, 300, 15);
  
    // Create two circles in each
    // another & color Green
    setfillstyle(SOLID_FILL, GREEN);
    circle(620, 400, 100);
    circle(620, 400, 90);
    floodfill(522, 400, 15);
    floodfill(542, 350, 15);
  
    // Create two circles in each
    // another & color Red
    setfillstyle(SOLID_FILL, RED);
    circle(740, 300, 100);
    circle(740, 300, 90);
    floodfill(642, 300, 15);
    floodfill(662, 350, 15);
  
    // Hold the screen for a while
    getch();
  
    // Close the initialized gdriver
    closegraph();
}


输出:

想要从精选的最佳视频中学习和练习问题,请查看《基础知识到高级C的C基础课程》。