V
V
Vlad Osadchyi2019-04-18 18:17:05
Algorithms
Vlad Osadchyi, 2019-04-18 18:17:05

How to consistently generate the most different colors?

There is such a color generator:

public static function getRandomHexColor()
   {
       return  sprintf('#%02X%02X%02X', rand(20, 200), rand(20, 200), rand(20, 200));
   }

When I call it in a loop, I often end up with very similar colors, for example:

5cb894aecc444772286744.png
What algorithm can I use to get the most different colors?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2019-04-18
@VladOsadchyi

The most reliable way is to generate a set of suitable colors in advance and simply choose from a ready-made table, at least in turn, at least randomly with repetition control.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question