My photo
Bangalore, Karnataka, India
Extending one hand to help someone has more value rather than joining two hands for prayer

Archives

program to print a variable box

Tuesday, September 1, 2009

#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<string.h>
#include<fstream.h>
#include<process.h>
void box();
int box_clr=6,bx1=100,bx2=400,by1=10,by2=460;
void main()
{    int d,m;
    d=DETECT;
    initgraph(&d,&m,"c:\\tc");
    box();
    getch();
}
void box()
{       int butn=4;
    setcolor(box_clr);
    setbkcolor(7);
    int a[]={bx1,by1,bx2,by1,bx2,by1+4,bx1+4,by1+4,bx1+4,by2,bx1,by2,bx1,by1};
    setfillstyle(3,box_clr);
    /* draw a filled polygon */
    fillpoly(7,a);
    floodfill(bx1,by1,box_clr);
    int b[]={bx2-10,by1+5,bx2,by1+5,bx2,by2,bx1+5,by2,bx1+5,by2-10,bx2-10,by2-10,bx2-10,by1+5};
    setfillstyle(9,box_clr);
    fillpoly(7,b);
    //right top button
    setcolor(butn);
    rectangle(bx2-10,by1+5,bx2,by1+20);
    line(bx2-10,by1+15,bx2,by1+15);
    setfillstyle(1,butn);
    floodfill(bx2-8,by1+17,butn);
    int c[]={bx2-10,by1+5,bx2,by1+5,bx2-5,by1+14,bx2-10,by1+5};
    setfillstyle(1,butn);
    fillpoly(4,c);
    //right bottom button
    rectangle(bx2-10,by2-25,bx2,by2-10);
    line(bx2-10,by2-20,bx2,by2-20);
    setfillstyle(1,butn);
    floodfill(bx2-8,by2-23,butn);
    int d[]={bx2-5,by2-19,bx2,by2-10,bx2-10,by2-10,bx2-5,by2-19};
    setfillstyle(1,butn);
    fillpoly(4,d);
    //lower right button
    rectangle(bx2-25,by2-10,bx2-10,by2);
    line(bx2-20,by2-10,bx2-20,by2);
    setfillstyle(1,butn);
    floodfill(bx2-23,by2-8,butn);
    int e[]={bx2-19,by2-5,bx2-10,by2-10,bx2-10,by2,bx2-19,by2-5};
    setfillstyle(1,butn);
    fillpoly(4,e);
    //lower left button
    rectangle(bx1+5,by2-10,bx1+20,by2);
    line(bx1+15,by2-10,bx1+15,by2);
    setfillstyle(1,butn);
    floodfill(bx1+17,by2-8,butn);
    int f[]={bx1+5,by2-10,bx1+14,by2-5,bx1+5,by2,bx1+5,by2-10};
    setfillstyle(1,butn);
    fillpoly(4,f);
}

0 comments: