求真百科歡迎當事人提供第一手真實資料,洗刷冤屈,終結網路霸凌。

Setcolor檢視原始碼討論檢視歷史

事實揭露 揭密真相
前往: 導覽搜尋
Setcolor

來自 搜狐網 的圖片

Setcolor C庫函數 圖形屏幕函數;說明函數原型:void setcolor(int color);函數功能: 設置前景顏色。

基本信息

中文名稱 C庫函數圖形屏幕函數 [1]

外文名稱 setcolor

函數原型 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 白

程序例

  1. include <graphics.h>
  1. include <stdlib.h>
  1. include <stdio.h>只獄嚷龍
  1. 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;

}

參考來源