Core Function RGB
From Sputnik Wiki
RGB( <red>, <green>, <blue> )
Contents |
Description
Get the colour INT value of given red, green and blue bytes.
Parameters
red
A red value to use.
green
A green value to use.
blue
A blue value to use.
Return Value
The colour as a numeric value 0x R G B.
Remarks
Example
$RGB = RGB(0x11, 0x22, 0x33); println("Decimal '$RGB' Hex '" . Hex($RGB) . "'"); $Red = GetRValue($RGB); Println("Red: Decimal '$Red' Hex '" . Hex($Red) . "'"); $Green = GetGValue($RGB); Println("Green: Decimal '$Green' Hex '" . Hex($Green) . "'"); $Blue = GetBValue($RGB); Println("Green: Decimal '$Blue' Hex '" . Hex($Blue) . "'");
This next example using Sputnik only code to generate the R G B value and extract the R G B from it
$RGB = _RGB(0x11, 0x22, 0x33); println("Decimal '$RGB' Hex '" . Hex($RGB) . "'"); $Red = _GetRValue($RGB); Println("Red: Decimal '$Red' Hex '" . Hex($Red) . "'"); $Green = _GetGValue($RGB); Println("Green: Decimal '$Green' Hex '" . Hex($Green) . "'"); $Blue = _GetBValue($RGB); Println("Green: Decimal '$Blue' Hex '" . Hex($Blue) . "'"); Function _RGB($r, $g, $b) { return ((int)((($b) | ((short)(($g)) << 8)) | (((int)($r)) << 16))); } Function _GetRValue($rgb) { return (byte)(($rgb) >> 16); } Function _GetGValue($rgb) { return (short)$rgb >> 8; } Function _GetBValue($rgb) { return (byte)($rgb); }