|
|
|
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 | | | PHP-CSL PHP Code Snippet Library, A very handy application designed to save you many hours by storing all your code snippets, classes and functions. Categories : PHP, Utilities, MySQL, Databases, To PHP | | | Popup window creator for images on the Fly. Categories : PHP, GD image library, Java Script | | | phpMyAdmin is intended to handle the adminstration of MySQL
over the web. Categories : Databases, MySQL, Complete Programs, PHP | | | Simple database class Categories : PHP, PHP Classes, MySQL, Databases | | | Persistent connections - General information. Categories : General SQL, PHP, Databases | | | ECHO-PHP Class Real Time Transaction Processor v1.4.4 for Credit Cards and
Checks / ACH Categories : PHP Classes, Cybercash, Classes and Objects, Ecommerce, PHP | | | Getting newsgroup with PHP Categories : PHP, IMAP | | | Alert in JavaScript and Trace in Flash Action script are two commands that I find very much useful for tracking and debugging errors in my scripts. Unfortunately, there is no such option in PHP. Categories : PHP, Java Script, Debugging | | | a smart list board on index for use for communication Categories : MS SQL Server, PHP | | | AJAX Application Categories : PHP, AJAX, Databases, MySQL | | | Link Manager for Link Exchangers Categories : PHP, PHP Classes, Databases, MySQL, CURL | | | PHP interface class to the eBusiness Charts generatation remote service. Categories : PHP, PHP Classes, Graphics, Charts and Graphs | | | I need a trim function/regexp that will trim all " " from the ends of a string. Categories : Regexps, PHP, Strings | |
|
|