This function will "parse" the color and split it into its Red, Green, and Blue parts - I presume you wanted each separate, right? Note, this works for both hex and decimal numbers (uses bit-wise math).
If the color is in RGB form, use SplitRGBColor. If the color is in BGR form, use SplitBGRColor.
Code:
;form 0xRRGGBB
color := 0x010203
SplitRGBColor(color, Red, Green, Blue)
MsgBox, % "RGB " Color " split is:`n"
. "Red: " Red . "`n"
. "Green: " Green . "`n"
. "Blue: " Blue . "`n"
;form 0xBBGGRR
color := 0x010203
SplitBGRColor(color, Red, Green, Blue)
MsgBox, % "BGR " Color " split is:`n"
. "Red: " Red . "`n"
. "Green: " Green . "`n"
. "Blue: " Blue . "`n"
;color MUST be in RGB form
;this function splits the color into its Red, Green, and Blue parts
SplitRGBColor(RGBColor, ByRef Red, ByRef Green, ByRef Blue)
{
Red := RGBColor >> 16 & 0xFF
Green := RGBColor >> 8 & 0xFF
Blue := RGBColor & 0xFF
}
;color MUST be in BGR form
;this function splits the color into its Red, Green, and Blue parts
SplitBGRColor(BGRColor, ByRef Red, ByRef Green, ByRef Blue)
{
Red := BGRColor & 0xFF
Green := BGRColor >> 8 & 0xFF
Blue := BGRColor >> 16 & 0xFF
}
_________________
As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the
Class Library. Check out
my scripts.