// grColourPicker.js // Copyright (c) grelf.net, UK, 2011 // // Suitable HTML to invoke this: //
// Another piece of script must provide // function setColour (colour) // where colour is the usual HTML value of "#" + 6 hex digits. // Note that margins can be added to all colour cells with CSS because they have class="cpcell": // .cpcell { margin:2px; } ColourPicker.prototype.cellWd = 20; ColourPicker.prototype.cellHt = 16; function ColourPicker () { if (!!document.createElement ("canvas").getContext) { this.div = document.getElementById ("colourPicker"); this.html = ""; var steps = [ "00", "33", "66", "99", "CC"]; // 255 * 255 * 255 = 16581375 // /64 = 259083.98 /75 = 221085 for (row = 0; row < steps.length; row++) { this.addCell (steps [row] + steps [row] + steps [row]); // grey this.addCell ("FF" + steps [row] + steps [row]); // red this.addCell ("FF88" + steps [row]); // orange this.addCell ("FFFF" + steps [row]); // yellow this.addCell (steps [row] + "FF" + steps [row]); // green this.addCell (steps [row] + "88" + steps [row]); // dark green this.addCell (steps [row] + "FFFF"); // cyan this.addCell (steps [row] + steps [row] + "FF"); // blue this.addCell ("FF" + steps [row] + "FF"); // magenta this.html += '