1. Go to this page and download the library: Download abivia/colorspace 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/ */
abivia / colorspace example snippets
use Abivia\ColorSpace\Color;
use Abivia\ColorSpace\Hsl;
use Abivia\ColorSpace\Rgb;
// Legacy syntax. Returns an instance of Hsl.
$colorHsl = Color::fromCss('hsl(50%, 10%, 25%)');
// Modern syntax. Returns an instance of RGB
$colorRgb = Color::fromCss('rgba(50% 10% 25% / 0.5)');
// Convert RGB to HSL
$converted = new Hsl($colorRgb);
// Modern syntax
echo $converted->toCss(); // output: hsla(239 80% 50% / 0.5)
// Legacy Syntax
echo $converted->toCss(true); // output: hsla(239,80%,50%,0.5)
// As hex (with no Alpha channel)
echo $converted->toCssHex(); // output: #7f193f