Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How do you figure out the best contrasting-opposite color

How do you figure out the best contrasting-opposite color

Scheduled Pinned Locked Moved C#
tutorial
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FocusedWolf
    wrote on last edited by
    #1

    I'm not sure what to call this. but i rember once seeing this color wheel which showed the best opposing colors...like yellow was the color opposite black. I'm not trying to figure out how to invert a color. so i want a function where if i send in the color black, it returns yellow. i'd settle for the name of that sorta color wheel :P

    S 1 Reply Last reply
    0
    • F FocusedWolf

      I'm not sure what to call this. but i rember once seeing this color wheel which showed the best opposing colors...like yellow was the color opposite black. I'm not trying to figure out how to invert a color. so i want a function where if i send in the color black, it returns yellow. i'd settle for the name of that sorta color wheel :P

      S Offline
      S Offline
      sarojkumarjena
      wrote on last edited by
      #2

      substract the RGB combination of current color from RGB(255,255,255)

      C 1 Reply Last reply
      0
      • S sarojkumarjena

        substract the RGB combination of current color from RGB(255,255,255)

        C Offline
        C Offline
        Coding C
        wrote on last edited by
        #3

        Hi, After reading your disccission i have a question. that is how to get the rgb codes of the specific color, for example what are the rgb combinations of the color yellow. thanks.:) Nitin...

        M 1 Reply Last reply
        0
        • C Coding C

          Hi, After reading your disccission i have a question. that is how to get the rgb codes of the specific color, for example what are the rgb combinations of the color yellow. thanks.:) Nitin...

          M Offline
          M Offline
          mabo42
          wrote on last edited by
          #4

          Try this:

          Color original = Color.Yellow;
          Color opposite = Color.FromArgb(255 - original.R, 255 - original.G, 255 - original.B);

          F 1 Reply Last reply
          0
          • M mabo42

            Try this:

            Color original = Color.Yellow;
            Color opposite = Color.FromArgb(255 - original.R, 255 - original.G, 255 - original.B);

            F Offline
            F Offline
            FocusedWolf
            wrote on last edited by
            #5

            Ok i did some research and it turns out that complementary colors is same as inverted colors, for most part. so blue is the opposite of yellow, not black Here's another way to get inverted color... not sure if its more effecient. private Color InvertColor(Color color) { byte bRed = (byte)~(color.R); byte bGreen = (byte)~(color.G); byte bBlue = (byte)~(color.B); return Color.FromArgb(bRed, bGreen, bBlue); } This site helped to explain it: http://www.webwhirlers.com/colors/combining.asp

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups