mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Added: HTML #RGBA color
This commit is contained in:
parent
07a1f2000a
commit
44abf90861
1 changed files with 31 additions and 0 deletions
|
@ -975,6 +975,37 @@ namespace NLGUI
|
|||
if (*src == '#')
|
||||
{
|
||||
++src;
|
||||
if (strlen(src) == 3 || strlen(src) == 4)
|
||||
{
|
||||
bool hasAlpha = (strlen(src) == 4);
|
||||
// check RGB for valid hex
|
||||
if (isHexa(src[0]) && isHexa(src[1]) && isHexa(src[2]))
|
||||
{
|
||||
// check optional A for valid hex
|
||||
if (hasAlpha && !isHexa(src[3])) return false;
|
||||
|
||||
dest.R = convertHexa(src[0]);
|
||||
dest.G = convertHexa(src[1]);
|
||||
dest.B = convertHexa(src[2]);
|
||||
|
||||
dest.R = dest.R << 4 | dest.R;
|
||||
dest.G = dest.G << 4 | dest.G;
|
||||
dest.B = dest.B << 4 | dest.B;
|
||||
|
||||
if (hasAlpha)
|
||||
{
|
||||
dest.A = convertHexa(src[3]);
|
||||
dest.A = dest.A << 4 | dest.A;
|
||||
}
|
||||
else
|
||||
dest.A = 255;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CRGBA result;
|
||||
src = scanColorComponent(src, result.R); if (!src) return false;
|
||||
src = scanColorComponent(src, result.G); if (!src) return false;
|
||||
|
|
Loading…
Reference in a new issue