getcolor function in c graphics

getcolor function of c graphics is used to get the current foreground color in graphics mode. To get the maximum number of possible colors we need to use getmaxcolor function.

General syntax of getcolor function is :
                                                     getcolor();

C graphics program to demonstrate the getcolor function.

#include <graphics.h>
#include <stdio.h>

int main( )
{
    int gd=DETECT, gm;
    char msg[50];
    initgraph(&gd,&gm,"C:\\tc\\bgi");
    setbkcolor(6);
    setcolor(10);
    rectangle(150,100,550,300);

    moveto(230,200);
    sprintf(msg,"Current foreground color is : %d",getcolor());
    outtext(msg);

    getch();
    closegraph();

    return 0;
}


getcolor function of c graphics programming

Download


0 comments:

Post a Comment