|
|
Create a lighter shade of a hex color:
<?
function hexLighter($hex,$factor = 30)
{
$new_hex = '';
$base['R'] = hexdec($hex{0}.$hex{1});
$base['G'] = hexdec($hex{2}.$hex{3});
$base['B'] = hexdec($hex{4}.$hex{5});
foreach ($base as $k => $v)
{
$amount = 255 - $v;
$amount = $amount / 100;
$amount = round($amount * $factor);
$new_decimal = $v + $amount;
$new_hex_component = dechex($new_decimal);
if(strlen($new_hex_component) < 2)
{ $new_hex_component = "0".$new_hex_component; }
$new_hex .= $new_hex_component;
}
return $new_hex;
}
?>
Example, making a new colour 50% lighter than the first:
<?
$myCol = "FFCC99";
$newCol = hexLighter($myCol, 50);
?> |
|
| Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | Color - making a hex color darker Categories : PHP, Colors | | | XPath for PHP without the DOM XML extension Categories : DOM XML, XML, XSLT, PHP Classes, PHP | | | Creating a Language File Categories : PHP, Beginner Guides, Filesystem | | | PHP Image Compression using GD library Categories : PHP, Compression, GD image library, Graphics | | | How to display a PHP variable value from a selectbox without reloading the
page by merging PHP and Javascript variables. Categories : PHP, Java Script, Variables | | | Function that returns an array with the 7 dates of the week that belong to the supplied date. Categories : PHP, Date Time, Arrays | | | session out Timer Categories : PHP, Sessions, Security, Beginner Guides | | | Variable serialization and unserialization. Loading and saving variable structures
to and from file. Categories : Arrays, Filesystem, Variables, Strings, PHP | | | How to get the name of the user which is accessing
the current script. Categories : Environment Variables, PHP | | | Problem with Database Connectivity in PHP and MS Access? Don't
worry, The easy way is...... Categories : ADO, PHP, Databases | | | Convert SQL from oracle,mysql,mssql,sqlite and odbc to SQL compatible Categories : PHP, PHP Classes, Databases, MySQL, MS SQL Server | | | Human readable PHP password generator Categories : PHP, Security, Beginner Guides, Arrays | | | TABLE LIST, DATABASE LIST, PHP , PostgreSQL, ADMIN, Web Interface,
database admin Categories : PHP, PostgreSQL | | | STR - a Perl-like string manipulator class - The str class provides 4 perl-like methods for manipulating strings and
other scalar variables. Categories : PHP, PHP Classes, Perl, Strings | |
| |
| |
|