I need help in color math. I have one main color and i need to get other colors of chosen harmony.
I need such color harmonies: triada, complement, analogous, monochromatic. I need them in C#.
Any help is appreciated.
Thanks,
Dima.
I need help in color math. I have one main color and i need
Share
Ok, everything revolves around the color wheel described in your link. I suggest hardcoding those colors in an array. I’m assuming your main color is always one of those 12.
One helper method we’re going to need is one that will wrap values around the array, such that color -1 becomes color 12 (index 11 in the array):
We also need a helper method that will get the index of a color on the color wheel:
Now everything’s in place (assuming you’ve got an array called ColorWheelArray, containing the colors in order).
Triada:
Compliment:
Analogous:
As i don’t know the definition of monochromatic i’ll leave that to you. 🙂
EDIT: If you want it to work with any color then i’m not 100% sure, however i’ve got an idea.
That site says the wheel is created by picking colors in the RYB color space (not the RGB one that C# uses). So presumably you could work out how ‘far’ your color is to each of the colors on the wheel (by converting both to RYB and comparing), then use my functions to get the other color(s). Finally add on the difference between your color and the closest wheel color (in RYB color space) to each result, finally translating back into RGB to store as a Color object.