ortic/color-converter

color converter

v0.1 2017-05-09 10:50 UTC

This package is not auto-updated.

Last update: 2024-12-11 16:14:41 UTC


README

Build Status Code Rating Coverage Status

Helps you to convert between the various ways to define a color in CSS.

Examples

Assuming you've got a string resembling a color, just call the fromString method to get a color object back.

$color = Color::fromString('#ff0000');

The hex representation is not the only support schema:

$color = Color::fromString('red');
$color = Color::fromString('rgb(255, 0, 0)');
$color = Color::fromString('hsl(0, 100%, 50%)');

Once you have a color object you can get a HEX representation like this:

echo $color->toHex();