how to determine the opposite of hex color values?

  • reaper
  • Proficient
  • Proficient
  • User avatar
  • Joined: Apr 05, 2005
  • Posts: 435
  • Loc: europe
  • Status: Offline

Post October 25th, 2005, 10:14 am

How can i determine the opposite value of a hex color code like EEEEEE ?

For EEFF99 it would be 99FFEE offcourse but how about the value from above?

And how can i easily view and compare a hex color to it's opposite?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 25th, 2005, 10:14 am

  • Axe
  • Genius
  • Genius
  • User avatar
  • Joined: Jan 07, 2004
  • Posts: 5744
  • Loc: Sub-level 28
  • Status: Offline

Post October 25th, 2005, 12:35 pm

Well, that wouldn't necessarily be the "opposite".

The opposite of #EEFF99 would be #110066 (#FFFFFF - #EEFF99).

What you're doing is reversing it.

With what you did to #EEFF99, using the same methodology, the opposite of #FFFFFF would be #FFFFFF (when it's actually #000000).

Of course, a colour (well, grey) like #808080 produces #808080 regardless of which method you used.

Reversed it's still #808080, and subtracted from #FFFFFF it's still #808080.

You could write a PHP script to work these out.

Simply remove the # from the beginning, then subtract the colour from FFFFFF.

Windows calculator (in hex mode, through scientific view) will allow you to do this too, if you want something you can just tap in manually.
  • reaper
  • Proficient
  • Proficient
  • User avatar
  • Joined: Apr 05, 2005
  • Posts: 435
  • Loc: europe
  • Status: Offline

Post October 25th, 2005, 1:14 pm

Quote:
Reversed it's still #808080, and subtracted from #FFFFFF it's still #808080.


Through windows calculator in scientific view my results was when i substracted 808080 from FFFFFF i got the result 7F7F7F :shock:

So what am i doing wrong here?


Quote:
The opposite of #EEFF99 would be #110066


May i ask how you got this result? did you use the windows calculator?
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post October 25th, 2005, 2:01 pm

You aren't doing anything wrong. The middle of the spectrum is actually 7FFFFF

Try subtracting that, and your result will be 7FFFFF
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • Axe
  • Genius
  • Genius
  • User avatar
  • Joined: Jan 07, 2004
  • Posts: 5744
  • Loc: Sub-level 28
  • Status: Offline

Post October 25th, 2005, 2:29 pm

well, #808080 is 128,128,128 in decimal (half of 256).

But I neglected to take into account the fact that PCs start counting at 0, heh.

So, 127,127,127 would be half of 255,255,255.

127,127,127 is #7F7F7F.

7F == 127
80 == 128
FF == 255

ATNO : FFFFFF - 7FFFFF == 800000 ;)
  • Belk Media Group
  • Graphic Monk
  • Professor
  • User avatar
  • Joined: Jan 12, 2005
  • Posts: 778
  • Loc: In the heart of California, Fresno.
  • Status: Offline

Post October 25th, 2005, 3:15 pm

WTF? I guess I am old. As an old school art major, we just used a color wheel, starting with the primary colors; red, blue, and yellow. If you don't know how to make one the following links should help a lot, especially the first one. The second one is a webpage tutorial on color theory.

http://www.ficml.org/jemimap/style/color/wheel.html
http://www.colormatters.com/colortheory.html
http://www.JamesBelk.com Stay Tuned for the new era in Belk Media Design
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post October 25th, 2005, 4:37 pm

Axe wrote:

ATNO : FFFFFF - 7FFFFF == 800000 ;)


Comes down to how it's calculated.
2+2 doesn't always equal 4
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • LAbrego
  • brego from LA
  • Web Master
  • User avatar
  • Joined: May 25, 2004
  • Posts: 2853
  • Status: Offline

Post October 25th, 2005, 5:25 pm

Never forget: 2 + 2 = 5 for extremely large values of 2. :D
  • Axe
  • Genius
  • Genius
  • User avatar
  • Joined: Jan 07, 2004
  • Posts: 5744
  • Loc: Sub-level 28
  • Status: Offline

Post October 25th, 2005, 6:21 pm

ATNO/TW wrote:
Axe wrote:

ATNO : FFFFFF - 7FFFFF == 800000 ;)


Comes down to how it's calculated.
2+2 doesn't always equal 4


Right, but here it's not one big single number. It's three pairs of 0-255. So you'd have to half each of the pairs.
  • reaper
  • Proficient
  • Proficient
  • User avatar
  • Joined: Apr 05, 2005
  • Posts: 435
  • Loc: europe
  • Status: Offline

Post October 26th, 2005, 1:17 am

Ok ok, this is getting complicated guys, especially when statements being made such as
Quote:
2+2 doesn't always equal 4
then you really got me lost in the forest of obliviousness :shock:

And please don't try to explain me how 2+2 doesn't always adds up to 4 because you guys are scaring the sh**s out of me :lol: talk about getting complicated :)


Please guys, a simple way to dertermine the opposite color of a hex value?
  • Axe
  • Genius
  • Genius
  • User avatar
  • Joined: Jan 07, 2004
  • Posts: 5744
  • Loc: Sub-level 28
  • Status: Offline

Post October 26th, 2005, 8:02 am

lmao!!!

Simple way == convert it to three decimal numbers between 0-255.

Subtract each of those numbers from 255, and convert your answer back to three pairs of hex numbers (Red, Green and Blue).
  • reaper
  • Proficient
  • Proficient
  • User avatar
  • Joined: Apr 05, 2005
  • Posts: 435
  • Loc: europe
  • Status: Offline

Post October 26th, 2005, 10:00 am

Quote:
Simple way == convert it to three decimal numbers between 0-255.

Subtract each of those numbers from 255, and convert your answer back to three pairs of hex numbers (Red, Green and Blue).



:lol: You call that simple

Come on man, you're sh*tting me right?
  • Axe
  • Genius
  • Genius
  • User avatar
  • Joined: Jan 07, 2004
  • Posts: 5744
  • Loc: Sub-level 28
  • Status: Offline

Post October 27th, 2005, 5:22 am

Nope, you can make up a PHP function to do it real easy.

Use substr() to split it up into 3 separate variables, do the math, then join 'em back up.

PHP Code: [ Select ]
<?php
 
 
 
function invert_colour($start_colour) {
 
  $colour_red = hexdec(substr($start_colour, 1, 2));
 
  $colour_green = hexdec(substr($start_colour, 3, 2));
 
  $colour_blue = hexdec(substr($start_colour, 5, 2));
 
 
 
  $new_red = dechex(255 - $colour_red);
 
  $new_green = dechex(255  - $colour_green);
 
  $new_blue = dechex(255 - $colour_blue);
 
 
 
  if (strlen($new_red) == 1) {$new_red .= '0';}
 
  if (strlen($new_green) == 1) {$new_green .= '0';}
 
  if (strlen($new_blue) == 1) {$new_blue .= '0';}
 
 
 
  $new_colour = '#'.$new_red.$new_green.$new_blue;
 
 
 
  return $new_colour;
 
}
 
 
 
echo '<table border="0" cellpadding="1" cellspacing="2" width="200">';
 
 
 
$start_colour = '#ffa040';
 
echo '<tr><td align="center" bgcolor="'.$start_colour.'"><b><font color="'.invert_colour($start_colour).'">'.$start_colour.'</font></b></td></tr>';
 
echo '<tr><td align="center" bgcolor="'.invert_colour($start_colour).'"><b><font color="'.$start_colour.'">'.invert_colour($start_colour).'</font></b></td></tr>';
 
 
 
$start_colour = '#eeff99';
 
echo '<tr><td align="center" bgcolor="'.$start_colour.'"><b><font color="'.invert_colour($start_colour).'">'.$start_colour.'</font></b></td></tr>';
 
echo '<tr><td align="center" bgcolor="'.invert_colour($start_colour).'"><b><font color="'.$start_colour.'">'.invert_colour($start_colour).'</font></b></td></tr>';
 
 
 
$start_colour = '#ff00ff';
 
echo '<tr><td align="center" bgcolor="'.$start_colour.'"><b><font color="'.invert_colour($start_colour).'">'.$start_colour.'</font></b></td></tr>';
 
echo '<tr><td align="center" bgcolor="'.invert_colour($start_colour).'"><b><font color="'.$start_colour.'">'.invert_colour($start_colour).'</font></b></td></tr>';
 
 
 
echo '</table>';
 
 
 
?>
 
 
  1. <?php
  2.  
  3.  
  4.  
  5. function invert_colour($start_colour) {
  6.  
  7.   $colour_red = hexdec(substr($start_colour, 1, 2));
  8.  
  9.   $colour_green = hexdec(substr($start_colour, 3, 2));
  10.  
  11.   $colour_blue = hexdec(substr($start_colour, 5, 2));
  12.  
  13.  
  14.  
  15.   $new_red = dechex(255 - $colour_red);
  16.  
  17.   $new_green = dechex(255  - $colour_green);
  18.  
  19.   $new_blue = dechex(255 - $colour_blue);
  20.  
  21.  
  22.  
  23.   if (strlen($new_red) == 1) {$new_red .= '0';}
  24.  
  25.   if (strlen($new_green) == 1) {$new_green .= '0';}
  26.  
  27.   if (strlen($new_blue) == 1) {$new_blue .= '0';}
  28.  
  29.  
  30.  
  31.   $new_colour = '#'.$new_red.$new_green.$new_blue;
  32.  
  33.  
  34.  
  35.   return $new_colour;
  36.  
  37. }
  38.  
  39.  
  40.  
  41. echo '<table border="0" cellpadding="1" cellspacing="2" width="200">';
  42.  
  43.  
  44.  
  45. $start_colour = '#ffa040';
  46.  
  47. echo '<tr><td align="center" bgcolor="'.$start_colour.'"><b><font color="'.invert_colour($start_colour).'">'.$start_colour.'</font></b></td></tr>';
  48.  
  49. echo '<tr><td align="center" bgcolor="'.invert_colour($start_colour).'"><b><font color="'.$start_colour.'">'.invert_colour($start_colour).'</font></b></td></tr>';
  50.  
  51.  
  52.  
  53. $start_colour = '#eeff99';
  54.  
  55. echo '<tr><td align="center" bgcolor="'.$start_colour.'"><b><font color="'.invert_colour($start_colour).'">'.$start_colour.'</font></b></td></tr>';
  56.  
  57. echo '<tr><td align="center" bgcolor="'.invert_colour($start_colour).'"><b><font color="'.$start_colour.'">'.invert_colour($start_colour).'</font></b></td></tr>';
  58.  
  59.  
  60.  
  61. $start_colour = '#ff00ff';
  62.  
  63. echo '<tr><td align="center" bgcolor="'.$start_colour.'"><b><font color="'.invert_colour($start_colour).'">'.$start_colour.'</font></b></td></tr>';
  64.  
  65. echo '<tr><td align="center" bgcolor="'.invert_colour($start_colour).'"><b><font color="'.$start_colour.'">'.invert_colour($start_colour).'</font></b></td></tr>';
  66.  
  67.  
  68.  
  69. echo '</table>';
  70.  
  71.  
  72.  
  73. ?>
  74.  
  75.  


There ya go. It could probably be optimized quite a bit, but you don't wanna know how hungover I am right now, heh.

You could make a form to submit the colours to a script, rather than having to edit the file each time.
  • blink182av
  • Guru
  • Guru
  • No Avatar
  • Joined: Jun 27, 2005
  • Posts: 1261
  • Loc: New York
  • Status: Offline

Post October 30th, 2005, 11:08 am

2.0+2.0=4.0 :)
  • Axe
  • Genius
  • Genius
  • User avatar
  • Joined: Jan 07, 2004
  • Posts: 5744
  • Loc: Sub-level 28
  • Status: Offline

Post October 30th, 2005, 11:53 am

Yeah, but 8+8 doesn't always = 16. Sometimes 8+8 == 10 ;)
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 30th, 2005, 11:53 am

Post Information

  • Total Posts in this topic: 21 posts
  • Users browsing this forum: No registered users and 47 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.