ShowTable of Contents
NotesColorObject
This button builds a table in HTML that contains one line for each Domino color, and assigns the text to a scoped variable bound to a rich text control. The line identifies the Domino color code, the RGB values, and the HSL values. The line displays in the color being represented so some lines are not visible depending on the background color of the table.
var color = session.createColorObject();
var text = '<table style="text-align:center;background-color:silver">';
// Generate header row
text = text + '<tr style="font-weight:bold">';
text = text + "<td>Notes</td>";
text = text + "<td>Red</td>";
text = text + "<td>Green</td>";
text = text + "<td>Blue</td>";
text = text + "<td>Hue</td>";
text = text + "<td>Saturation</td>";
text = text + "<td>Luminance</td>";
text = text + "</tr>";
for (var i=0; i<=240; i++) { // for each Notes color
color.setNotesColor(i);
// Get RGB, HSL, and generate hex values for RGB
var red = color.getRed();
var green = color.getGreen();
var blue = color.getBlue();
var hue = color.getHue();
var saturation = color.getSaturation();
var luminance = color.getLuminance();
var redx = red.toString(16).toUpper().lpad("0", 2);
var greenx = green.toString(16).toUpper().lpad("0", 2);
var bluex = blue.toString(16).toUpper().lpad("0", 2);
// Generate row for color
text = text + '<tr style="font-weight:bold;color:#' + redx + greenx + bluex + '">';
text = text + "<td>" + i + "</td>";
text = text + "<td>" + red + "</td>";
text = text + "<td>" + green + "</td>";
text = text + "<td>" + blue + "</td>";
text = text + "<td>" + hue + "</td>";
text = text + "<td>" + saturation + "</td>";
text = text + "<td>" + luminance + "</td>";
text = text + "</tr>"
}
text = text + "</table>";
requestScope.colortable = text
setNotesColor, getRed, getGreen, getBlue, getHue, getSaturation, getLuminance
This button gets a Domino color code from a scoped variable bound to an input box control. It assigns to scoped variables bound to other input box controls the RGB and HSL values of the color.
var color = session.createColorObject();
try {
if (isNaN(requestScope.notescolor)) throw ("NotesColor value must be numeric");
var notescolor = parseInt(requestScope.notescolor, 10);
if (notescolor < 0 || notescolor > 240) throw ("NotesColor value must be 0 - 240");
color.setNotesColor(notescolor);
requestScope.red = color.getRed().toFixed();
requestScope.green = color.getGreen().toFixed();
requestScope.blue = color.getBlue().toFixed();
requestScope.hue = color.getHue().toFixed();
requestScope.saturation = color.getSaturation().toFixed();
requestScope.luminance = color.getLuminance().toFixed();
requestScope.status = "Success";
} catch(e) {
requestScope.status = e.toString();
}
setRGB, getNotesColor
This button control sets a color according to red, green, and blue values from scoped variables bound to input box controls. It assigns the Domino, RGB, and HSL values of the color to scoped variables bound to input box controls.
var color = session.createColorObject();
try {
if (isNaN(requestScope.red)) throw ("Red value must be numeric");
if (isNaN(requestScope.green)) throw ("Green value must be numeric");
if (isNaN(requestScope.blue)) throw ("Blue value must be numeric");
var red = parseInt(requestScope.red, 10);
var green = parseInt(requestScope.green, 10);
var blue = parseInt(requestScope.blue, 10);
if (red < 0 || red > 255) throw ("Red value must be 0 - 255");
if (green < 0 || green > 255) throw ("Green value must be 0 - 255");
if (blue < 0 || blue > 255) throw ("Blue value must be 0 - 255");
color.setRGB(red, green, blue);
requestScope.notescolor = color.getNotesColor().toFixed();
requestScope.red = color.getRed().toFixed();
requestScope.green = color.getGreen().toFixed();
requestScope.blue = color.getBlue().toFixed();
requestScope.hue = color.getHue().toFixed();
requestScope.saturation = color.getSaturation().toFixed();
requestScope.luminance = color.getLuminance().toFixed();
requestScope.status = "Success";
} catch(e) {
requestScope.status = e.toString();
}
setHSL
This button control sets a color according to the hue, saturation, and luminance values from scoped variables bound to input box controls. It assigns the Domino, RGB, and HSL values of the color to scoped variables bound to input box controls.
var color = session.createColorObject();
try {
if (isNaN(requestScope.hue)) throw ("Hue value must be numeric");
if (isNaN(requestScope.saturation)) throw ("Saturation value must be numeric");
if (isNaN(requestScope.luminance)) throw ("Luminance value must be numeric");
var hue = parseInt(requestScope.hue, 10);
var saturation = parseInt(requestScope.saturation, 10);
var luminance = parseInt(requestScope.luminance, 10);
if (hue < 0 || hue > 240) throw ("Hue value must be 0 - 240");
if (saturation < 0 || saturation > 240) throw ("Saturation value must be 0 - 240");
if (luminance < 0 || luminance > 240) throw ("Luminance value must be 0 - 240");
color.setHSL(hue, saturation, luminance);
requestScope.notescolor = color.getNotesColor().toFixed();
requestScope.red = color.getRed().toFixed();
requestScope.green = color.getGreen().toFixed();
requestScope.blue = color.getBlue().toFixed();
requestScope.hue = color.getHue().toFixed();
requestScope.saturation = color.getSaturation().toFixed();
requestScope.luminance = color.getLuminance().toFixed();
requestScope.status = "Success";
} catch(e) {
requestScope.status = e.toString();
}