Notifications
Clear all

[Closed] complement color how?

I want to make a script that can generate the complement color of a color, but don’t know the algorithm to do it. Hope anyone will help:) ,btw thanks in advance.

1 Reply

This can be a very tricky question, depending on the color space within which you define compliments. In pigments (paint, etc.), you have compliment pairs like red/green, blue/orange, and yellow/purple. But in additive color space the compliments are blue/yellow, red/cyan, green/magenta. In Max you are dealing with RGB, which is additive, and the mapping of colors in this system to their pigmentary compliments is completely arbitrary.

If all you need is the additive compliment, then that’s fairly straightforward – just subtract each rgb component from 255 and the result is your compliment. But if you need the pigmentary compliment of an rgb color, the only way I know of to get it is to build a lookup table for the .hue of a color. The hue range in Max is 0-255, so you’d need a 256-element array of values, where each element is a complimentary hue value to the element’s index. This is not trivial!

RH