-3
    pt = Point(x,y) 
    h=angle
    s=length
    RGB=colorsys.hsv_to_rgb(h, s, 0)
    print (RGB)
    pt.setFill(color_rgb(RGB))
    pt.draw(win)

I get error message: "color_rgb() missing 2 required positional arguments: 'g' and 'b'" but if I print RGB I get: "(-0.0, -0.0, 0)", so there is three.

I made corrections below:

    pt = Point(x,y) 
    h=angle
    s=length
    print (h,s)
    RGB=colorsys.hsv_to_rgb(h, s, h + s)
    pt.setFill(color_rgb(*RGB))
    pt.draw(win)

But now I get error message:

File "D:\Python\graphics.py", line 962, in color_rgb return "#%02x%02x%02x" % (r,g,b) TypeError: %x format: an integer is required, not float

1 Answers1

1

RGB is here a 3-tuple, but you can not pass this tuple to color_rgb: this method requires three parameters. You can however unpack the tuple in three parameters, with for example the asterisk (*) in front:

pt.setFill(color_rgb(*RGB))

or you can first unpack the tuple in three variables:

r, g, b = RGB
pt.setFill(color_rgb(r, g, b))

Note however that if the v parameter is set to 0, this will always return (0, 0, 0) since HSV is basically a cone, and the v parameter determines the distance from the "top" to the "surface", as is demonstrated on the Wikipedia image [wiki] below:

enter image description here

So with v=0, this will always result in black, regardless of the value for the hue and saturation.

Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555