NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Colors darker than

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 08-31-2006, 04:53 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
Tree's Avatar
Join Date: Feb 2006
Location: Atlanta, GA, USA
Posts: 335
Tree will become famous soon enoughTree will become famous soon enough
 



Colors darker than


Is there a way in PHP to randomly select all colors darker than, say, #696969?

I have a randomColor function already:

PHP Code:
function randomColor()
{
    return 
str_pad(dechex(mt_rand(016777215)), 6'0'STR_PAD_LEFT);

I just don't know where #696969 stops in base 10.
????: NamePros.com http://www.namepros.com/programming/233606-colors-darker-than.html

Tree is offline  
Old 08-31-2006, 09:51 PM   #2 (permalink)
Eating Pie
 
iNod's Avatar
Join Date: Nov 2004
Location: Canada
Posts: 2,267
iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of
 


Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
Something like this maybe?

PHP Code:
function darker_color($color$dif=20){
$color str_replace('#'''$color);
if (
strlen($color) != 6){ return '000000'; }
$rgb '';
for (
$x=0;$x<3;$x++){
$c hexdec(substr($color,(2*$x),2)) - $dif;
????: NamePros.com http://www.namepros.com/showthread.php?t=233606
$c = ($c 0) ? dechex($c);
$rgb .= (strlen($c) < 2) ? '0'.$c $c;
}
return 
'#'.$rgb;

Than use something like
PHP Code:
for ($x=1$x 20$x++){
// Start color:
$c darker_color('#FF481D', ($x*3));
????: NamePros.com http://www.namepros.com/showthread.php?t=233606

print 
"<div style='background-color: $c; color: $c; font-size: 50%; padding: 0px;'>.</div>\n";

To print it.. Where as the number of required darker amounts is 20..

Or what ever you need..

- Steve
__________________
I feel old.
Last edited by iNod; 08-31-2006 at 09:56 PM.
iNod is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 02:16 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger