Core Function GetRValue
From Sputnik Wiki
GetRValue( <colour> )
Contents |
Description
Get the red byte from a colour INT value.
Parameters
colour
The colour INT value to use.
Return Value
The red byte.
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); }