Generate random colors (RGB)

后端 未结 8 2107
-上瘾入骨i
-上瘾入骨i 2020-12-25 12:51

I just picked up image processing in python this past week at the suggestion of a friend to generate patterns of random colors. I found this piece of script online that gene

8条回答
  •  一个人的身影
    2020-12-25 13:22

    Here:

    def random_color():
        rgbl=[255,0,0]
        random.shuffle(rgbl)
        return tuple(rgbl)
    

    The result is either red, green or blue. The method is not applicable to other sets of colors though, where you'd have to build a list of all the colors you want to choose from and then use random.choice to pick one at random.

提交回复
热议问题