note 48375 added to function.hexdec

From: Date: Tue, 21 Dec 2004 10:23:32 +0000
Subject: note 48375 added to function.hexdec
Groups: php.notes 
Request: Send a blank email to php-notes+get-82119@lists.php.net to get a copy of this message
A function to change the tint to the color you specify by wichever ammount you specify. <?php $color = "#09112A"; $tint_red = 125; $tint_green = 100; $tint_blue = -100; colortint($color,$tint_red,$tint_green,$tint_blue); function colortint($c,$tr,$tg,$tb) { if (eregi("#",$c)) { $c = str_replace('#','',$c); $p = 1; } $r = hexdec(substr($c,0,2))+$tr; $g = hexdec(substr($c,2,2))+$tg; $b = hexdec(substr($c,4,2))+$tb; if ($r > 255) $r = 255; elseif ($r < 0) $r = 0; if ($g > 255) $g = 255; elseif ($g < 0) $g = 0; if ($b > 255) $b = 255; elseif ($b < 0) $b = 0; $r = dechex($r); $g = dechex($g); $b = dechex($b); if (strlen($r) == 1) $r = "0".$r; if (strlen($g) == 1) $g = "0".$g; if (strlen($b) == 1) $b = "0".$b; $c = $r.$g.$b; if ($p == 1) $c = "#".$c; return $c; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.hexdec.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48375 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48375&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48375&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48375&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48375&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48375&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48375&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48375&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#82119) next »