Consolidate color spaces to a single class
sebastiandedeyne opened this issue · comments
Sebastian De Deyne commented
Brain dump incoming
Consolidate all color spaces in a single color class that holds the color information.
rgb
, rgba
and hex
all use the same color space. hls
uses a different one so would need to be stored differently or we'd lose data.
API sketch:
Color::fromString('rgb(255, 0, 255)');
// Formats return diffrent objects depending on the format
$color->rgb()->__toString();
$color->rgb()->red();
$color->hex()->red();
// $color->rgb()->toHls() should also be possible
// Changing color spaces requires an explicit conversion (different implementation of `Color`)
// For example, you can't get `red` from a `hls` color
$color->toHls()->hue();
Sebastian De Deyne commented
Closing for now. Might come back later.