import turtle as t
t.Screen().bgcolor('#8A360F')
For above scripts, is there a way that I can set RGB(138, 54, 15) instead of '#8A360F'?
e.g.
t.Screen().bgcolor(RGB(138, 54, 15))
Thanks.
CodePudding user response:
You can Use the :x operator and make a custom formula
def rgb_to_hex(r, g, b):
return ('{:X}{:X}{:X}'). format(r, g, b)
Now call this within the bgcolor function, It works because :x makes normal values become hex values
import turtle as t
t.Screen().bgcolor(rgb_to_hex(100, 120, 90))
CodePudding user response:
You can use it in this way
import turtle as t
t.pencolor(83, 58, 27)
