Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4597286
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:14:08+00:00 2026-05-21T23:14:08+00:00

I need help in color math. I have one main color and i need

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T23:14:09+00:00Added an answer on May 21, 2026 at 11:14 pm

    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):

    int WrapColor(int colorIndex, int numWheelColors)
    {
        while(colorIndex < 0)
        {
            colorIndex += numWheelColors;
        }
    
        colorIndex = colorIndex % numWheelColors;
    }
    

    We also need a helper method that will get the index of a color on the color wheel:

    int GetColorWheelIndex(Color color)
    {
        if (ColorWheelArray.Contains(color))
            return ColorWheelArray.IndexOf(color);
        else
            throw new InvalidArgumentException("color");
    }
    

    Now everything’s in place (assuming you’ve got an array called ColorWheelArray, containing the colors in order).

    Triada:

    Color[] GetTriadaColors(Color color)
    {
        int colorIndex = GetColorWheelIndex(color, ColorWheelArray.Length);
        return new Color[]
            {
                color,
                ColorWheelArray[WrapColor(colorIndex + ColorWheelArray.Length / 3)],
                ColorWheelArray[WrapColor(colorIndex + 2 * ColorWheelArray.Length / 3)]
            };
    }
    

    Compliment:

    Color GetComplimentColor(Color color)
    {
        int colorIndex = GetColorWheelIndex(color, ColorWheelArray.Length);
        return ColorWheelArray[WrapColor(colorIndex + ColorWheelArray.Length / 2)];
    }
    

    Analogous:

    Color[] GetAnalogousColors(Color color)
    {
        int colorIndex = GetColorWheelIndex(color, ColorWheelArray.Length);
        return new Color[] { color,
                             ColorWheelArray[WrapColor(colorIndex + 1)],
                             ColorWheelArray[WrapColor(colorIndex + 2)] };
    }
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two System.Windows.Media.Color (a and b)and need to get a and put over
I would need help: I have an array and I need to get values
Need help with a query that I wrote: I have three tables Company id
need help/guide for sql select query, I have 2 table stock and stock_history, in
need help regarding USSD Gateway. I have to develop an app, which will directly
need help in error in database pivot. i have table tamed table_score like below:
I need help with one ajax function This is raw page setup. Page will
I have created an animation which works fine, but it flicks. I need help
I need help. I have 6 tabs on website. But when i`m clicking to
I need some help optimizing a section of math heavy code. I've done the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.