背景色調色盤

來源:互聯網
上載者:User
提示:您可以先修改部分代碼再運行

<p><html><br /><head><br /><title>調色盤</title><br /></head><br /><body><br /><script language="JavaScript"><br /><!--</p><p>// Copyright (c) 1996-1997 Tomer Shiran. All rights reserved.<br />// Permission given to use the script provided that this notice remains as is.<br />// Additional scripts can be found at [url]http://www.geocities.com/~yehuda/[/url]</p><p>// create 6-element array<br />var hex = new Array(6)</p><p>// assign non-dithered descriptors<br />hex[0] = "FF"<br />hex[1] = "CC"<br />hex[2] = "99"<br />hex[3] = "66"<br />hex[4] = "33"<br />hex[5] = "00"</p><p>// accept triplet string and display as background color<br />function display(triplet) {<br /> // set color as background color<br /> document.bgColor = '#' + triplet</p><p> // display the color hexadecimal triplet<br /> alert('現在的背景色是 #'+triplet)<br />}</p><p>// draw a single table cell based on all descriptors<br />function drawCell(red, green, blue) {<br /> // open cell with specified hexadecimal triplet background color<br /> document.write('<TD BGCOLOR="#' + red + green + blue + '">')</p><p> // open a hypertext link with javascript: scheme to call display function<br /> document.write('<A HREF="javascript:display(\'' + (red + green + blue) + '\')">')</p><p> // print transparent image (use any height and width)<br /> document.write('<IMG SRC="place.gif" BORDER=0 HEIGHT=12 WIDTH=12>')</p><p> // close link tag<br /> document.write('</A>')</p><p> // close table cell<br /> document.write('</TD>')<br />}</p><p>// draw table row based on red and blue descriptors<br />function drawRow(red, blue) {<br /> // open table row<br /> document.write('<TR>')</p><p> // loop through all non-dithered color descripters as green hex<br /> for (var i = 0; i < 6; ++i) {<br />  drawCell(red, hex[i], blue)<br /> }</p><p> // close current table row<br /> document.write('</TR>')<br />}</p><p>// draw table for one of six color cube panels<br />function drawTable(blue) {<br /> // open table (one of six cube panels)<br /> document.write('<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>')</p><p> // loop through all non-dithered color descripters as red hex<br /> for (var i = 0; i < 6; ++i) {<br />  drawRow(hex[i], blue)<br /> }</p><p> // close current table<br /> document.write('</TABLE>') <br />}</p><p>// draw all cube panels inside table cells<br />function drawCube() {<br /> // open table<br /> document.write('<TABLE CELLPADDING=5 CELLSPACING=0 BORDER=1><TR>')</p><p> // loop through all non-dithered color descripters as blue hex<br /> for (var i = 0; i < 6; ++i) {<br />  // open table cell with white background color<br />  document.write('<TD BGCOLOR="#FFFFFF">')</p><p>  // call function to create cube panel with hex[i] blue hex<br />  drawTable(hex[i])</p><p>  // close current table cell<br />  document.write('</TD>')<br /> }</p><p> // close table row and table<br /> document.write('</TR></TABLE>')<br />}</p><p>// call function to begin execution<br />drawCube()</p><p>// --><br /></script></p><p></body><br /></html></p>
提示:您可以先修改部分代碼再運行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.