https://github.com/maymeow/php-color
🌈 Color conversion from RGB to HEX and back.
https://github.com/maymeow/php-color
color hex php php-library rgb
Last synced: about 1 year ago
JSON representation
🌈 Color conversion from RGB to HEX and back.
- Host: GitHub
- URL: https://github.com/maymeow/php-color
- Owner: MayMeow
- License: mit
- Created: 2020-01-11T08:03:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-11T12:03:37.000Z (over 6 years ago)
- Last Synced: 2025-02-02T04:24:25.272Z (over 1 year ago)
- Topics: color, hex, php, php-library, rgb
- Language: PHP
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Color
🌈 Color conversion from RGB to HEX and back.
## Instalation
Trough composer:
```
composer require maymeow/php-color
```
## Using
Convert color to hex
```php
use MayMeow\PHPColor\Color;
// ...
$color = new Color(198, 255, 32);
$hex = Color::convertToHex($color); //#c6ff20
```
and back to RGB
```php
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