Open In App

C program to design a hot air balloon using graphics

Last Updated : 23 Apr, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will discuss how to design a Hot Air Balloon in the C using Graphics.

Approach:

  • Draw a circle using the circle() function.
  • Draw a total of four lines using the line() function which will act as the rope that holds the container.
  • Implement the container using the rectangle() function.
  • Color the circle which will act as a balloon with red using the setfillstyle() & floodfill() functions.
  • Color the container yellow & brown using the setfillstyle() & floodfill() functions.
  • Color all the ropes white using the setfillstyle() & floodfill() functions.
  • Set the background color blue using setfillstyle() & floodfill() functions.

Below is the implementation of the above approach:

C




// C program to design a Hot Air Balloon
// using graphics
#include <conio.h>
#include <graphics.h>
#include <stdio.h>
  
// Driver Code
void main()
{
    int gd = DETECT, gm;
  
    // Initialize of gdriver with
    // DETECT macros
    initgraph(&gd, &gm, "C:\\"
                        "turboc3\\bgi");
  
    // Set the Background Color to blue
    setfillstyle(SOLID_FILL, BLUE);
    floodfill(100, 100, 15);
  
    // Set Circle Balloon Color
    // With Red
    setfillstyle(SOLID_FILL, RED);
  
    // Creating Balloon
    circle(550, 200, 100);
    floodfill(552, 202, 15);
  
    // Set The Rope Color
    // With White
    setfillstyle(SOLID_FILL, WHITE);
  
    // Right Side Right Rope
    line(650, 200, 630, 400);
  
    // Right Side Left Rope
    line(650, 200, 620, 400);
  
    // Connect the two right side ropes
    // for coloring purpose
    line(620, 400, 630, 400);
    floodfill(625, 398, 15);
  
    // Left side left rope
    line(450, 200, 470, 400);
  
    // Left side right rope
  
    line(450, 200, 480, 400);
  
    // Connect the two left side ropes
    // for coloring purpose
    line(470, 400, 480, 400);
    floodfill(475, 398, 15);
  
    // Set Container One Part
    // With Brown
    setfillstyle(SOLID_FILL, BROWN);
    rectangle(450, 400, 650, 500);
    floodfill(452, 402, 15);
  
    // Set Container Another
    // Part With Yellow
    setfillstyle(XHATCH_FILL, YELLOW);
  
    // Dividing Container For
    // Decorating Purpose
    line(450, 430, 650, 430);
    floodfill(452, 498, 15);
  
    // Hold the screen
    getch();
  
    // Close the initialized gdriver
    closegraph();
}


Output:



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads