Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
colorsys.hsv_to_rgb
#1
pt = Point(x,y) 
h=angle
s=length
RGB=colorsys.hsv_to_rgb(h, s, 0.0)
pt.setFill(color_rgb(RGB))
pt.draw(win)
I get error message="color_rgb() missing 2 required positional arguments: 'g' and 'b'"

Why? What I'm doing wrong?
Reply
#2
I don't know the library you use, but it seems that colorsys.hsv_to_rgb(h, s, 0.0) returns a tuple with 3 elements, and color_rgb(RGB) expects 3 separate arguments. Try with:
R, G, B = colorsys.hsv_to_rgb(h, s, 0.0)
pt.setFill(color_rgb(R, G, B))
Reply
#3
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
Reply
#4
You may try casting the r, g and b values to integer values.
Better yet, try to search for documentation or examples for the module you are using.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020