Ruby, Generate a random hex color (only light colors)

前端 未结 6 2047
甜味超标
甜味超标 2021-01-07 01:49

I know this is possible duplicated question. Ruby, Generate a random hex color

My question is slightly different. I need to know, how to generate the random hex lig

6条回答
  •  离开以前
    2021-01-07 02:19

    Just some pointers:

    Use HSL and generate the individual values randomly, but keeping L in the interval of your choosing. Then convert to RGB, if needed.

    It's a bit harder than generating RGB with all components over a certain value (say 0x7f), but this is the way to go if you want the colors distributed evenly.

提交回复
热议问题