std.experimental.color, request reviews

Manu via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 24 01:47:41 PDT 2015


On 24 June 2015 at 17:18, Tofu Ninja via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On Wednesday, 24 June 2015 at 04:47:35 UTC, Manu wrote:
>>
>> They work fine. Just cast between color structs with different component
>> orders:
>>
>> BGR8 a = Color.white;
>> RGB8 b = a; // <- did swizzle
>>
>> Is there a specific api you miss?
>>
>>
>> On 24 June 2015 at 05:34, Tofu Ninja via Digitalmars-d
>> <digitalmars-d at puremagic.com> wrote:
>>>
>>> On Tuesday, 23 June 2015 at 14:58:35 UTC, Manu wrote:
>>>>
>>>>
>>>> https://github.com/D-Programming-Language/phobos/pull/2845
>>>>
>>>> I'm getting quite happy with it.
>>>> I think it's a good and fairly minimal but useful starting point.
>>>>
>>>> It'd be great to get some reviews from here.
>>>
>>>
>>>
>>> Swizzels would be a nice addition.
>
>
> Ahh, I was thinking more about swizzling the color channels themselves, not
> just conversion to different color layouts.
> RGB8 a = RGB8(0,1,2);
> RGB8 b = a.rbg;
> assert(b == RGB8(0,2,1));

Ah okay.
Yeah, it's an interesting idea. It's only applicable to RGB colours.
What's a bit awkward, is it's not entirely clear where the result of
the swizzle is assigned? Is the result of the swizzle assigned to the
colours present in the order of appearance in the current layout?
BGR8 a = Color.white;
BGR8 b = a.rbg;

is that: b=r, g=b, r=g, or is it r=r, g=b, b=g? Surely it's the
former, but that means you need to be conscious of the colour layout
whenever you perform a swizzle; ie, it will do different things for
different layouts...


More information about the Digitalmars-d mailing list