How to generate random 'greenish' colors

后端 未结 9 1976
鱼传尺愫
鱼传尺愫 2020-12-28 13:31

Anyone have any suggestions on how to make randomized colors that are all greenish? Right now I\'m generating the colors by this:

color = (randint(100, 200),         


        
相关标签:
9条回答
  • 2020-12-28 13:50

    I'd go with with the HSV approach everyone else mentioned. Another approach would be to get a nice high resolution photo which some greenery in it, crop out the non-green parts, and pick random pixels from it using PIL.

    0 讨论(0)
  • 2020-12-28 13:56

    So in this case you are lucky enough to want variations on a primary color, but for artistic uses like this it is better to specify color wheel coordinates rather than primary color magnitudes.

    You probably want something from the colorsys module like:

    colorsys.hsv_to_rgb(h, s, v)
        Convert the color from HSV coordinates to RGB coordinates.
    
    0 讨论(0)
  • 2020-12-28 13:59

    The simplest way to do this is to make sure that the red and blue components are the same, like this: (Forgive my Python)

    rb = randint(100, 200)
    color = (rb, randint(120, 255), rb)
    
    0 讨论(0)
提交回复
热议问题