查看完整版本: [收集]缤纷选色代码集合。。

tension 2007-9-7 15:19

[收集]缤纷选色代码集合。。

[b]直接调用系统调色板[/b]

[html]<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT>
<script>
var tempColor = "0099cc";
function returnColor(){
        var Hcolor = dlgHelper.ChooseColorDlg(tempColor).toString(16);
        with(event.srcElement){
                value = ((Hcolor.length<6)?"000000".substring(0,6-Hcolor.length):"") + Hcolor;       
                style.backgroundColor = ((Hcolor.length<6)?"000000".substring(0,6-Hcolor.length):"") + Hcolor;       
        }       
        tempColor = Hcolor
}
</script>
<input type="text" value="#0099CC" size="12" onclick="returnColor()" style="background-color: #0099CC">[/html]

tension 2007-9-7 15:19

[b]利用JS做的一个网页安全色调色板[/b]

[html]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2311">
<title>DW调色板</title>
<script>
var ColorHex=new Array('00','33','66','99','CC','FF')
var SpColorHex=new Array('FF0000','00FF00','0000FF','FFFF00','00FFFF','FF00FF')
var current=null
function intocolor()
{
var colorTable=''
for (i=0;i<2;i++)
{
  for (j=0;j<6;j++)
   {
    colorTable=colorTable+'<tr height=12>'
    colorTable=colorTable+'<td width=11 style="background-color:#000000">'
   
    if (i==0){
    colorTable=colorTable+'<td width=11 style="background-color:#'+ColorHex[j]+ColorHex[j]+ColorHex[j]+'">'}
    else{
    colorTable=colorTable+'<td width=11 style="background-color:#'+SpColorHex[j]+'">'}
   
    colorTable=colorTable+'<td width=11 style="background-color:#000000">'
    for (k=0;k<3;k++)
     {
       for (l=0;l<6;l++)
       {
        colorTable=colorTable+'<td width=11 style="background-color:#'+ColorHex[k+i*3]+ColorHex[l]+ColorHex[j]+'">'
       }
     }
  }
}
colorTable='<table width=253 border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 solid;border-bottom:none;border-collapse: collapse" bordercolor="000000">'
           +'<tr height=30><td colspan=21 bgcolor=#cccccc>'
           +'<table cellpadding="0" cellspacing="1" border="0" style="border-collapse: collapse">'
           +'<tr><td width="3"><td><input type="text" name="DisColor" size="6" disabled style="border:solid 1px #000000;background-color:#ffff00"></td>'
           +'<td width="3"><td><input type="text" name="HexColor" size="7" style="border:inset 1px;font-family:Arial;" value="#000000"></td></tr></table></td></table>'
           +'<table border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="000000" onmouseover="doOver()" onmouseout="doOut()" onclick="doclick()" style="cursor:hand;">'
           +colorTable+'</table>';         
colorpanel.innerHTML=colorTable
}
function doOver() {
      if ((event.srcElement.tagName=="TD") && (current!=event.srcElement)) {
        if (current!=null){current.style.backgroundColor = current._background}     
        event.srcElement._background = event.srcElement.style.backgroundColor
        DisColor.style.backgroundColor = event.srcElement.style.backgroundColor
        HexColor.value = event.srcElement.style.backgroundColor
        event.srcElement.style.backgroundColor = "white"
        current = event.srcElement
      }
}
function doOut() {
    if (current!=null) current.style.backgroundColor = current._background
}
function doclick(){
if (event.srcElement.tagName=="TD"){
alert("选取颜色: "+event.srcElement._background)
return event.srcElement._background
}
}
</script>
</head>
<body onload="intocolor()">
<div id="colorpanel" style="position: absolute;">
 </div>
</body>
</html>[/html]

配合下面一段代码使用

[html]<SCRIPT>
var dWin=null;
function doDialog()
{
dWin=showModelessDialog('color.html',window,'status:no;dialogWidth:260px;dialogHeight:200px');
}
</SCRIPT>
<form name=form1>
<input name="color1">
<button onclick="doDialog();" >open</button>
</form>[/html]

tension 2007-9-7 15:22

[b]Fellow牌调色板[/b]

[html]<head>
<title>Untitled Document-[url]www.51windows.Net[/url]</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--- Designed By Fellow 12/2001 --->
<!--- Copyright(c)Fellow's Own World,2001 --->
<META name="author" content="fellow99@163.net">
<META NAME="DESCRIPTION" CONTENT="Fellow's Own World">
<style type="text/css">
<!--
body {font:menu}
td,selcet,input {  font:menu}
.memo {  border: 1px #dddddd solid}
.button {  border-color: #CCCCCC #666666 #666666 #CCCCCC; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
.cursorcross {  cursor: crosshair}
.cursorhand {  cursor: hand}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div align="center"><b><font color="#003366">Fellow牌调色板 Ver1.1</font></b><br>
<br>
</div>
<table border="0" cellspacing="1" cellpadding="3" width="350" align="center" bgcolor="#dddddd">
<tr bgcolor="#FFFFFF">
<td width="10%" align="center">
<select name="select1" onchange="selectchg(this.value)">
<option value="1" selected>红</option>
<option value="2">绿</option>
<option value="3">蓝</option>
<option value="4">灰</option>
</select>
</td>
<td width="90%" align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right">
<input type="text" name="text1" class="memo" size="10">
<input type="button" name="Button2" value="&gt;&gt;" class="button" onClick="choosecolor()">
</td>
<td align="right" width="3%">&nbsp;</td>
<td width="30%">
<table width="40" border="0" cellspacing="1" cellpadding="0" height="20"  class="cursorcross">
<tr>
<td id="customcolor" bgcolor="#FFFFFF"  onMouseOver="showcolor(this)">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="10%" align="center">
<table id="tableleft" border="0" cellspacing="1" cellpadding="0" class="cursorhand">
<script language="VBScript">
function hexit(which)
hexit=hex(which)
end function
</script>
<script language="JavaScript">
for(i=0;i<=15;++i)
{document.write('<tr><td align="center">'+ hexit(0+i*17) +'</td><td id="tdleft' + i +'" bgcolor="rgb('+ (0+i*17) + ',0,0)" width="15" height="15" onclick="changeright(this.num)" onmouseover="showcolor(this)"></td></tr>')
document.all['tdleft' + i].num=i
}
</script>
</table>
</td>
<td align="center" width="90%">
<table id="tableleft" border="0" cellspacing="1" cellpadding="0" class="cursorcross">
<script language="JavaScript">
document.write('<tr><td></td>')
for(i=0;i<=15;++i)
{document.write('<td align="center">'+ hexit(0+i*17) +'</td>')}
document.write('</tr>')
for(i=0;i<=15;++i)
{document.write('<tr>')
document.write('<td align="center">'+ hexit(0+i*17) +'</td>')
for(j=0;j<=15;++j)
  {document.write('<td id="tdrightr' + i + 'c' + j +'" bgcolor="rgb(0,'+ (0+i*17) + ',' + (0+j*17) + ')" width="15" height="15" onmouseover="showcolor(this)" onclick="clickright(this)"></td>')}
document.write('</tr>')
}
</script>
</table>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2" height="20">·可选16*16*16种颜色。<br>
·单击左边的颜色会得到更多的颜色。<br>
·单击右边的颜色会固定选取的颜色。 <br>
·输入框可以自定义颜色。</td>
</tr>
</table>
<script language="JavaScript">
function selectchg(which)
{switch(which)
  {case '1' :leftR();break;
   case '2' :leftG();break;
   case '3' :leftB();break;
   case '4' :leftA();break;
  }
}
function leftR()
{for(i=0;i<=15;++i)
   {document.all['tdleft'+i].bgColor='rgb('+ (0+i*17) + ',0,0)'}
rightR(0)
}
function leftG()
{for(i=0;i<=15;++i)
   {document.all['tdleft'+i].bgColor='rgb(0,'+ (0+i*17) + ',0)'}
rightG(0)
}
function leftB()
{for(i=0;i<=15;++i)
   {document.all['tdleft'+i].bgColor='rgb(0,0,'+ (0+i*17) + ')'}
rightB(0)
}
function leftA()
{for(i=0;i<=15;++i)
   {document.all['tdleft'+i].bgColor='rgb('+ (0+i*17) + ','+ (0+i*17) + ','+ (0+i*17) + ')'}
rightA()
}
function rightR(which)
{for(i=0;i<=15;++i)
   {for(j=0;j<=15;++j)
     {document.all['tdrightr' + i + 'c' + j].bgColor='rgb(' + (0+which*17) + ',' + (0+i*17) + ','+ (0+j*17) + ')'}
    }
}
function rightG(which)
{for(i=0;i<=15;++i)
   {for(j=0;j<=15;++j)
     {document.all['tdrightr' + i + 'c' + j].bgColor='rgb(' + (0+i*17) + ',' + (0+which*17) +  ',' + (0+j*17) + ')'}
    }
}
function rightB(which)
{for(i=0;i<=15;++i)
   {for(j=0;j<=15;++j)
     {document.all['tdrightr' + i + 'c' + j].bgColor='rgb(' + (0+i*17) + ','+ (0+j*17)+ ',' + (0+which*17) + ')'}
    }
}
function rightA()
{for(i=0;i<=15;++i)
   {for(j=0;j<=15;++j)
     {document.all['tdrightr' + i + 'c' + j].bgColor='rgb(' + (0+i*16+j) + ','+ (0+i*16+j)+ ',' + (0+i*16+j) + ')'}
    }
}
var rightclicked=false
function clickright(which)
{if(rightclicked){rightclicked=false;showcolor(which)}else{rightclicked=true}
}
function changeright(which)
{switch(select1.value)
  {case '1' :rightR(which);break;
   case '2' :rightG(which);break;
   case '3' :rightB(which);break;
}
}
function showcolor(which)
{if(rightclicked)return;
text1.value=which.bgColor
choosecolor()
}
function choosecolor()
{customcolor.bgColor=text1.value
}
</script>
</body>
</html>
[/html]

tension 2007-9-7 15:27

[b]又一款[/b]

[html]<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<style type="text/css">
body{background-color: buttonface; }
input{font-size:9pt;font-family: "verdana,tahoma,arial,sans-serif";}
button{height:24px;font-size:10pt;font-family: "verdana,tahoma,arial,sans-serif";}
</style>
</head>
<body onSelectStart="return false;" style="margin: 0px;padding: 0px;">
<script language="JavaScript">
document.title="颜色选择"+ document.title;
var iW = 30;//共有6种颜色,每种颜色的宽为iW。iW*6为色带的宽。
var iH = '152';//iH为色带的高。
var iT =20;
var iL = 0;
//var iT = (document.body.offsetHeight-iH)/2;
var H,S,V;
var sr,sg,sb;
var curColor="#000000";
</script>
<table cellspacing="0" cellpadding="0">
        <tr>
                <td>       
                        <input type=text disabled=true size=9 id=ShowColor style="background-color:#000000;disabled:true;"><input type=text disabled=true size=15 id=SelColor value="#000000">
        </td>
  </tr>
</table>
<script language="Javascript">
function SetColor(){
        SelColor.value=curColor.toUpperCase();
        ShowColor.style.background=curColor;
}
function HSV(){
        var pX = event.offsetX;
        var pY = event.offsetY;
        var HalfH = parseInt(iH/2);
        H = parseInt(pX*360/(iW*6));
        if(event.offsetY < HalfH){
                S = pY/HalfH;
                V = 1;
        }else{
                S = 1;
                V = (iH-pY)/HalfH;
        }
        HSVtoRGB();
        rgb=RGB2HTML();
        //HSV.value = 'H:'+H+'  S:'+parseInt(S*100)+'%   V:'+parseInt(V*100)+'%';
        //RGB.value = 'R:'+sr+'  G:'+sg+'   B:'+sb;
        SelColor.value="#"+rgb.toUpperCase();
        ShowColor.style.background= '#'+rgb;
}
function HSVtoRGB(){
        var r,g,b;
        var k = (H%60)/60;
        var c1 = V*(1-S);
        var c2 = V*(1-S*k);
        var c3 = V*(1-S*(1-k));
        switch(parseInt(H/60)){
                case 0 : r=V,g=c3;b=c1; break;
                case 1 : r=c2,g=V;b=c1; break;
                case 2 : r=c1,g=V;b=c3; break;
                case 3 : r=c1,g=c2;b=V; break;
                case 4 : r=c3,g=c1;b=V; break;
                case 5 : r=V,g=c1;b=c2; break;
        }
        sr = parseInt(r*255);
        sg = parseInt(g*255);
        sb = parseInt(b*255);
}
function RGB2HTML(){
        var r=(sr>=16)?sr.toString(16):('0'+sr.toString(16));
        var g=(sg>=16)?sg.toString(16):('0'+sg.toString(16));
        var b=(sb>=16)?sb.toString(16):('0'+sb.toString(16));
        return r+g+b;
}
function finsh(){
        window.returnValue = SelColor.value;
        window.close();
}
function window.onload(){
        var iHtml = '';
        var RainBow = [255,0,0,  255,255,0,  0,255,0,  0,255,255,  0,0,255,  255,0,255,  255,0,0];
        for(var i=0;i<6;i++){
                var R1 = RainBow[i*3];
                var G1 = RainBow[i*3+1];
                var B1 = RainBow[i*3+2];
                var R2 = RainBow[(i+1)*3];
                var G2 = RainBow[(i+1)*3+1];
                var B2 = RainBow[(i+1)*3+2];
                iHtml += "<span style='position:absolute;left:"+(i*iW+iL)+";top:"+iT+";width:"+iW+";height:"+iH+";background:rgb("+R1+","+G1+","+B1+");'></span><span style='position:absolute;left:"+(i*iW+iL)+";top:"+iT+";width:"+iW+";height:"+iH+";background:rgb("+R2+","+G2+","+B2+");filter:alpha(opacity=0,finishopacity=100,Style=1);'></span>"
        }
        iHtml += "<span style=position:absolute;left:"+iL+";top:"+iT+";width:"+iW*6+";height:"+iH/2+";background:rgb(255,255,255);filter:alpha(opacity=100,finishOpacity=0,style=1,starty=0,finishy=100,startx=0,finishx=0)></span><span style=position:absolute;left:"+iL+";top:"+(iT+iH/2)+";width:"+iW*6+";height:"+iH/2+";background:rgb(0,0,0);filter:alpha(opacity=0,finishOpacity=100,style=1,starty=0,finishy=100,startx=0,finishx=0)></span><span style='cursor:crosshair;position:absolute;left:"+iL+";top:"+iT+";width:"+iW*6+";height:"+iH+";' onmousemove=HSV() ondblclick=finsh() onclick='curColor=SelColor.value' onmouseout=SetColor()></span>"
        document.body.innerHTML+=iHtml;
        SetColor();
}
</script>
</body>
</html>[/html]

tension 2007-9-7 15:29

[b]JS写的调色板[/b]

[html]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>调色板工具</title>
<style type="text/css">
<!--
td {font-size:12px;}
-->
</style>
</head>
<body bgColor=ece9d8>
<script type="text/javascript">
<!--
var SelRGB = '#000000';
var DrRGB = '';
var SelGRAY = '120';
var hexch = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
function ToHex(n)
{var h, l;
n = Math.round(n);
l = n % 16;
h = Math.floor((n / 16)) % 16;
return (hexch[h] + hexch[l]);
}
function DoColor(c, l)
{ var r, g, b;
r = '0x' + c.substring(1, 3);
g = '0x' + c.substring(3, 5);
b = '0x' + c.substring(5, 7);  
if(l > 120)
{
l = l - 120;
r = (r * (120 - l) + 255 * l) / 120;
g = (g * (120 - l) + 255 * l) / 120;
b = (b * (120 - l) + 255 * l) / 120;
}else{
r = (r * l) / 120;
g = (g * l) / 120;
b = (b * l) / 120;
}
return '#' + ToHex(r) + ToHex(g) + ToHex(b);
}
function EndColor()
{ var i;
if(DrRGB != SelRGB)
{
DrRGB = SelRGB;
for(i = 0; i <= 30; i ++)
GrayTable.rows(i).bgColor = DoColor(SelRGB, 240 - i * 8);
}
SelColor.value = DoColor(RGB.innerText, GRAY.innerText);
ShowColor.bgColor = SelColor.value;
}
//-->
</script>
<script type="text/javascript" for="ColorTable" event="onclick">
<!--
SelRGB = event.srcElement.bgColor;
EndColor();
//-->
</script>
<script type="text/javascript" for="ColorTable" event="onmouseover">
<!--
RGB.innerText = event.srcElement.bgColor.toUpperCase();
EndColor();
//-->
</script>
<script type="text/javascript" for="ColorTable" event="onmouseout">
<!--
RGB.innerText = SelRGB;
EndColor();
//-->
</script>
<script type="text/javascript" for="GrayTable" event="onclick">
<!--
SelGRAY = event.srcElement.title;
EndColor();
//-->
</script>
<script type="text/javascript" for="GrayTable" event="onmouseover">
<!--
GRAY.innerText = event.srcElement.title;
EndColor();
//-->
</script>
<script type="text/javascript" for="GrayTable" event="onmouseout">
<!--
GRAY.innerText = SelGRAY;
EndColor();
//-->
</script>
<script type="text/javascript" for="Ok" event="onclick">
<!--
window.returnValue = SelColor.value;
window.close();
//-->
</script>
</head>
<body bgcolor=menu>
<div align="center"><table border="0" cellspacing="10" cellpadding="0"><tr><td>
<table ID="ColorTable" CELLSPACING=0 CELLPADDING=0 style='border:0px; cursor:pointer'>
<script language="javascript" type="text/javascript">
<!--
function wc(r, g, b, n)
{
r = ((r * 16 + r) * 3 * (15 - n) + 0x80 * n) / 15;
g = ((g * 16 + g) * 3 * (15 - n) + 0x80 * n) / 15;
b = ((b * 16 + b) * 3 * (15 - n) + 0x80 * n) / 15;
document.write('<TD BGCOLOR=#' + ToHex(r) + ToHex(g) + ToHex(b) + ' height=8 width=8></TD>');
}
var cnum = new Array(1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0);
for(i = 0; i < 16; i ++)
{
document.write('<TR>');
for(j = 0; j < 30; j ++)
{
n1 = j % 5;
n2 = Math.floor(j / 5) * 3;
n3 = n2 + 3;
wc((cnum[n3] * n1 + cnum[n2] * (5 - n1)),
   (cnum[n3 + 1] * n1 + cnum[n2 + 1] * (5 - n1)),
   (cnum[n3 + 2] * n1 + cnum[n2 + 2] * (5 - n1)), i);
     }
document.writeln('</tr>');
}
//-->
</script>
</table></td><td><table id="GrayTable" cellspacing="0" cellpadding="0" style="border:0px; cursor:hand;">
<script type="text/javascript">
<!--
for(i = 255; i >= 0; i -= 8.5)
document.write('<tr bgcolor=#' + ToHex(i) + ToHex(i) + ToHex(i) + '><td title=' + Math.floor(i * 16 / 17) + ' height=4 width=20></td></tr>');
//-->
</script>
</table></td></tr></table></center></div>
<div align="center"><center>
<table cellspacing="10" cellpadding="0" style="border:0px; width:100%;"><tr><td rowspan="2" align="center" width=70>
<table id="ShowColor" cellspacing="0" cellpadding="0" style="border:1px solid #000; width: 50px; height:40px; background:#000;"><tr><td></td></tr></table>
</td><td rowspan="2">
基色:<span id="RGB">#000000</span><br />
亮度:<SPAN ID=GRAY>120</SPAN><BR>
代码:<input type="TEXT" size="6" id="SelColor" value="#000000" /></td>
<td width=50><button id=Ok type=submit>确定</button></td></tr>
<tr><td width=50><button onclick=window.close();>关闭</button></td></tr>
</table></center></div>
</body>   
</html>[/html]

tension 2007-9-7 15:34

[b]216色[/b]

[html]<HTML><HEAD><TITLE>Typhoon Start JavaScript Fairyland</TITLE>
<STYLE type=text/css>#subtext {
    BACKGROUND-COLOR: #cccccc; FONT-FAMILY: helvetica,arial; FONT-SIZE: 8pt; layer-background-color: #CCCCCC
}
#title {
    FONT-FAMILY: helvetica,arial; FONT-SIZE: 13pt; FONT-WEIGHT: bold
}
#red {
    BACKGROUND-IMAGE: url(redback.gif); CLIP: rect(0px 256px 10px 0px); HEIGHT: 10px; LEFT: 54px; POSITION: absolute; TOP: 100px; VISIBILITY: visible; WIDTH: 256px; Z-INDEX: 1; layer-background-image: url(redback.gif)
}
#green {
    BACKGROUND-IMAGE: url(greenback.gif); CLIP: rect(0px 256px 10px 0px); HEIGHT: 10px; LEFT: 54px; POSITION: absolute; TOP: 120px; VISIBILITY: visible; WIDTH: 256px; Z-INDEX: 1; layer-background-image: url(greenback.gif)
}
#blue {
    BACKGROUND-IMAGE: url(blueback.gif); CLIP: rect(0px 256px 10px 0px); HEIGHT: 10px; LEFT: 54px; POSITION: absolute; TOP: 140px; VISIBILITY: visible; WIDTH: 256px; Z-INDEX: 1; layer-background-image: url(blueback.gif)
}
#redSlider {
    BACKGROUND-IMAGE: url(scroll-boxh.gif); CLIP: rect(0px 8px 14px 0px); HEIGHT: 14px; LEFT: 50px; POSITION: absolute; TOP: 98px; VISIBILITY: visible; WIDTH: 8px; Z-INDEX: 2; layer-background-image: url(scroll-boxh.gif)
}
#greenSlider {
    BACKGROUND-IMAGE: url(scroll-boxh.gif); CLIP: rect(0px 8px 14px 0px); HEIGHT: 14px; LEFT: 50px; POSITION: absolute; TOP: 118px; VISIBILITY: visible; WIDTH: 8px; Z-INDEX: 2; layer-background-image: url(scroll-boxh.gif)
}
#blueSlider {
    BACKGROUND-IMAGE: url(scroll-boxh.gif); CLIP: rect(0px 8px 14px 0px); HEIGHT: 14px; LEFT: 50px; POSITION: absolute; TOP: 138px; VISIBILITY: visible; WIDTH: 8px; Z-INDEX: 2; layer-background-image: url(scroll-boxh.gif)
}
#display {
    BACKGROUND-COLOR: #000000; HEIGHT: 50px; LEFT: 320px; POSITION: absolute; TOP: 100px; VISIBILITY: visible; WIDTH: 50px; Z-INDEX: 1; layer-background-color: #000000
}
#hexValue {
    HEIGHT: 20px; LEFT: 54px; POSITION: absolute; TOP: 160px; VISIBILITY: visible; WIDTH: 320px; Z-INDEX: 1
}
#titleBar {
    BACKGROUND-COLOR: #dddddd; HEIGHT: 20px; LEFT: 54px; POSITION: absolute; TOP: 70px; WIDTH: 320px; Z-INDEX: 1; layer-background-color: #DDDDDD
}
#colorTable {
    HEIGHT: 200px; LEFT: 380px; POSITION: absolute; TOP: 70px; VISIBILITY: visible; WIDTH: 320px; Z-INDEX: 1
}
</STYLE>
<SCRIPT language=JavaScript>
<!-- Begin
function init() {
ns4 = (document.layers)?true:false;
ie4 = (document.all)?true:false;
sliderMin = 50;
sliderMax = 306;
rValue=0;
gValue=0;
bValue=0;
r1 = '0';
r2 = '0';
g1 = '0';
g2 = '0';
b1 = '0';
b2 = '0';
Rgb = '0';
rGb = '0';
rgB = '0';
rActive = false;
gActive = false;
bActive = false;
document.onmousedown = mouseDown
document.onmousemove = mouseMove
document.onmouseup = mouseUp
if (ns4) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
if (ns4) {
domRed = document.redSlider;
domRed.xpos = parseInt(domRed.left);
domRed.ypos = parseInt(domRed.top);
domRed.w = domRed.clip.width;
domRed.h = domRed.clip.height;
domGreen = document.greenSlider;
domGreen.xpos = parseInt(domGreen.left);
domGreen.ypos = parseInt(domGreen.top);
domGreen.w = domGreen.clip.width;
domGreen.h = domGreen.clip.height;
domBlue = document.blueSlider;
domBlue.xpos = parseInt(domBlue.left);
domBlue.ypos = parseInt(domBlue.top);
domBlue.w = domBlue.clip.width;
domBlue.h = domBlue.clip.height;
domDisplay = document.display;
domValue = document.hexValue.document.frmValue.valueDisp;
domredValue = document.hexValue.document.frmValue.RgbDisp;
domgreenValue = document.hexValue.document.frmValue.rGbDisp;
domblueValue = document.hexValue.document.frmValue.rgBDisp;
}
else {
domRed = redSlider.style;
domRed.xpos = redSlider.offsetLeft;
domRed.ypos = redSlider.offsetTop;
domRed.w = redSlider.clientWidth;
domRed.h = redSlider.clientHeight;
domGreen = greenSlider.style;
domGreen.xpos = greenSlider.offsetLeft;
domGreen.ypos = greenSlider.offsetTop;
domGreen.w = greenSlider.clientWidth;
domGreen.h = greenSlider.clientHeight;
domBlue = blueSlider.style;
domBlue.xpos = blueSlider.offsetLeft;
domBlue.ypos = blueSlider.offsetTop;
domBlue.w = blueSlider.clientWidth;
domBlue.h = blueSlider.clientHeight;
domDisplay = display;
domValue = frmValue.valueDisp;
domredValue = frmValue.RgbDisp;
domgreenValue = frmValue.rGbDisp;
domblueValue = frmValue.rgBDisp;
}
hexArray = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
}
function mouseDown(e) {
if ((ns4 && e.which!=1) || (ie4 && event.button!=1)) return true;
var x = (ns4)? e.pageX : event.x+document.body.scrollLeft;
var y = (ns4)? e.pageY : event.y+document.body.scrollTop;
if (x > domRed.xpos && x < domRed.xpos+domRed.w && y > domRed.ypos && y < domRed.ypos+domRed.h){ rActive = true; dragObject = domRed; }
if (x > domGreen.xpos && x < domGreen.xpos+domGreen.w && y > domGreen.ypos && y < domGreen.ypos+domGreen.h){ gActive = true; dragObject = domGreen; }
if (x > domBlue.xpos && x < domBlue.xpos+domBlue.w && y > domBlue.ypos && y < domBlue.ypos+domBlue.h){ bActive = true; dragObject = domBlue; }
if (rActive==true || gActive==true || bActive==true){
if (x>=dragObject.xpos && x<=dragObject.xpos+dragObject.w) {
dragObject.dragOffsetX = x-dragObject.xpos
}
return false
}
else {
return true
   }
}
function mouseMove(e) {
var x = (ns4)? e.pageX : event.x+document.body.scrollLeft;
var y = (ns4)? e.pageY : event.y+document.body.scrollTop;
if (rActive) {
rMoveTo = x-dragObject.dragOffsetX;
if (rMoveTo > sliderMax) rMoveTo = 306;
if (rMoveTo < sliderMin) rMoveTo = 50;
domRed.xpos = rMoveTo;
domRed.left = domRed.xpos;
rValue = (domRed.xpos+4)-50;
calcValue(rMoveTo-50, 'red');
}
if (gActive) {
gMoveTo = x-dragObject.dragOffsetX;
if (gMoveTo > sliderMax) gMoveTo = sliderMax;
if (gMoveTo < sliderMin) gMoveTo = sliderMin;
domGreen.xpos = gMoveTo;
domGreen.left = domGreen.xpos;
gValue = (domGreen.xpos+4)-50;
calcValue(gMoveTo-50, 'green');
}
if (bActive) {
bMoveTo = x-dragObject.dragOffsetX;
if (bMoveTo > sliderMax) bMoveTo = sliderMax;
if (bMoveTo < sliderMin) bMoveTo = sliderMin;
domBlue.xpos = bMoveTo;
domBlue.left = domBlue.xpos;
bValue = (domBlue.xpos+4)-50;
calcValue(bMoveTo-50, 'blue');
}
return true
}
function mouseUp(e) {
var x = (ns4)? e.pageX : event.x+document.body.scrollLeft
var y = (ns4)? e.pageY : event.y+document.body.scrollTop
rActive = false;
gActive = false;
bActive = false;
return true
}
function calcValue(base, color) {
base -= 1;
if (base < 16) { first = 0; }
else { first = parseInt(base/16); }
if (base < 0 ) { second = 0; base = 0; }
else { second = parseInt(base%16); }
c1=hexArray[first];
c2=hexArray[second];
if (color == 'red') { r1 = c1; r2 = c2; Rgb=base; }
else if (color == 'green') { g1 = c1; g2 = c2; rGb=base; }
else { b1 = c1; b2 = c2; rgB=base; }
domValue.value = eval('"'+r1+r2+g1+g2+b1+b2+'"');
domredValue.value = eval('"'+Rgb+'"');
domgreenValue.value = eval('"'+rGb+'"');
domblueValue.value = eval('"'+rgB+'"');
if (ns4) { domDisplay.bgColor = eval('"#'+r1+r2+g1+g2+b1+b2+'"'); }
else { domDisplay.style.backgroundColor = eval('"#'+r1+r2+g1+g2+b1+b2+'"'); }
return true;
}
function manualSet(value,color) {
if (value < 0) value=0;
if (value > 255) value=255;
++value;
calcValue(value,color);
if (color == 'red'){ domRed.xpos = value+sliderMin-4; domRed.left = domRed.xpos; }
else if (color == 'green'){ domGreen.xpos = value+sliderMin-4; domGreen.left = domGreen.xpos; }
else { domBlue.xpos = value+sliderMin-4; domBlue.left = domBlue.xpos; }
}
function convertHex(hexString) {
if(hexString == null) hexString = domValue.value;
inputHexArray = new Array(6);
for(i=0;i<=5;++i) {
inputHexArray[i] = hexString.charAt(i);
}
for(i=0;i<=5;++i) {
tempHexVal = inputHexArray[i];
for(j=0;j<=15;++j) {
if(tempHexVal == hexArray[j]) tempHexVal = j;
}
inputHexArray[i] = tempHexVal;
}
Rgb = (inputHexArray[0]*16)+inputHexArray[1]+1;
calcValue(Rgb,'red');
manualSet(Rgb,'red');
rGb = (inputHexArray[2]*16)+inputHexArray[3]+1;
calcValue(rGb,'green');
manualSet(rGb,'green');
rgB = (inputHexArray[4]*16)+inputHexArray[5]+1;
calcValue(rgB,'blue');
manualSet(rgB,'blue');
}
// End -->
</SCRIPT>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META content="MSHTML 5.00.3315.2870" name=GENERATOR></HEAD>
<BODY aLink=#33ff33 bgColor=#ffffff link=#33ff33 onload=init() text=#999999
vLink=#33ff33>
<DIV id=red></DIV>
<DIV id=green></DIV>
<DIV id=blue></DIV>
<DIV id=redSlider></DIV>
<DIV id=greenSlider></DIV>
<DIV id=blueSlider></DIV>
<DIV id=colorTable>
<TABLE border=0 cellPadding=0 cellSpacing=1>
  <TBODY>
  <TR>
    <TD align=middle colSpan=18 id=subtext>Standard 216 Color Palette</TD></TR>
  <SCRIPT>
<!--
clr = new Array('00','33','66','99','CC','FF');
for(k=0;k<6;++k){
for(j=0;j<6;){
document.write('<tr>\n');
for(m=0;m<3;++m){
for(i=0;i<6;++i){
document.write('<td bgcolor=#'+clr[k]+clr[j+m]+clr[i]+'>');
document.write('<a href="javascript:void(null)" ');
document.write('onClick="convertHex(\''+clr[k]+clr[j+m]+clr[i]+'\')\;">');
document.write('<img src=blankgif width=10 height=10 border=0></a></td>\n');
}
}
j+=3;
document.write('</tr>\n');
}
}
//-->
</SCRIPT>
  </TBODY></TABLE></DIV>
<DIV id=display><IMG border=0 height=50 src="相当不错的调色板.files/blank.gif"
width=50></DIV>
<DIV id=titleBar>
<TABLE border=0 cellPadding=2 cellSpacing=0 width=320>
  <TBODY>
  <TR>
    <TD id=title>Houser's RGB2HEX DHTML App</TD></TR></TBODY></TABLE></DIV>
<DIV id=hexValue>
<FORM name=frmValue>
<TABLE bgColor=#eeeeee border=0 cellPadding=2 cellSpacing=0 width=320>
  <TBODY>
  <TR>
    <TD align=middle>
      <TABLE border=0 cellPadding=2 cellSpacing=0>
        <TBODY>
        <TR>
          <TD id=subtext>Red</TD>
          <TD id=subtext>Green</TD>
          <TD id=subtext>Blue</TD></TR>
        <TR>
          <TD><INPUT maxLength=3 name=RgbDisp
            onblur="manualSet(this.value,'red');" size=3 value=0></TD>
          <TD><INPUT maxLength=3 name=rGbDisp
            onblur="manualSet(this.value,'green');" size=3 value=0></TD>
          <TD><INPUT maxLength=3 name=rgBDisp
            onblur="manualSet(this.value,'blue');" size=3
      value=0></TD></TR></TBODY></TABLE></TD>
    <TD align=middle>
      <TABLE border=0 cellPadding=2 cellSpacing=0>
        <TBODY>
        <TR>
          <TD id=subtext>Hexdecimal</TD></TR>
        <TR>
          <TD><INPUT maxLength=6 name=valueDisp onblur=convertHex(); size=6
            value=000000></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></FORM></DIV></BODY></HTML>[/html]
页: [1]
查看完整版本: [收集]缤纷选色代码集合。。