Header file:
graphics.h
Synopsis:
void bar (int left, int top, int right, int bottom);
(left, top) - top left corner of the rectangular bar
(right, bottom) - bottom right corner of the rectangular bar
Description:
bar() draws a solid rectangular two dimensional bar
bar 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, x, y, i;
/* initialize graphics and local variables */
initgraph(&graphicDriver, &graphicMode,
"C:/TURBOC3/BGI");
/* read result of initialization */
err = graphresult();
if (err != grOk) {
/* an error occurred */
printf("Graphical Error: %s\n",
grapherrormsg(err));
getch();
return 0;
}
x = getmaxx();
y = getmaxy();
/* loop through the fill patterns */
for (i = 1; i< 10; i++) {
/* set the fill style */
setfillstyle(LINE_FILL, getmaxcolor());
x = x - 60;
y = y - 40;
/* draw the bar */
bar(x, y, x + 60, y + 40);
delay(150);
}
getch();
/* clean up */
closegraph();
return 0;
}
Output: (bar built-in function in c graphics.h)
No comments:
Post a Comment