SharkBait Posted November 14, 2006 Share Posted November 14, 2006 Ok, I am trying to figure this out, if I enter the HEX color of 336699 that would break down to:Red: 51Green: 102Blue: 153Correct?I would need to split the hex value into 3 values and then convert those to their decimal values right?Would I go about splitting them up every 2 characters, and then convert hex -> dec on those 3 seperate values?Or is there a better way to do this?Thanks. Quote Link to comment Share on other sites More sharing options...
Barand Posted November 14, 2006 Share Posted November 14, 2006 [code]<?php$color = 0x336699;$r = ($color >> 16) & 0xFF;$g = ($color >> 8) & 0xFF;$b = $color & 0xFF;?>[/code] Quote Link to comment Share on other sites More sharing options...
SharkBait Posted November 14, 2006 Author Share Posted November 14, 2006 Can ya explain what the >> does with the hex values? Quote Link to comment Share on other sites More sharing options...
Barand Posted November 14, 2006 Share Posted November 14, 2006 seehttp://www.phpfreaks.com/forums/index.php/topic,113143.msg459615.html#msg459615 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.