1. Go to this page and download the library: Download avadim/ace-colors 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/ */
avadim / ace-colors example snippets
use avadim\AceColors\AceColors;
// black
$color = new AceColors();
// red, in three equivalent notations
$color = new AceColors('ff0000');
$color = new AceColors('f00');
$color = new AceColors('#ff0000');
// ...and from the other formats
$color = new AceColors('rgba(255, 0, 0, 0.5)');
$color = new AceColors('hsl(0, 100%, 50%)');
$color = new AceColors(['r' => 255, 'g' => 0, 'b' => 0]);
// darken the color and print the hex code
echo (new AceColors('#3388cc'))->darken()->getHex(); // #296da3
// setters are chainable and modify the color in place
echo (new AceColors())
->setRed(51)
->setGreen(136)
->setBlue(204)
->setAlpha(0.8)
->getHexa(); // 3388cccc
// static converters need no instance
print_r(AceColors::hexToRgb('#3388cc')); // ['r' => 51, 'g' => 136, 'b' => 204]
echo AceColors::hslToHex(['h' => 210, 's' => 0.5, 'l' => 0.4]); // 336699
$color = new AceColors('#3388cc');
echo $color->red; // 51
echo $color->r; // the same
echo $color->luma; // 0.2267...
$color->green = 0;
$color->h = 120;
AceColors::setKeyCase(CASE_UPPER);
print_r(AceColors::hexToHsl('#6B513E')); // ['H' => ..., 'S' => ..., 'L' => ...]
AceColors::setKeyCase(CASE_LOWER); // back to the default
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.