SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Zealot
    Join Date
    May 2002
    Location
    Brandon, MS
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    calculating colors

    Is there a formula that can be used to calculate an RGB colors complementary color? example: Plug ff0000 into the formula and get a result of 00ff00.

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    Svj
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.colormatch.dk/

    I think one of the 6 colours is the complementary

    And the formula? I guess it can be found somewhere in the javascript

  3. #3
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    Svj
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, maybe it's just y = 255 - x for each value R, G and B?

  4. #4
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,811
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Eurgh - doesn't work on any proper browsers....any good cross-browser options?
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  5. #5
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    Svj
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jofa
    Hmm, maybe it's just y = 255 - x for each value R, G and B?
    Yep, I was right
    How to calculate complementary colours: the sum of value pairs must be 255 (=FF)
    Example: 003366 vs. FFCC99


    Well, I think I was right... Asked my wife, who is an art teacher, and then a long discussion on simultaneous contrasts etc followed, and I was completely lost

    This site has a lot of colourful info:
    http://www.ncscolour.com/engelsk/main.asp
    Last edited by jofa; Aug 18, 2003 at 04:02.

  6. #6
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice discovery, jofa. I cooked up a quick Python function that can be adapted to whatever language you use.
    Code:
    def complementaryColor(hex):
      """Returns complementary RGB color
      
      Example:
      >>>complementaryColor('FFFFFF')
      '000000'
      """
      if hex[0] == '#':
        hex = hex[1:]
      rgb = (hex[0:2], hex[2:4], hex[4:6])
      comp = ['02%X' % (255 - int(a, 16)) for a in rgb]
      return comp.join()
    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure

  7. #7
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    Svj
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice

    If you want a javascript version, I think reading this thread first can be helpful:
    http://www.sitepointforums.com/showt...threadid=92993

  8. #8
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's also a wealth of javascript color stuff in Eric Meyer's Color Blender(released under a Creative Commons license) for the borrowing.
    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure

  9. #9
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,811
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by anode
    There's also a wealth of javascript color stuff in Eric Meyer's Color Blender(released under a Creative Commons license) for the borrowing.
    Yay, and it plays with Firebird (as you'd expect from Meyer)
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  10. #10
    SitePoint Zealot
    Join Date
    May 2002
    Location
    Brandon, MS
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for all your input!

  11. #11
    SitePoint Zealot
    Join Date
    May 2002
    Location
    Brandon, MS
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, maybe it's just y = 255 - x for each value R, G and B?
    I don't this works.
    Example: The complementary color for red (FF0000) is green (00FF00). Using this formula you would get 00FFFF for the complement of red.

  12. #12
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    Svj
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kenbusby
    I don't this works.
    Example: The complementary color for red (FF0000) is green (00FF00). Using this formula you would get 00FFFF for the complement of red.
    Is green the complementary colour to red?
    I think a green-blue colour is more correct

    http://www.color-wheel-pro.com/pics/complementary.jpg

  13. #13
    SitePoint Zealot
    Join Date
    May 2002
    Location
    Brandon, MS
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well then, I'm really confused. I have a pocket color wheel I purchased at WalMart that indicates green is complementary to red, blue-green is complementary to red-orange????


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •