Drawing colors with colorsys


  • admin

    0_1515704525803_dot.png

    Python offers a couple of basic color conversion tools in the colorsys module. In this snippet the hsv_to_rgb() function converts hue (the color), saturation and brightness values (all between 0 and 1) to red, green and blue values.

    import colorsys
    
    s = 50
    b = 20
    step = 0
    brig = .5
    sat = 1
    for x in range(s):
        for y in range(s):
            c = colorsys.hsv_to_rgb(step/(s*s), 1, y/s)
            fill(*c)
            rect(x*b, y*b, b, b)
            step+= 1
    saveImage("dot.png")
    

Log in to reply
 

Looks like your connection to DrawBot Forum was lost, please wait while we try to reconnect.