1. Go to this page and download the library: Download mexitek/phpcolors 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/ */
mexitek / phpcolors example snippets
/**
* Using The Class
*/
use Mexitek\PHPColors\Color;
// Initialize my color
$myBlue = new Color("#336699");
echo $myBlue->darken();
// 1a334d
echo $myBlue->lighten();
// 8cb3d9
echo $myBlue->isLight();
// false
echo $myBlue->isDark();
// true
echo $myBlue->complementary();
// 996633
echo $myBlue->getHex();
// 336699
print_r( $myBlue->getHsl() );
// array( "H"=> 210, "S"=> 0.5, "L"=>0.4 );
print_r( $myBlue->getRgb() );
// array( "R"=> 51, "G"=> 102, "B"=>153 );
print_r($myBlue->makeGradient());
// array( "light"=>"8cb3d9" ,"dark"=>"336699" )
/**
* On The Fly Custom Calculations
*/
use Mexitek\PHPColors\Color;
// Convert my HEX
$myBlue = Color::hexToHsl("#336699");
// Get crazy with the HUE
$myBlue["H"] = 295;
// Gimme my new color!!
echo Color::hslToHex($myBlue);
// 913399
use Mexitek\PHPColors\Color;
// Initialize my color
$myBlue = new Color("#336699");
// Get CSS
echo $myBlue->getCssGradient();
/* - Actual output doesn't have comments and is single line
// fallback background
background: #336699;
// IE Browsers
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#8cb3d9', endColorstr='#336699');
// Safari 5.1+, Mobile Safari, Chrome 10+
background-image: -webkit-linear-gradient(top, #8cb3d9, #336699);
// Standards
background-image: linear-gradient(to bottom, #8cb3d9, #336699);
*/
use Mexitek\PHPColors\Color;
$myBlue = new Color("#336699");
// Get CSS
echo $myBlue->getCssGradient(10, TRUE);
/* - Actual output doesn't have comments and is single line
background: #336699; // fallback background
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#8cb3d9', endColorstr='#336699'); // IE Browsers
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#8cb3d9), to(#336699)); // Safari 4+, Chrome 1-9
background-image: -webkit-linear-gradient(top, #8cb3d9, #336699); // Safari 5.1+, Mobile Safari, Chrome 10+
background-image: -moz-linear-gradient(top, #8cb3d9, #336699); // Firefox 3.6+
background-image: -o-linear-gradient(top, #8cb3d9, #336699); // Opera 11.10+
background-image: linear-gradient(to bottom, #8cb3d9, #336699); // Standards
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.