physaux Posted November 14, 2009 Share Posted November 14, 2009 How can I change a hex color code by a percent? Ex= [008E00-->ffffff] is proportional to [100-->0]? What I mean is like, imagine the following line (or color gradient): ffffff____________________008E00 Where white is at far left, and a shade of green is on far right. Now Imagine another line, right under that line: 0______________________100 I want a way of generating a hex color code, based on a number between 0 and 100. 0 would be WHITE 100 would be MY GREEN My theory is to just focus on the green component of the hex, 8E, then construct a hex code of that, by surrounding ti with two zeros on each side. So I guess my question comes down to how do I get a percentage of a hex number (I don't know much about hex numbers)... Thanks!! Quote Link to comment Share on other sites More sharing options...
physaux Posted November 14, 2009 Author Share Posted November 14, 2009 Actually I just found this: could I just use hexdec() to put it to a decimal, then get a ratio using my percent, then put it back with dechex()? That is my plan now, unless anyone has some suggestions. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.