def float_color(value):
"""Get a color to describe the safety level.
Safety level should be a floating number in range [0.0, 1.0].
The color will be more close to green if the safety level is more close
to 1.0, and more close to red if level is more close to 0.0.
:param value: The value of safety level.
:type value: :class:`float`
:return: An html color string, for example, "#ffffff".
"""
h = value / 3.0
l = 0.3
s = 1.0
rgb = map((lambda i: int(i * 255)), colorsys.hls_to_rgb(h, l, s))
return '#%02X%02X%02X' % tuple(rgb)
评论列表
文章目录