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!! Link to comment https://forums.phpfreaks.com/topic/181455-how-can-i-modify-a-hex-color-code-using-a-range-of-0-to-100-where-0white/ 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. Link to comment https://forums.phpfreaks.com/topic/181455-how-can-i-modify-a-hex-color-code-using-a-range-of-0-to-100-where-0white/#findComment-957192 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.