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

前端 未结 6 2097
甜味超标
甜味超标 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:24

    All colors where each of r, g ,b is greater than 0x7f

    color = (0..2).map{"%0x" % (rand * 0x80 + 0x80)}.join
    

提交回复
热议问题