Wednesday, February 29, 2012

playing with colors in C graphics

Hello all, Lets play with colors in c Graphics. In this example, lines are shown in different colors. The number of colors is limited by the graphic mode which is detected by the initgraph(). read "C graphics" for basic c graphic program.  To check the maximum colors a graphic mode supports, use getmaxcolor() function. In current system, the graphic mode supports 15 colors. Use setcolor() to change the color of the next drawing object. In this example, after setting the color, the line is drawn in that color.

The programs output is shown below.

/* Presented by
 * Colors example.

void main()
int gdriver=DETECT,gmode=0;
int color=0;
int y=10;
/* Open graphic mode
Detect grahic driver and supporting mode
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");


  /* draw  line default */



/*Close graphic mode */


please leave comments behind. Thanks
Pin It
Related Posts Plugin for WordPress, Blogger...