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

  • Home
  • SEARCH
  • 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 6662767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:25:32+00:00 2026-05-26T02:25:32+00:00

I am trying to generate colors on the fly for a chart control. I

  • 0

I am trying to generate colors on the fly for a chart control. I want the colors to be visually distinctive. I don’t just want the colors to be distinctive from the adjacent colors, but all colors generated so far.

I also don’t want to have to have a known color collection size. Some algorithms I have seen for this require the number of things to color to be known. I want to implement a GetNextColor() for my color generator so I will not know at the time of choosing how many colors I will ultimately have and choosing a number up front feels wrong.

I am not just trying to graph a bunch of stuff in different colors, I am interested in this problem and want some feedback.

Here’s where I’m at:

  • Using the HSV color space.
  • The hue is a value from [0-360] where 0
    and 360 are the same (reddish).
  • Hue starts at 0, I ad 27 (so that
    when it cycles around it doesn’t land on the same color it started
    on), take MOD 360.
  • For S and V (both between 0 and 1) I start out at a low number like
    .25
  • Run through about 20 hues
  • Then take a high number like .85
  • Run through 20 hues
  • Then start bisecting to get the most distant
    values that haven’t been used yet.

This isn’t a very effective method, it works OK, but it could be much
more scientific. It started out with a lot of thought and then
morphed into this mess.

Any ideas on how to do this elegantly?

(It shouldn’t matter, but I am using C# and I will post code when I get back to my computer I have all this stuff on.)

  • 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-26T02:25:33+00:00Added an answer on May 26, 2026 at 2:25 am

    I believe that your question should be split into two questions:

    1. How to map colors into a n-dimensional Cartesian space, and define an Euclidean distance function between colors, such that the distance reflects the difference for a human observer.
    2. Given a n-dimensional cuboid, generate a sequence of dots such that minimal Euclidean distance between any two dots generated so far would be maximized.

    And now the answers:

    1. Color difference is calculated using the The CIEDE2000 Color-Difference Formula. The CIEDE2000 formula is based on the LCH color space (Luminosity, Chroma, and Hue). LCH color space is represented as a cylinder (see image here).

      However, the difference formula is highly nonlinear. Therefore it would be impossible to map the colors into a square grid such that Euclidean distance would give the CIEDE2000 color-difference.

      Settling on a less accurate model, we can use the CIE76 Color-Difference formula, which is based on the Lab color space ( L*a*b*). We can use Euclidean distance directly on this color space to measure the difference. There are no simple formulas for conversion between RGB or CMYK values and L*a*b*, because the RGB and CMYK color models are device dependent. The RGB or CMYK values first need to be transformed to a specific absolute color space, such as sRGB or Adobe RGB. This adjustment will be device dependent, but the resulting data from the transform will be device independent, allowing data to be transformed to the CIE 1931 color space and then transformed into L*a*b*. This article explains the procedure and the formulas.

    2. For the L*a*b* color space and the CIE76 Color-Difference formula – we’ll need to solve the problem for a 3D cube.

      I believe that your best strategy would be to divide the cube into 8 cubes, which will generate 27 points. Use these points. Now divide each of the 8 cubes into another 8 cubes. For each of these cubes, 12 out of the 27 points have already been used, so you’re left with 15*8 new points. In each additional step n, you can generate 15*8^n additional points.

      The points-set in each step should be sorted such that the minimal distance between two consecutive points would be maximized. I don’t know how to do it – I’ve just posted a question.

    Edit:

    I’ve crossposted on https://cstheory.stackexchange.com/ and got a good answer. See https://cstheory.stackexchange.com/questions/8609/sorting-points-such-that-the-minimal-euclidean-distance-between-consecutive-poin.

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

Sidebar

Related Questions

I'm trying to generate sparklines for a dashboard using the Microsoft chart control on
I am trying to generate a list of all possible number combinations within a
I hwas trying to generate a multi page XPS document from a web application
I am trying to generate a dynamic html button in c#,But buttons are being
I'm trying to generate a query that finds all large, red things with a
I'm trying to store randomly generated dice values in some data structure, but don't
Using my Windows 7 64bit machine, I'm trying to generate an avi file from
I am trying to automatically generate a bunch of images all containing a border,
I am trying to figure out how to generate combinations of sizes with colors
I'm trying to generate a vector graphic from an area in a bitmap image,

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.