Hex constant method starts from ".a": 0xCCCCCC.argb
Виталий Фадеев
vital.fadeev at gmail.com
Mon Dec 14 05:24:39 UTC 2020
We have:
static import winapi=core.sys.windows.windows;
struct Color
{
union
{
winapi.COLORREF native;
struct
{
ubyte r;
ubyte g;
ubyte b;
}
}
ubyte a = 0xFF;
}
Color argb( uint color )
{
Color c;
c.native =
cast( uint ) (
( ( color & 0x000000FF ) << 16 ) |
( ( color & 0x0000FF00 ) ) |
( ( color & 0x00FF0000 ) >> 16 )
);
c.a = ( color & 0xFF000000 ) >> 24;
return c;
}
Goal:
auto color = 0x00AABBCC.argb;
Has error:
Error: exponent required for hex float
( at 0x00AABBCC.argb )
What is it ?
How to implement beauty code like the: #CCCCCC.rgb ?
More information about the Digitalmars-d-learn
mailing list