Generate random colors (RGB)

后端 未结 8 2067
-上瘾入骨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:39

    With custom colours (for example, dark red, dark green and dark blue):

    import random
    
    COLORS = [(139, 0, 0), 
              (0, 100, 0),
              (0, 0, 139)]
    
    def random_color():
        return random.choice(COLORS)
    
    0 讨论(0)
  • 2020-12-25 13:43

    Output in the form of (r,b,g) its look like (255,155,100)

    from numpy import random
    color = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
    
    0 讨论(0)
提交回复
热议问题