Saturday, March 9, 2019

Assignment 10b: National Flag Hoisting







#include<iostream>
#include<graphics.h>

using namespace std;

class flag
{
    float l,b,x,y,h;       //In reality length=width*1.5

    public:
        flag()
        {
            l=160;
            b=35;
            x=130;
            y=102;
            h=275;
        }
        void create()
        {
            //ORANGE(here red is used as orange is not available)
            setcolor(12);
            rectangle(50,50,50+l,50+b);
            setfillstyle(SOLID_FILL,12);
            floodfill(65,65,12);

            //WHITE
            setcolor(15);
            rectangle(50,50+b,50+l,50+(2*b));
            setfillstyle(SOLID_FILL,15);
            floodfill(65,90,15);

            //GREEN
            setcolor(2);
            rectangle(50,50+(2*b),50+l,50+(3*b));
            setfillstyle(SOLID_FILL,2);
            floodfill(65,135,2);

            //ASHOKA CHAKRA
            setcolor(1);
            circle(x,y,17);
            circle(x,y,7);
            setfillstyle(SOLID_FILL,1);
            floodfill(x+2,y+2,1);
            line(x,86,x,118);   //vertical
            line(113,y,147,y);   //horizontal

            //QUAD 1
            line(x+3,86+2,x,y);
            line(x+6,86+3,x,y);
            line(x+9,86+4,x,y);
            line(x+12,86+7,x,y);
            line(x+15,86+11,x,y);

            //QUAD 2
            line(x-3,86+2,x,y);
            line(x-6,86+3,x,y);
            line(x-9,86+4,x,y);
            line(x-12,86+7,x,y);
            line(x-15,86+11,x,y);

            //QUAD 3
            line(x-3,118-2,x,y);
            line(x-6,118-3,x,y);
            line(x-9,118-4,x,y);
            line(x-12,118-7,x,y);
            line(x-15,118-11,x,y);

            //QUAD 4
            line(x+3,118-2,x,y);
            line(x+6,118-3,x,y);
            line(x+9,118-4,x,y);
            line(x+12,118-7,x,y);
            line(x+15,118-11,x,y);
        }

        void pole()
        {
            setcolor(8);
            rectangle(47,50,50,50+h);
            setfillstyle(SOLID_FILL,8);
            floodfill(48,90,8);
        }
        void st()
        {
            int dest1=305;
            setcolor(15);
            line(52,dest1,70,dest1);
            delay(700);
            setcolor(0);
            line(52,dest1,70,dest1);
            while(dest1!=50)
            {
                dest1=dest1-1;
                setcolor(15);
                line(52,dest1,70,dest1);
                delay(60);
                setcolor(0);
                line(52,dest1,70,dest1);
                //pole();n for
            }

        }
}f;

int main()
{
    int gd=0,gm;
    initgraph(&gd,&gm,NULL);

    f.pole();
    f.st();

    cleardevice();

    f.pole();
    f.create();

    setcolor(12);
    outtextxy(240,240,"VAND");
    delay(1000);
    setcolor(15);
    outtextxy(276,240,"E MAT");
    delay(1000);
    setcolor(2);
    outtextxy(317,240,"ARAM");

    getch();
    cleardevice();
    closegraph();
}

No comments:

Post a Comment