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 6468569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:54:07+00:00 2026-05-25T05:54:07+00:00

How I can programmatically split the color circle into sections, and how I can

  • 0

How I can programmatically split the color circle into sections, and how I can get all RGB color in this sections ?

Color Circle

I want fce which returns me the color section by input parament in RGB color.

int getColorSection(RGB color);
  • 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-25T05:54:08+00:00Added an answer on May 25, 2026 at 5:54 am

    I don’t know if i understood correctly the question, but i think you are asking if a color is more green, more blue or blue red?
    This will give you informations on in what section (Red, Green or Blue) it is.

    For doing that, without keeping in account human perception of colors, you can do:

    public enum ColorSection
    {
        Red,
        Green,
        Blue
    }
    
    public ColorSection GetColorSection(int rgb)
    {
        int r = rgb & 0xFF;
        int g = (rgb >> 8) & 0xFF;
        int b = (rgb >> 16) & 0xFF;
    
        return (r > g && r > b) ? ColorSection.Red : ((g > b) ? ColorSection.Green : ColorSection.Blue);
    }
    

    Of course this don’t work very well if you have colors with two equal values, if you have red = green, it returns red.
    If you have white it returns red, if you have black, it returns blue.

    If you need something more fancy, probably as you are asking, then you need to use neirest neighbour approximation and polar coordinates.

    You can compute the angle using, as pointed out, the Hue.
    From the angle then you can just convert it to an integer.

    To compute the hue:

        public static double GetHue(int rgb)
        {
            double result = 0.0;
            int r = rgb & 0xFF;
            int g = (rgb >> 8) & 0xFF;
            int b = (rgb >> 16) & 0xFF;
    
            if (r != g && g != b)
            {
                double red = r / 255.0;
                double green = g / 255.0;
                double blue = b / 255.0;
    
                double max = Math.Max(Math.Max(red, green), blue);
                double min = Math.Min(Math.Min(red, green), blue);
    
                double delta = max - min;
                if (delta != 0)
                {
                    if (red == max)
                        result = (green - blue) / delta;
                    else if (green == max)
                        result = 2 + ((blue - red) / delta);
                    else if (blue == max)
                        result = 4 + ((red - green) / delta);
    
                    result *= 60.0;
                    if (result < 0)
                        result += 360.0;
                }
            }
    
            return result;
        }
    

    It returns the angle, in degrees, from 0 to 360, of where are you in the color wheel.
    You can compute than the section using neirest neighbour.

    For example:

    const int NumberOfSections = 10;
    int section = (int)(GetHue() * NumberOfSections / 360.0);
    

    Your wheel however seems rotated in respect to the C# color wheel.
    You probably need to substract a constant angle that is the exact difference.

    If i’m not wrong, the difference is 180°.

        public static double GetMyHue(int rgb)
        {
            return (GetHue(rgb) + 180.0) % 360.0;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can programmatically check which version of the WMI (Windows Management Instrumentation) is installed
I know you can programmatically determine the tranparency color of a .gif Is there
I have the following scenario. I have a search page which is split into
Is there a way in which I can programmatically access the document properties of
How can we programmatically create a Navigation controller in Detailed view of Split view
Is it possible to create a service or application which can programmatically log a
I can adda UINavigationController to a UIView programmatically but how is this represented in
Any pointers on how I can programmatically get exactly the identical stored procedure source
I found this piece of code works in that i can programmatically creates a
Is there any way that I can programmatically create (and I guess access) hidden

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.