Bar3d() Function

bar3d() function is used to draw 3-dimensional rectangular bar.

void bar3d(int left, int top, int right, int bottom, int depth, int topflag);
  • bar3d() function contains six parameters left, top, right, bottom, depth and topflag. top-left and right- bottom coordinates are required to draw the bar.
  • left specifies the X-coordinate of the top-left corner.
  • top specifies the Y-coordinate of the top-left corner.
  • right specifies the X-coordinate of the right-bottom corner.
  • bottom specifies the Y-coordinate of the right-bottom corner.
  • depth specifies the depth of bar in pixel.
  • The last one is topflag that is an important parameter which determines that 3-d top should be put on the bar or not.
  • If the value of topflag is equal to 1 then it puts the top on the bar otherwise not.





void main()


int gd=DETECT,gm;

initgraph(&gd,&gm," ");

bar3d( 100,150,200,200,25,1);




Above function is used to draw a three dimensional rectangular bar of length 100 cm, breadth 50 cm and depth 25 cm with the top left corner at position (100,150) and right-bottom corner (200,200). top-flag variable is 1 for putting the top on the bar. The color filled in bar is white because white color is a default color. We can change the color and style of the bar with the setfillstyle() functions present in the graphics.h header file.