C++ bar3d() - Draw a 3D bar on the Screen

- July 11, 2018
bar3d library function in cpp
In C++, bar3d() function is used to draw a three dimensional bar (3D) between two given points on the screen. This function is quite similar to bar() function (that is used to draw simple bar), but it draws 3D bar.

Syntax of bar3d()

The general syntax of this function is looks like:
bar3d (left, top, right, bottom, depth, flag);
Where:
left and top represents the x & y co-ordinates of the first point. The "left" indicates x-coordinate of the first point and the "top" indicates the y-coordinate of the first point.
right and bottom represents the x & y co-ordinates of the second point. The "right" indicates x-coordinate of the second point and the "bottom" indicates the y-coordinate of the second point.
depth It represents the depth of bar in pixels.
flag It represents the flag put on the top of bar. It it's value is zero then no flag is put.

Example of bar3d() Function

Ths following C++ program draws a 3D bar on the screen between (200, 100) & (300, 600) with depth 15 and flag 2.

#include<iostream>
#include<canio>
#include<graphics>
using namespace std;
  main()
   {
      int driver, mode;
      driver = DETECT;
      initgraph (&driver, &m, " ");
      cleardevice();
      bar3d ( 200, 100, 300, 600, 15, 2);
      getch();
      closegraph();
   }

Leave your reply.
EmoticonEmoticon

 

Start typing and press Enter to search