tags:

views:

102

answers:

4

Is there a way to find the complement of a color given its RGB values? Or can it only be found for certain colors? How would someone go about doing this in Java?

+2  A: 

Complement

How to Calculate a Complementary Color (PHP): http://www.serennu.com/colour/rgbtohsl.php

Javascript implementation: http://stackoverflow.com/questions/1664140/js-function-to-calculate-complementary-color

Supplement

(couldn't find technical definition)

MvanGeest
A: 

it should just be math

the total of the r values of the 2 colors should be 255

the total of the g values of the 2 colors should be 255

the total of the b values of the 2 colors should be 255

Randy
This will cause e.g. red to pair with cyan instead of green.
Adam Crume
+5  A: 

This is a question that can have unexpected depth, depending on what you need this for. If you're just trying to create something that looks more or less like the complement of an input color, it's pretty trivial using simple math. If you want it to be as close as possible (so you actually get a neutral gray when mixing the color), then you'll need to deal with color spaces, gamma, and the rest of the calibrated color mess.

Incidentally, I'm not familiar with the term "supplement of a color" - what do you mean by that?

Mark Bessey
+2  A: 

Complementary is easy using the HSL Color class.

camickr
Specifically, use hue to find complementary colors, matching saturation and lightness.
Alex Feinman