Header file:
graphics.h
Synopsis:
void bar3d (int left, int top, int right, int bottom,
int depth, int topflag);
(left, top) - top left corner of the 3D bar
(right, bottom) - bottom right corner of the 3D bar
depth - depth of the bar(in pixels)
topflag - 3D top is put on the bar if the value of topflag is 1
Description:
bar3d() draws a three dimensional bar.
bar3d function in c graphics
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
int main(void) {
/* request auto detection */
int graphicDriver = DETECT, graphicMode;
int err, i, x, y;
/* initialize graphics, local variables*/
initgraph(&graphicDriver, &graphicMode,
"C:/TURBOC3/BGI");
/* read result of initialization */
err = graphresult();
if (err != grOk) {
/* an error occurred */
printf("Graphic Error: %s\n",
grapherrormsg(err));
return 0;
}
x = 50;
y = getmaxy() - 100;
for (i=0; i<15; i++) {
setcolor(i);
/* different fill patterns */
setfillstyle(i % 12, i);
/* draw the 3-d bar */
bar3d(x - 50, y - 50, x + 50,
y + 50, 250, 1);
floodfill(x - 50, y - 50, i);
delay(250);
}
/* clean up */
closegraph();
return 0;
}
Output: (bar3d built-in function in c graphics.h)
No comments:
Post a Comment