Skip to content

ortic/color-converter

Repository files navigation

color-converter

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();

About

PHP library to convert between CSS color types

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages