how to determine the opposite of hex color values?

  • blink182av
  • Guru
  • Guru
  • No Avatar
  • Joined: Jun 27, 2005
  • Posts: 1261
  • Loc: New York
  • Status: Offline

Post October 30th, 2005, 5:25 pm

-decimal? Lol?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 30th, 2005, 5:25 pm

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

Post November 10th, 2005, 8:54 am

Ok guys i thought i didn't need it afterall but it shows i still need to know how this is done but i can't understand s&*t from this.

Isn't there a single piece of software that can spit out the opposite value for me when i enter a certain value?
  • xamix
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Nov 07, 2005
  • Posts: 154
  • Status: Offline

Post November 10th, 2005, 6:53 pm

http://www.artofwebdesign.co.uk/index.php?pg=rgbtohsl
http://www.artofwebdesign.co.uk/index.php?pg=hsltorgb
http://www.artofwebdesign.co.uk/colourcalculator.php


http://www.geocities.com/seedytheteck/c ... osite.html
  • reaper
  • Proficient
  • Proficient
  • User avatar
  • Joined: Apr 05, 2005
  • Posts: 435
  • Loc: europe
  • Status: Offline

Post November 11th, 2005, 7:45 am

THANKS! Xamix that looks very helpfull.
  • uberblue
  • Born
  • Born
  • No Avatar
  • Joined: Dec 06, 2006
  • Posts: 1
  • Status: Offline

Post December 6th, 2006, 8:20 pm

I was bored/curious so I converted the above php example to Classic ASP. Hopefully this will help somebody. The code isn't the cleanest because I used a translator
(http://www.me-u.com/php-asp/) and the cleaned that up. It was quite a bit of work actually, the translator was rather useless.

Code: [ Select ]
<%

Function HexToDec(strHex)
 dim lngResult
 dim intIndex
 dim strDigit
 dim intDigit
 dim intValue

 lngResult = 0
 for intIndex = len(strHex) to 1 step -1
  strDigit = mid(strHex, intIndex, 1)
  intDigit = instr("0123456789ABCDEF", ucase(strDigit))-1
  if intDigit >= 0 then
   intValue = intDigit * (16 ^ (len(strHex)-intIndex))
   lngResult = lngResult + intValue
  else
   lngResult = 0
   intIndex = 0 ' stop the loop
  end if
 next

 HexToDec = lngResult
End Function


Dim start_colour

Function invert_colour(lv_start_colour)
    Dim lv_colour_red, lv_colour_green, lv_colour_blue, lv_new_red, lv_new_green, lv_new_blue, lv_new_colour
    lv_colour_red = HexToDec(Mid(lv_start_colour,1,2))
    lv_colour_green = HexToDec(Mid(lv_start_colour, 3, 2))
    lv_colour_blue = HexToDec(Mid(lv_start_colour, 5, 2))
    lv_new_red = Hex(255 - lv_colour_red)
    lv_new_green = Hex(255  - lv_colour_green)
    lv_new_blue = Hex(255 - lv_colour_blue)
    
    If Len(lv_new_red)=1 then
        lv_new_red = lv_new_red & "0"
    End If
    If Len(lv_new_green) = 1 then
        lv_new_green = lv_new_green & "0"
    End If
    If Len ( lv_new_blue ) = 1 then
        lv_new_blue = lv_new_blue '0'
    End If

    new_colour  = "#" & lv_new_red & lv_new_green & lv_new_blue
    invert_colour = new_colour
End Function


    start_colour  = "#ffa040"
    Response.Write "<table border=""0"" cellpadding=""1"" cellspacing=""2"" width=""200"">"
    Response.Write "<tr><td align=""center"" bgcolor=""" & start_colour & """><b><font color=""" & invert_colour(start_colour) & """>" & start_colour & "</font></b></td></tr>" & vbcrlf & vbcrlf
    Response.Write "<tr><td align=""center"" bgcolor=""" & invert_colour(start_colour) & """><b><font color=""" & start_colour & """>" & invert_colour(start_colour) & "</font></b></td></tr>" & vbcrlf & vbcrlf
    start_colour  = "#eeff99"
    Response.Write "<tr><td align=""center"" bgcolor=""" & start_colour & """><b><font color=""" & invert_colour(start_colour) & """>" & start_colour & "</font></b></td></tr>"& vbcrlf & vbcrlf
    Response.Write "<tr><td align=""center"" bgcolor=""" & invert_colour(start_colour) & """><b><font color=""" & start_colour & """>" & invert_colour(start_colour) & "</font></b></td></tr>" & vbcrlf & vbcrlf
    start_colour  = "#ff00ff"
    Response.Write "<tr><td align=""center"" bgcolor=""" & start_colour & """><b><font color=""" & invert_colour(start_colour) & """>" & start_colour & "</font></b></td></tr>" & vbcrlf & vbcrlf
    Response.Write "<tr><td align=""center"" bgcolor=""" & invert_colour(start_colour) & """><b><font color=""" & start_colour & """>" & invert_colour(start_colour) & "</font></b></td></tr>" & vbcrlf & vbcrlf
    Response.Write "</table>"
    
%>
  1. <%
  2. Function HexToDec(strHex)
  3.  dim lngResult
  4.  dim intIndex
  5.  dim strDigit
  6.  dim intDigit
  7.  dim intValue
  8.  lngResult = 0
  9.  for intIndex = len(strHex) to 1 step -1
  10.   strDigit = mid(strHex, intIndex, 1)
  11.   intDigit = instr("0123456789ABCDEF", ucase(strDigit))-1
  12.   if intDigit >= 0 then
  13.    intValue = intDigit * (16 ^ (len(strHex)-intIndex))
  14.    lngResult = lngResult + intValue
  15.   else
  16.    lngResult = 0
  17.    intIndex = 0 ' stop the loop
  18.   end if
  19.  next
  20.  HexToDec = lngResult
  21. End Function
  22. Dim start_colour
  23. Function invert_colour(lv_start_colour)
  24.     Dim lv_colour_red, lv_colour_green, lv_colour_blue, lv_new_red, lv_new_green, lv_new_blue, lv_new_colour
  25.     lv_colour_red = HexToDec(Mid(lv_start_colour,1,2))
  26.     lv_colour_green = HexToDec(Mid(lv_start_colour, 3, 2))
  27.     lv_colour_blue = HexToDec(Mid(lv_start_colour, 5, 2))
  28.     lv_new_red = Hex(255 - lv_colour_red)
  29.     lv_new_green = Hex(255  - lv_colour_green)
  30.     lv_new_blue = Hex(255 - lv_colour_blue)
  31.     
  32.     If Len(lv_new_red)=1 then
  33.         lv_new_red = lv_new_red & "0"
  34.     End If
  35.     If Len(lv_new_green) = 1 then
  36.         lv_new_green = lv_new_green & "0"
  37.     End If
  38.     If Len ( lv_new_blue ) = 1 then
  39.         lv_new_blue = lv_new_blue '0'
  40.     End If
  41.     new_colour  = "#" & lv_new_red & lv_new_green & lv_new_blue
  42.     invert_colour = new_colour
  43. End Function
  44.     start_colour  = "#ffa040"
  45.     Response.Write "<table border=""0"" cellpadding=""1"" cellspacing=""2"" width=""200"">"
  46.     Response.Write "<tr><td align=""center"" bgcolor=""" & start_colour & """><b><font color=""" & invert_colour(start_colour) & """>" & start_colour & "</font></b></td></tr>" & vbcrlf & vbcrlf
  47.     Response.Write "<tr><td align=""center"" bgcolor=""" & invert_colour(start_colour) & """><b><font color=""" & start_colour & """>" & invert_colour(start_colour) & "</font></b></td></tr>" & vbcrlf & vbcrlf
  48.     start_colour  = "#eeff99"
  49.     Response.Write "<tr><td align=""center"" bgcolor=""" & start_colour & """><b><font color=""" & invert_colour(start_colour) & """>" & start_colour & "</font></b></td></tr>"& vbcrlf & vbcrlf
  50.     Response.Write "<tr><td align=""center"" bgcolor=""" & invert_colour(start_colour) & """><b><font color=""" & start_colour & """>" & invert_colour(start_colour) & "</font></b></td></tr>" & vbcrlf & vbcrlf
  51.     start_colour  = "#ff00ff"
  52.     Response.Write "<tr><td align=""center"" bgcolor=""" & start_colour & """><b><font color=""" & invert_colour(start_colour) & """>" & start_colour & "</font></b></td></tr>" & vbcrlf & vbcrlf
  53.     Response.Write "<tr><td align=""center"" bgcolor=""" & invert_colour(start_colour) & """><b><font color=""" & start_colour & """>" & invert_colour(start_colour) & "</font></b></td></tr>" & vbcrlf & vbcrlf
  54.     Response.Write "</table>"
  55.     
  56. %>
  • CXLink
  • Expert
  • Expert
  • User avatar
  • Joined: Nov 22, 2004
  • Posts: 684
  • Loc: ATL-GA
  • Status: Offline

Post December 7th, 2006, 5:36 am

blink182av wrote:
2.0+2.0=4.0 :)


Good Job blink I agree with you. Axe threw me under the bus before he posted the php.
My definition of simple php is one maybe two lines not one or two pages. lol
My head hurts I am going to go take a nap.

Post Information

  • Total Posts in this topic: 21 posts
  • Users browsing this forum: No registered users and 45 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
 
cron
 

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