Skip to content

MayMeow/php-color

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PHP Color

๐ŸŒˆ Color conversion from RGB to HEX and back.

Instalation

Trough composer:

composer require maymeow/php-color

Using

Convert color to hex

use MayMeow\PHPColor\Color;
// ...
$color = new Color(198, 255, 32);
$hex = Color::convertToHex($color); //#c6ff20

and back to RGB

use MayMeow\PHPColor\Color;
// ...
try {
    $rgb = Color::convertToRGB($hex); // color object: Color(198, 255, 32)
} catch (\MayMeow\PHPColor\Exceptions\NotHexException $exception)
{
    // do something, echo message or log ...
}

You can check example.php file in project sources.

License

MIT

About

๐ŸŒˆ Color conversion from RGB to HEX and back.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages