Open In App

C program to design a hot air balloon using graphics

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

Approach:



Below is the implementation of the above approach:




// 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:




Article Tags :