調色盤(javascript)

來源:互聯網
上載者:User
Domino調色盤

紅綠藍灰
 
 


·可選16*16*16種顏色。
·單擊左邊的顏色會得到更多的顏色。
·單擊右邊的顏色會固定選取的顏色。
·輸入框可以自訂色彩。

--------------------------------------------------------------
<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>

<DIV align=center><B><FONT color=#003366>Domino調色盤</FONT></B><BR><BR></DIV>
<TABLE cellSpacing=1 cellPadding=3 width=350 align=center bgColor=#dddddd border=0>
<TBODY>
<TR bgColor=#ffffff>
<TD align=middle width="10%"><SELECT onchange=selectchg(this.value) name=select1> <OPTION value=1 selected>紅</OPTION> <OPTION value=2>綠</OPTION> <OPTION value=3>藍</OPTION> <OPTION value=4>灰</OPTION></SELECT> </TD>
<TD align=middle width="90%">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD align=right><INPUT class=memo size=10 name=text1> <INPUT class=button onclick=choosecolor() type=button value=">>" name=Button2> </TD>
<TD align=right width="3%">&nbsp;</TD>
<TD width="30%">
<TABLE class=cursorcross height=20 cellSpacing=1 cellPadding=0 width=40 border=0>
<TBODY>
<TR>
<TD id=customcolor onmouseover=showcolor(this) bgColor=#ffffff>&nbsp;</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR bgColor=#ffffff>
<TD align=middle width="10%">
<TABLE class=cursorhand id=tableleft cellSpacing=1 cellPadding=0 border=0>
<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>

<TBODY></TBODY></TABLE></TD>
<TD align=middle width="90%">
<TABLE class=cursorcross id=tableleft cellSpacing=1 cellPadding=0 border=0>
<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>

<TBODY></TBODY></TABLE></TD></TR>
<TR bgColor=#ffffff>
<TD colSpan=2 height=20>·可選16*16*16種顏色。<BR>·單擊左邊的顏色會得到更多的顏色。<BR>·單擊右邊的顏色會固定選取的顏色。 <BR>·輸入框可以自訂色彩。</TD></TR></TBODY></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>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.