㈠ c语言改变字体颜色的代码
1,用样式表(css),在组件里面加上style属性,例如:
<div style="background-color:blue;font-family:宋体;">
欢迎你
</div>
2,直接在字体两边加font标记,例如:
<font color=blue >欢迎你</font>
(1)颜色识别c语言源代码扩展阅读
<input name="submit" type="submit" value="changeColor" onClick="changeColor()">
<span id="wenzi">wenzi</span>
<script>
function changeColor(){
document.all['wenzi'].style.color="#ff0000";
}
</script>
㈡ 如何实现c语言程序各颜色数字雨代码
#include<stdio.h>
#include<time.h>
#include<windows.h>
typedef struct
{
int x,y;
char ch;
}STU;
STU st[100];
//出现位置
void gotoxy(int x, int y)
{
HANDLE hout;
COORD pos;
pos.X = x;
pos.Y = y;
hout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hout, pos);
}
/*隐藏光标*/
void show_cursor(int hide)
{
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hout;
hout = GetStdHandle(STD_OUTPUT_HANDLE);
if(GetConsoleCursorInfo(hout, &cciCursor))
{
cciCursor.bVisible = hide;
SetConsoleCursorInfo(hout, &cciCursor);
}
}
/*设置颜色*/
void set_color(int color)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
}
main()
{
int i,j;
show_cursor(0);
srand(time(NULL));
//初始化结构体
for (i=0;i<100;i++)
{
st[i].x = rand()%80;
st[i].y = rand()%20;
st[i].ch = rand()%(49-47)+48;
}
while (1)
{
for (i=0;i<100;i++)
{
gotoxy(st[i].x,st[i].y);
set_color(0x2);//最先出现的颜色;
putchar(st[i].ch);
gotoxy(st[i].x,st[i].y-5);
putchar(' ');
st[i].y++;
st[i].ch = rand()%(49-47)+48;
if (st[i].y-5>=18)
{
gotoxy(st[i].x,st[i].y-1);
putchar(' ');
gotoxy(st[i].x,st[i].y-2);
putchar(' ');
gotoxy(st[i].x,st[i].y-3);
putchar(' ');
gotoxy(st[i].x,st[i].y-4);
putchar(' ');
gotoxy(st[i].x,st[i].y-4);
putchar(' ');
}
if (st[i].y > 23)
{
st[i].x = rand()%80;
st[i].y = rand()%20;
}
gotoxy(st[i].x,st[i].y);
set_color(0xA);//由前一个颜色渐变成的颜色
putchar(st[i].ch);
}
Sleep(120);
}
}

几个基本的颜色;
㈢ 求51单片机用的的 TCS230D颜色识别模块c语言程序
//转自某某大侠的(名字忘了)此程序用于颜色模块TCS230D的51驱动(2010.08.26大侠)
//鉴于你应该知道TCS230D芯片的资料,芯片引脚功能我就不说了
#include<reg52.h>
unsigned char tmp;
/*******************************************
定义颜色识别模块引脚
*******************************************/
sbit clr_S0=P3^0;
sbit clr_S1=P3^1;
//设置p3.0脚3.1脚分别接到tcs230d芯片的s0和s1脚
sbit clr_OE=P3^2;
sbit clr_OUT=P3^5;
//设置p3.2脚3.5脚分别接到tcs230d芯片的OE和OUT脚
sbit clr_S2=P3^4;
sbit clr_S3=P3^3;
//设置p3.4脚3.3脚分别接到tCS230D芯片的S2和S3脚
/*******************************************/
/**********
串口初始化
***********************/
/*******************************************/
void init_ser()//初始化串口
{
TMOD=0x20;
TH1=0xfd;
TL1=0xfd;
SCON=0x50;
PCON&=0xef;
TR1=1;
IE=0x00;
}
void ser_sendchar(unsigned char a)//串口发送一个字节
{
SBUF=a;
while(!TI);
TI=0;
}
/*******************************************/
/********
颜色识别模块配置
*******************/
/*******************************************/
void init_clr()
{
clr_OE=1;
}
unsigned int clr_get(unsigned char a)
{
unsigned int time;
TMOD=0x61;//设置定时器0工作方式为16位
TH0=TL0=0x00;//设置定时器0从0计时
TH1=TL1=0x00;
clr_S0=1;
clr_S1=1;
clr_S2=a&0x02;
clr_S3=a&0x01;
clr_OE=0;
TR1=TR0=1;
while(TL1<250);
TR1=TR0=0;
clr_OE=1;
time=TH0*256+TL0;
return(time);
}
/*******************************************/
/*******************************************/
/*******************************************/
void main()
{
unsigned int a;
init_ser();
init_clr();
while(1)
{
if(RI)
{
RI=0;
tmp=SBUF;
a=clr_get(tmp);
init_ser();
ser_sendchar(a&0x00ff);
ser_sendchar(a/256);
}
}
}
以上就是整个代码部分,希望有帮助
㈣ 求C语言颜色代码
#include<string.h>
main()
{charstr1[100],str2[100];
inti,j;
gets(str1);
for(i=0;str1[i]!='