① c语言背景色怎么弄
C语言不存在背景色,C语言的编译器可以更换背景色,各种不同的编译器更换背景色的方法不同,需要参考其帮助文件,一般是在编辑环境设置中。
② 关于C语言图形操作的一个问题
setrgbpalette函数是用来调整系统调色板的:
setpalette
【功能】改变一种调色板颜色。
【原型】void far setpalette(int colornum,int color)
【位置】graphics.h
【参见】getpalette, graphresult, setallpalette, getpalettesize, setcolor, setrgbcolor, setbkcolor
setrgbcolor
【功能】为VGA和IBM-8514驱动程序设置调色板条目。
【原型】void far setrgbcolor(int colornum,int red,int green,int blue)
【位置】graphics.h
【说明】colornum表示需要设置的调色板条目,red、green和blue用来定义颜色。
【参见】setpalette,setrgbpalette
setrgbpalette
【功能】为IBM-8514图形卡定义颜色
【原型】void far setrgbpalette(int colornum,int red,int green,int blue)
【位置】graphics.h
【说明】colornum表示需要载入的调色板条目,从0~255之间的数字,red、green和blue负责定义颜色。这些数值仅仅使用低位字节,而且只有最重要的6位载入调色板。
【参见】setrgbcolor,setpalette
putpixel
【功能】在指定点上画一个像素。
【原型】void far putpixel(int x,int y,int pixelcolor)
【位置】graphics.h
【参见】getpixel,putimage
1026是色彩索引值,那个0是色彩的值,应该就是黑色。
③ C语言中的颜色和边框的函数怎么来运用···
if(c=='-')
{
if(strcmp(str2,"")==0) /*如果str2为空,说明是负号,而不是减号*/
flag=-1; /*设置负数标志*/
else
{
num1=atof(str2); /*将第二个操作数转换为浮点数*/
strcpy(str2,""); /*将str2清空*/
act=2; /*做计算减法标志值*/
setfillstyle(SOLID_FILL,color+3);
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*画矩形*/
outtextxy(5*width,height,"0."); /*显示字符串*/
}
}
if(c=='*')
{
num1=atof(str2); /*将第二个操作数转换为浮点数*/
strcpy(str2,""); /*将str2清空*/
act=3; /*做计算乘法标志值*/
setfillstyle(SOLID_FILL,color+3); bar(2*width+width/2,height/2,15*width/2,3*height/2);
outtextxy(5*width,height,"0."); /*显示字符串*/
}
if(c=='/')
{
num1=atof(str2); /*将第二个操作数转换为浮点数*/
strcpy(str2,""); /*将str2清空*/
act=4; /*做计算除法标志值*/
setfillstyle(SOLID_FILL,color+3);
bar(2*width+width/2,height/2,15*width/2,3*height/2);
outtextxy(5*width,height,"0."); /*显示字符串*/
}
if(c=='^')
{
num1=atof(str2); /*将第二个操作数转换为浮点数*/
strcpy(str2,""); /*将str2清空*/
act=5; /*做计算乘方标志值*/
setfillstyle(SOLID_FILL,color+3); /*设置用淡绿色实体填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*画矩形*/
outtextxy(5*width,height,"0."); /*显示字符串*/
}
if(c=='%')
{
num1=atof(str2); /*将第二个操作数转换为浮点数*/
strcpy(str2,""); /*将str2清空*/
act=6; /*做计算模运算乘方标志值*/
setfillstyle(SOLID_FILL,color+3); /*设置用淡绿色实体填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*画矩形*/
outtextxy(5*width,height,"0."); /*显示字符串*/
}
if(c=='=')
{
num2=atof(str2); /*将第二个操作数转换为浮点数*/
switch(act) /*根据运算符号计算*/
{
case 1:result=num1+num2;break; /*做加法*/
case 2:result=num1-num2;break; /*做减法*/
case 3:result=num1*num2;break; /*做乘法*/
case 4:result=num1/num2;break; /*做除法*/
case 5:result=pow(num1,num2);break; /*做x的y次方*/
case 6:result=fmod(num1,num2);break; /*做模运算*/
}
setfillstyle(SOLID_FILL,color+3); /*设置用淡绿色实体填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*覆盖结果区*/
sprintf(temp,"%f",result); /*将结果保存到temp中*/
outtextxy(5*width,height,temp); /*显示结果*/
}
if(c=='c')
{
num1=0; /*将两个操作数复位0,符号标志为1*/
num2=0;
flag=1;
strcpy(str2,""); /*将str2清空*/
setfillstyle(SOLID_FILL,color+3); /*设置用淡绿色实体填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*覆盖结果区*/
outtextxy(5*width,height,"0."); /*显示字符串*/
}
if(c=='Q')exit(0); /*如果选择了q回车,结束计算程序*/
}
putimage(x,y,rar,XOR_PUT); /*在退出之前消去光标箭头*/
return; /*返回*/
}
/*窗口函数*/
void mwindow( char *header )
{
int height;
cleardevice(); /* 清除图形屏幕 */
setcolor( MaxColors - 1 ); /* 设置当前颜色为白色*/
setviewport( 20, 20, MaxX/2, MaxY/2, 1 ); /* 设置视口大小 */
height = textheight( "H" ); /* 读取基本文本大小 */
settextstyle( DEFAULT_FONT, HORIZ_DIR, 1 );/*设置文本样式*/
settextjustify( CENTER_TEXT, TOP_TEXT );/*设置字符排列方式*/
outtextxy( MaxX/4, 2, header ); /*输出标题*/
setviewport( 20,20+height+4, MaxX/2+4, MaxY/2+20, 1 ); /*设置视口大小*/
drawboder(); /*画边框*/
}
void drawboder(void) /*画边框*/
{
struct viewporttype vp; /*定义视口类型变量*/
setcolor( MaxColors - 1 ); /*设置当前颜色为白色 */
setlinestyle( SOLID_LINE, 0, NORM_WIDTH );/*设置画线方式*/
getviewsettings( &vp );/*将当前视口信息装入vp所指的结构中*/
rectangle( 0, 0, vp.right-vp.left, vp.bottom-vp.top ); /*画矩形边框*/
}
/*设计鼠标图形函数*/
int arrow()
{
int size;
int raw[]={4,4,4,8,6,8,14,16,16,16,8,6,8,4,4,4}; /*定义多边形坐标*/
setfillstyle(SOLID_FILL,2); /*设置填充模式*/
fillpoly(8,raw); /*画出一光标箭头*/
size=imagesize(4,4,16,16); /*测试图象大小*/
rar=malloc(size); /*分配内存区域*/
getimage(4,4,16,16,rar); /*存放光标箭头图象*/
putimage(4,4,rar,XOR_PUT); /*消去光标箭头图象*/
return 0;
}
/*按键函数*/
int specialkey(void)
{
int key;
while(bioskey(1)==0); /*等待键盘输入*/
key=bioskey(0); /*键盘输入*/
key=key&0xff? key&0xff:key>>8; /*只取特殊键的扫描值,其余为0*/
return(key); /*返回键值*/
}
④ C语言怎么调颜色
第一步、进入到vs界面,在上方工具栏中选择箭头所指的工具选项,如下图所示。
⑤ c语言 在图形模式下的字体颜色如何设
SetTextColor()
具体的说明自己查查参考手册吧,祝你好运!
补充:
以上是在MSC环境下的函数。
如果在TC上,图形模式下,设置字体颜色和设置前景颜色一样,用setcolor();
outtext()以外的图形模式下的输出文本函数还有:outtextxy()
⑥ c语言编写的程序的颜色设置
楼主比较幽默。putoutChar(y-1,x-1,219,GREEN,BLACK);这里传过去是一个字符串,而接收函数只接受char类型:void
putoutChar(int
y,int
x,char
ch,char
fc,char
bc)
{
printScreen[(x*160)+(y<<1)+0]=ch;/*屏幕输出字符*/
printScreen[(x*160)+(y<<1)+1]=(bc*16)+fc;
/*指定字符颜色fc,背景色bc*/
}
调用的时候建议把:putoutChar(y-1,x-1,219,GREEN,BLACK);中的GREEN,BLACK用类似宏定义#define
BLACK
0
或者传过去的时候用int接收void
putoutChar(int
y,int
x,int
ch,int
fc,int
bc)
{
printScreen[(x*160)+(y<<1)+0]=ch;/*屏幕输出字符*/
printScreen[(x*160)+(y<<1)+1]=(bc*16)+fc;
/*指定字符颜色fc,背景色bc*/
}
⑦ c语言颜色函数color怎么使用
函数名: textbackground
功 能: 选择新的文本背景颜色
用 法: void textbackground(int color);
程序例:
#include <conio.h>
int main(void)
{
int i, j;
clrscr();
for (i=0; i<9; i++)
{
for (j=0; j<80; j++)
cprintf("C");
cprintf("\r\n");
textcolor(i+1);
textbackground(i);
}
return 0;
}
函数名: textcolor
功 能: 在文本模式中选择新的字符颜色
用 法: void textcolor(int color);
程序例:
#include <conio.h>
int main(void)
{
int i;
for (i=0; i<15; i++)
{
textcolor(i);
cprintf("Foreground Color\r\n");
}
return 0;
⑧ 求C语言怎么做让打出的界面有颜色
可以使用【system("color 0A");】函数来定义界面背景颜色、字体颜色,其定义在stdlib.h头文件中。其中color后面的0是背景色代号,A是前景色代号。各颜色代码如下:0=黑色 1=蓝色 2=绿色 3=湖蓝色 4=红色 5=紫色 6=黄色 7=白色 8=灰色 9=淡蓝色 A=淡绿色 B=淡浅绿色 C=淡红色 D=淡紫色 E=淡黄色 F=亮白色。
#include<stdio.h>
#include<stdlib.h>
/*
对应的颜色码表:
0=黑色8=灰色
1=蓝色9=淡蓝色
2=绿色A=淡绿色
3=浅绿色B=淡浅绿色
4=红色C=淡红色
5=紫色D=淡紫色
6=黄色E=淡黄色
7=白色F=亮白色
*/
intmain(void){
system("colorE9");/*淡黄色背景淡蓝色文字*/
printf("HelloWorld! ");
getch();
return0;
}
运行结果