1. Go to this page and download the library: Download savvywombat/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/ */
$newHsl = $hsl->red(50); // set to specific value
$newHsl = $hsl->red('+50'); // add 50 to the current value
$newHsl = $hsl->red('-50'); // remove 50 from the current value
$newHsl = $hsl->red('+50%'); // increase the current value by 50%
$newHsl = $hsl->red('-50%'); // decrease the current value by 50%
$newHsl = $hsl->red('+1/2'); // set to a value halfway between the current value and 255 (maximum red value)
$newHsl = $hsl->red('-1/2'); // set to a value halfway between the current value and 0 (minimum red value)
public static function fromString(string $colorSpec): ColorInterface;
public function __toString(): string;
public static function fromRGB(Rgb $rgb): ColorInterface;
public function toRGB(): Rgb;
/**
* color spec pattern: 'gray\((\d{1,3}(\.\d{1})?)%\)'
* color spec pattern: 'gray\((\d{1,3}(\.\d{1})?)%,([0-1](\.\d{1,2})?)\)'
*
* If the color spec matches either of the patterns, extractChannels will return the parameters from the string using regex.
*/
public static function fromString(string $colorSpec): ColorInterface
{
$channels = Color::extractChannels($colorSpec, self::class);
if (!isset($channels[3])) {
$channels[3] = 1.0;
}
return new Gray((float) $channels[1], $channels[3]);
}