digitalmars.D.learn - Hex constant method starts from ".a": 0xCCCCCC.argb
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (35/35) Dec 13 2020 We have:
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (19/21) Dec 13 2020 But...:
- Paul Backus (5/9) Dec 13 2020 It's parsing the `.a` in `.argb` as part of the number:
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (3/15) Dec 13 2020 Thanks!
- Jacob Carlborg (6/15) Dec 14 2020 Or you can call it `rgba`. It seems to be what Wikipedia prefers
- Adam D. Ruppe (5/7) Dec 14 2020 The ordering here tends to reflect the bytes. So argb puts the
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (5/13) Dec 14 2020 I think about .rgba.
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (16/32) Dec 14 2020 0x00AABBCC.argb
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (22/58) Dec 14 2020 This concept:
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 ?
Dec 13 2020
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
Dec 13 2020
On Monday, 14 December 2020 at 05:27:40 UTC, Виталий Фадеев wrote:".rgb" Compiled fine. ".argb" Compilation error. Source: https://run.dlang.io/is/ULQ4khIt'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;
Dec 13 2020
On Monday, 14 December 2020 at 05:37:21 UTC, Paul Backus wrote:On Monday, 14 December 2020 at 05:27:40 UTC, Виталий Фадеев wrote:Thanks! It is not perfect, but also beauty!".rgb" Compiled fine. ".argb" Compilation error. Source: https://run.dlang.io/is/ULQ4khIt'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;
Dec 13 2020
On Monday, 14 December 2020 at 05:51:28 UTC, Виталий Фадеев wrote:Or you can call it `rgba`. It seems to be what Wikipedia prefers [1]. [1] https://en.wikipedia.org/wiki/RGBA_color_model -- /Jacob CarlborgIt'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!
Dec 14 2020
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.
Dec 14 2020
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:I think about .rgba. Yes. The ordering! The logic. ARGB = .argb Thanks!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.
Dec 14 2020
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: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!On Monday, 14 December 2020 at 16:11:16 UTC, Jacob Carlborg wrote:I think about .rgba. Yes. The ordering! The logic. ARGB = .argb Thanks!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.
Dec 14 2020
On Tuesday, 15 December 2020 at 05:10:27 UTC, Виталий Фадеев wrote:On Tuesday, 15 December 2020 at 05:04:46 UTC, Виталий Фадеев wrote: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! )On Monday, 14 December 2020 at 16:19:18 UTC, Adam D. Ruppe wrote: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!On Monday, 14 December 2020 at 16:11:16 UTC, Jacob Carlborg wrote:I think about .rgba. Yes. The ordering! The logic. ARGB = .argb Thanks!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.
Dec 14 2020