网站地图
3936.net
学霸百科 没有你查不到的
setcolor

「官网地址0365.tv」-「永久地址0365.tv」

setcolor----C库函数 图形屏幕函数;说明函数原型:void setcolor(int color);函数功能: 设置前景颜色。

setcolor----C库函数图形屏幕函数;

说明函数原型:void setcolor(int color);

函数功能: 设置前景颜色。

0 - BLACK 黑

1 - BLUE 蓝 2 - GREEN 绿

3 - CYAN 青 4 - RED 红

5 - MAGENTA 洋红 6 - BROWN 棕

7 - LIGHTGRAY 淡灰 8 - DARKGRAY 深灰

9 - LIGHTBLUE 淡兰 10 - LIGHTGREEN 淡绿

11 - LIGHTCYAN 淡青 12 - LIGHTRED 淡红

13 - LIGHTMAGENTA 淡洋红 14 - YELLOW 黄

15 - WHITE 白

#include <graphics.h>

#include <stdlib.h>

#include <stdio.h>

#include <conio.h>

int main(void)

{

/* select a driver and mode that supports */

/* multiple drawing colors. */

int gdriver = EGA, gmode = EGAHI, errorcode;

int color, maxcolor, x, y;

char msg[80];

/* initialize graphics and local variables */

initgraph(&gdriver, &gmode, "");

/* read result of initialization */

errorcode = graphresult();

if (errorcode != grOk) /* an error occurred */

{

printf("Graphics error: %s\n", grapherrormsg(errorcode));

printf("Press any key to halt:");

getch();

exit(1); /* terminate with an error code */

}

/* maximum color index supported */

maxcolor = getmaxcolor();

/* for centering text messages */

settextjustify(CENTER_TEXT, CENTER_TEXT);

x = getmaxx() / 2;

y = getmaxy() / 2;

/* loop through the available colors */

for (color=1; color<=maxcolor; color++)

{

/* clear the screen */

cleardevice();

/* select a new background color */

setcolor(color);

/* output a messsage */

sprintf(msg, "Color: %d", color);

outtextxy(x, y, msg);

getch();

}

/* clean up */

closegraph();

return 0;

}