|
Posted by Philip Ronan on 09/25/01 11:32
"Geradeaus" wrote:
> I'm searching for a script which calculates the tint for a color-code (e.g.
> 10% tint for the color #cc3366 is #f9eaef , similar to the following script
> : http://www.splintered.co.uk/experiments/43/
>
> I can nowhere find a source-code to do this...
>
> Anybody an idea? Thanks!
<?php
$color = "#cc3366";
$tint = 0.10; // =10%
echo get_tint($color, $tint); // "#faebf0"
function get_tint($c,$t)
{
$r = hexdec(substr($c,1,2));
$g = hexdec(substr($c,3,2));
$b = hexdec(substr($c,5,2));
$rt = "0" . dechex(round($t * $r + (1-$t) * 255));
$gt = "0" . dechex(round($t * $g + (1-$t) * 255));
$bt = "0" . dechex(round($t * $b + (1-$t) * 255));
$tint = "#" . substr($rt,-2) . substr($gt,-2) . substr($bt,-2);
return $tint;
}
?>
--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Navigation:
[Reply to this message]
|