Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a color from a number

Tags:

python

colors

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?

like image 482
akalenuk Avatar asked Dec 10 '22 22:12

akalenuk


1 Answers

You could use:

"#%02X0000" % x
like image 141
Greg Hewgill Avatar answered Dec 27 '22 00:12

Greg Hewgill