I have a simple PHP function that generates the hexadecimal value for HTML colors and insert them in a db.
Considering an array of hexadecimal values extracted from the db, how can I modify this function to avoid generating a color similar to the others?
There are many definitions of the similarity of colours. You might be looking for similar hue, or similar brightness.
For these purposes, perhaps the simplest is to take the euclidian distance between the two points in RGB space, that is:
and reject those where that value is too small (e.g. 10?)