colour lib

Andrea Fontana via Digitalmars-d digitalmars-d at puremagic.com
Wed Aug 31 01:04:04 PDT 2016


On Wednesday, 31 August 2016 at 07:58:36 UTC, Andrea Fontana 
wrote:

> I always think the perfect colour library should work using a 
> superset of all colour spaces, for example cie xyz (is it a 
> superset, isn't it?). isColour(T) then IMO should check if 
> x,y,z properties exists (or toXYZ() method).
>
> In this way every algorithm like "blend" or anything else could 
> be implemented just for xyz (and eventually specialized for 
> other colours if we want to avoid conversion overhead). In this 
> way it become easy to do cross-colour operations (for example: 
> apply a rgb mask over another color space) and to implement new 
> or strange color spaces (that automagically will work with all 
> "blend" & co.). To implement a new color spaces you just need 
> to map it to xyz (that should represent all - and more - 
> visible colours: rgb is a subset of visibile colours)
>
> Andrea

I forgot that in this way it's quite easy to wrap external 
class/struct to make them works with library. If we have a custom 
COLOR class provided by another library we just need to write a 
toXYZ(COLOR c) method (if it doesnt provide x,y,z properties) and 
it works.



More information about the Digitalmars-d mailing list