Generate Random Color distinguishable to Humans

前端 未结 9 912
旧时难觅i
旧时难觅i 2020-12-12 14:11

I am trying to randomly generate a color in hex in javascript.

However the colors generated are almost indistinguishable from eachother.
Is there a way to improv

9条回答
  •  感情败类
    2020-12-12 15:05

    What you are saying is that you do not want to generate random colors, you are saying that you want to generate different colors.
    You can find a good tutorial on how to do it here: http://krazydad.com/tutorials/makecolors.php .

    I made this fiddle with the relevant code from the tutorial demonstrating how you would generate non-repeating colors:

    http://jsfiddle.net/rGL52/

    The only differnce from the tutorial code is that the makegradient() function returns an array of colors that you can later apply at will in your page.

提交回复
热议问题