1. Go to this page and download the library: Download webzille/colorutility 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/ */
webzille / colorutility example snippets
use Webzille\ColorUtility\Colors\RGB;
use Webzille\ColorUtility\Colors\RYB;
use Webzille\ColorUtility\Colors\LAB;
$rgbColor = new RGB(255, 0, 0); // Red in RGB
$rybColor = new RYB(255, 0, 0); // Red in RYB
$labColor = new LAB(53.23288178584245, 80.10930952982204, 67.22006831026425); // Red in LAB
$complementaryRGB = $rgbColor->complementary(); // Green
$weight = 0.5;
$blendedRYB = $rybColor->blendColors(new RYB(0, 0, 255), $weight); // Blend red and blue in RYB
$darkerColor = $rgbColor->adjustShade(50); // 50% of the current shade
$brighterColor = $rgbColor->adjustShade(150); // 50% brighter than it's current shade
$sameShade - $rgbColor->adjustShade(100); // No change; 100% of it's current shade
$isLight = $rgbColor->isLight(); // Returns true if the color is considered light
$angleBetween = $rybColor->calculateAngle(new RYB(0, 255, 0)); // Calculate angle between red and yellow in RYB
$triadicScheme = $rgbColor->triadic(); // Returns an array of RGB objects in a triadic scheme
$hexColor = $rgbColor->asHEX();
echo $hexColor; // Outputs HEX code for red
// Default websafe color to view is RGB
$hslColor = new HSL(195.51382638999, 100, 50);
echo $hslColor->asLAB()->findColorByAngle(180)->viewColor(); // rgb(228, 163, 97)
// Making sure we view the color in HSL format after using the color in LAB color space
$hslColor = new HSL(195.51382638999, 100, 50);
echo $hslColor->asLAB()->findColorByAngle(180)->backTo($hslColor)->viewColor(); // hsl(30.533318540464, 70.332302060189%, 63.65760628305%)
// Making sure we view the color in HSL format after using the color in LAB color space
$hslColor = new HSL(195.51382638999, 100, 50);
echo $hslColor->asLAB()->findColorByAngle(180)->asHSL()->viewColor(); // hsl(30.533318540464, 70.332302060189%, 63.65760628305%)
// Assuming $rgbColor, $rybColor, and $labColor are already defined as instances of their respective color classes
// RGB to other formats
$hexFromRGB = $rgbColor->asHEX();
$hslFromRGB = $rgbColor->asHSL();
$labFromRGB = $rgbColor->asLAB();
// RYB to RGB (and then to other formats)
$rgbFromRYB = $rybColor->asRGB();
$hexFromRYB = $rybColor->asHEX();
$hslFromRYB = $rybColor->asHSL();
// LAB to RGB and to HEX
$rgbFromLAB = $labColor->asRGB();
$hexFromLAB = $labColor->asHEX();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.