① 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;
}
運行結果