setRGB (NotesColorObject - JavaScript™)
Sets an RGB value to the closest Domino® color and HSL value.
Defined in
NotesColorObjectSyntax
setRGB(red:int, green:int,
blue:int) : int
Parameter | Description |
---|---|
int red |
Red component of the RGB value. Must be in the range 0-255. |
int green |
Green component of the RGB value. Must be in the range 0-255. |
int blue |
Blue component of the RGB value. Must be in the range 0-255. |
Return value | Description |
---|---|
int |
Closest Domino® color to the RGB value. |
Usage
SetRGB sets NotesColor, in addition to the return value, to the closest Domino® color.SetRGB sets the RGB properties to the specifications of this method.
SetRGB sets the HSL properties to values that match the Domino® color.
Language cross-reference
SetRGB method in LotusScript® NotesColorObject classsetRGB method in Java™ ColorObject class
Examples
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();
}