utility.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:railgun 作者: xin-xinhanggao 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号