note 58104 added to function.hexdec

From: Date: Mon, 24 Oct 2005 14:38:17 +0000
Subject: note 58104 added to function.hexdec
Groups: php.notes 
Request: Send a blank email to php-notes+get-97517@lists.php.net to get a copy of this message
This function will take a hex $color, e.g. fa34bc and make it the shade you want, e.g. anywhere between 0 and 255. The smaller the number, the darker the output color. It keeps the color the same, only changing the shade. function correctshade($color, $shade) { $r = hexdec(substr($color,0,2)); $g = hexdec(substr($color,2,2)); $b = hexdec(substr($color,4,2)); $sum = ($r + $g + $b); $x = (($shade * 3) - $sum) / $sum; if ($x >= 0) { $x = $x + 1; } else { $x = 1 + $x; } $r = intval($x * $r); $g = intval($x * $g); $b = intval($x * $b); $r = dechex($r); $g = dechex($g); $b = dechex($b); return $r.$g.$b; } ---- Manual Page -- http://www.php.net/manual/en/function.hexdec.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58104 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58104&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58104&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58104&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58104&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58104&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58104&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58104&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58104&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97517) next »