Reply to Re: color tints

Your name:

Reply:


Posted by Philip Ronan on 11/02/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/

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация