请输入您要查询的百科知识:

 

词条 setcolor
释义

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

说明

函数原型:void setcolor(int color)

功能:将当前图形屏幕的当前笔画颜色置为color.

程序例:

#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\", 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;

}

随便看

 

百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。

 

Copyright © 2004-2023 Cnenc.net All Rights Reserved
更新时间:2024/11/16 7:22:24