1. Go to this page and download the library: Download konradmichalik/php-color library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
konradmichalik / php-color example snippets
use KonradMichalik\Color\Color;
$color = Color::fromHex('#3366cc');
$color->toRgb(); // Rgb(51, 102, 204)
$color->toHsl(); // Hsl(220.0, 60.0, 50.0)
$color->toHex(); // "#3366cc"
Color::fromRgb(51, 102, 204)->toHex(); // "#3366cc"
Color::fromHsl(220, 60, 50)->toHex(); // "#3366cc"
$color->withLightness(85)->toHex(); // a lighter variant (HSL space)
$color->scaleRgb(0.5)->toHex(); // halve each RGB channel → "#1a3366"
$color->darken(0.5)->toHex(); // alias for scaleRgb()
use KonradMichalik\Color\ColorHasher;
ColorHasher::crc32()->hash($string)->scaleRgb(0.5)->toHex(); // darkened avatar color
Color::fromString('#ff0000'); // red
Color::fromString('f00'); // red
Color::fromString('rgb(255, 0, 0)'); // red
Color::fromString('hsl(0, 100%, 50%)'); // red
Color::fromString('HSL(0,100,50)'); // red