Вопрос

I need to represent a series of elements through time. For designing purposes each of them should have a color to make it simplier to identify each one at a glance. The point is that color each elemnt would make no sense if the difference in color between them is not appreciable by humans.

The only fixed attribute the elements have is their ID. This ID is supossed to differ by one from one element to another, but this is not certain.

What I look for is a hash function that based on a numeric ID returns an HEX color (web format e.g. #f62035) that differs a lot with the previous ID and the next ID. Also, the HEX color must not be too dark since the background where the elements are displayed is black.


Example:

Element ID: 12  
Element ID: 13

hash(12) = #f46600  
hash(13) = #5aa9aa
Это было полезно?

Решение

IMHO, and depeding how many different colors you are going to need, I think your best solution would be to build a list of colors to use, with say 100 different variations of color, and sort them in the order you want to use them, then you can use these as your colors by assigningn them from this list in order, when you get to the end of the list, you can start again.

This solution would not be scalable, but you have to keep in mind that there are only very few colors that humans can tell they are different and suit your design.

To create this list, maybe you can write a different java application that swhows a color picker, so you can choose colors and the code creates the list for you

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top