Reputation: 3845
I have a function that returns a float from 0 to 255. I would like to make a gradient in red color from this, but I need a string in "#FFFFFF" format. Is there a function for that?
Upvotes: 5
Views: 2441
Reputation: 752
def rgbtohex(r,g,b): return "#%02X%02X%02X" % (r,g,b)
Upvotes: 3
Reputation: 994251
You could use:
"#%02X0000" % x
Upvotes: 12