Thread overview
December 14
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 ?

December 14
On Monday, 14 December 2020 at 05:24:39 UTC, Виталий Фадеев wrote:
>
> ... msg ...
> 

But...:
    Color rgb( uint color )
    {
        return
            Color( cast( uint ) (
                ( ( color & 0x000000FF ) << 16 )  |
                ( ( color & 0x0000FF00 ) )  |
                ( ( color & 0x00FF0000 ) >> 16 )
            ) );
    }

unittest
{
    auto color2 = 0x00AABBCC.rgb;
}

".rgb"  Compiled fine.
".argb" Compilation error.


Source:
    https://run.dlang.io/is/ULQ4kh


December 14
On Monday, 14 December 2020 at 05:27:40 UTC, Виталий Фадеев wrote:
> ".rgb"  Compiled fine.
> ".argb" Compilation error.
>
>
> Source:
>     https://run.dlang.io/is/ULQ4kh

It's parsing the `.a` in `.argb` as part of the number:

auto color = 0x00AABBCC.a rgb; // what the compiler sees

You can fix it with parentheses:

auto color = (0x00AABBCC).argb;
December 14
On Monday, 14 December 2020 at 05:37:21 UTC, Paul Backus wrote:
> On Monday, 14 December 2020 at 05:27:40 UTC, Виталий Фадеев wrote:
>> ".rgb"  Compiled fine.
>> ".argb" Compilation error.
>>
>>
>> Source:
>>     https://run.dlang.io/is/ULQ4kh
>
> It's parsing the `.a` in `.argb` as part of the number:
>
> auto color = 0x00AABBCC.a rgb; // what the compiler sees
>
> You can fix it with parentheses:
>
> auto color = (0x00AABBCC).argb;

Thanks!

It is not perfect, but also beauty!

December 14
On Monday, 14 December 2020 at 05:51:28 UTC, Виталий Фадеев wrote:

>> It's parsing the `.a` in `.argb` as part of the number:
>>
>> auto color = 0x00AABBCC.a rgb; // what the compiler sees
>>
>> You can fix it with parentheses:
>>
>> auto color = (0x00AABBCC).argb;
>
> Thanks!
>
> It is not perfect, but also beauty!

Or you can call it `rgba`. It seems to be what Wikipedia prefers [1].

[1] https://en.wikipedia.org/wiki/RGBA_color_model

--
/Jacob Carlborg
December 14
On Monday, 14 December 2020 at 16:11:16 UTC, Jacob Carlborg wrote:
> Or you can call it `rgba`. It seems to be what Wikipedia prefers [1].

The ordering here tends to reflect the bytes. So argb puts the alpha byte first in the array whereas rgba puts red first.

But there's other ways here including just saying argb(...) or foo.as!"argb" or whatever well.
December 15
On Monday, 14 December 2020 at 16:19:18 UTC, Adam D. Ruppe wrote:
> On Monday, 14 December 2020 at 16:11:16 UTC, Jacob Carlborg wrote:
>> Or you can call it `rgba`. It seems to be what Wikipedia prefers [1].
>
> The ordering here tends to reflect the bytes. So argb puts the alpha byte first in the array whereas rgba puts red first.
>
> But there's other ways here including just saying argb(...) or foo.as!"argb" or whatever well.

I think about .rgba.

Yes. The ordering! The logic.

ARGB = .argb

Thanks!

December 15
On Tuesday, 15 December 2020 at 05:04:46 UTC, Виталий Фадеев wrote:
> On Monday, 14 December 2020 at 16:19:18 UTC, Adam D. Ruppe wrote:
>> On Monday, 14 December 2020 at 16:11:16 UTC, Jacob Carlborg wrote:
>>> Or you can call it `rgba`. It seems to be what Wikipedia prefers [1].
>>
>> The ordering here tends to reflect the bytes. So argb puts the alpha byte first in the array whereas rgba puts red first.
>>
>> But there's other ways here including just saying argb(...) or foo.as!"argb" or whatever well.
>
> I think about .rgba.
>
> Yes. The ordering! The logic.
>
> ARGB = .argb
>
> Thanks!

0x00AABBCC.argb

0x00AABBCC - is ARGB value
.argb      - is unit

...in my logic.

120.px
120       - is Pixel value
.px       - is unit

...in my logic.

100.percent
100       - is Percent value
.percent  - is unit

...in my logic.
)

Thanks!

December 15
On Tuesday, 15 December 2020 at 05:10:27 UTC, Виталий Фадеев wrote:
> On Tuesday, 15 December 2020 at 05:04:46 UTC, Виталий Фадеев wrote:
>> On Monday, 14 December 2020 at 16:19:18 UTC, Adam D. Ruppe wrote:
>>> On Monday, 14 December 2020 at 16:11:16 UTC, Jacob Carlborg wrote:
>>>> Or you can call it `rgba`. It seems to be what Wikipedia prefers [1].
>>>
>>> The ordering here tends to reflect the bytes. So argb puts the alpha byte first in the array whereas rgba puts red first.
>>>
>>> But there's other ways here including just saying argb(...) or foo.as!"argb" or whatever well.
>>
>> I think about .rgba.
>>
>> Yes. The ordering! The logic.
>>
>> ARGB = .argb
>>
>> Thanks!
>
> 0x00AABBCC.argb
>
> 0x00AABBCC - is ARGB value
> .argb      - is unit
>
> ...in my logic.
>
> 120.px
> 120       - is Pixel value
> .px       - is unit
>
> ...in my logic.
>
> 100.percent
> 100       - is Percent value
> .percent  - is unit
>
> ...in my logic.
> )
>
> Thanks!

This concept:
class X
{
    this()
    {
        props.fontFace   = "Ubuntu Mono";
        props.fontSize   = 24.px;
        props.lineHeight = 15.px;
        props.color      = 0xFFFFFF;
        props.backColor  = 0x222222;
        // or
        props.color      = 0xFFFFFF.rgb;
        props.backColor  = 0x222222.rgb;
        // or
        props.color      = 0x88FFFFFF.argb;
        props.backColor  = 0x88222222.argb;
    }
}

Thanks!
)