I need to calculate/generate the complementary color of color. I thought I had it working but it's the wrong kind. As the opposite of red I get cyan instead of green, that's because AS3 uses rgb values. I know that I would need to use RYB values but I don't know how to convert from RGB to RYB, Calculate to complementary color of the RYB value and then Convert it back to RGB. I don't have a lot of knowledge of AS3.
Asked
Active
Viewed 713 times
1
-
what do you want to achieve? what code do you have now? if you have ryb colors, it will still be displayed if it would be rgb, so you have to convert them.. more info pls.. – csomakk Dec 17 '12 at 13:03
-
ryb to rgb - some fun math: http://stackoverflow.com/questions/4945457/conversion-between-rgb-and-ryb-color-spaces – Gone3d Dec 17 '12 at 14:20
-
@csomakk i want to get the complementary color of the color that i put in. ie i give red and it returns green. i have code now ` r = color >>> 16 & 0xFF; g = color >>> 8 & 0xFF; b = color & 0xFF; rc = r ^ 0xFF; gc = g ^ 0xFF; bc = b ^ 0xFF; return complementaryColor = rc << 16 | gc << 8 | bc;` but it returns cyan instead of green. if you know a way of getting that i would be very thankfull – Liam de Haas Dec 17 '12 at 14:37
-
@Gone3d i read that but im not good enough with coding to just find it out by reading an article and figuring it out myself. – Liam de Haas Dec 17 '12 at 14:39
1 Answers
1
You should look in to Hue-Saturation-Brightness. A rotation of 180 degrees on the Hue scale should give the opposite color.
I don't have actual code for you to share but check out the ColorMatrix
class from Quasimondo:
http://code.google.com/p/quasimondolibs/source/browse/trunk/quasimondolibs/com/quasimondo/geom/ColorMatrix.as

frankhermes
- 4,720
- 1
- 22
- 39