generate-icons.py 文件源码

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

项目:sc-controller 作者: kozec 项目源码 文件源码
def recolor(tree, add):
    """ Recursive part of recolor_strokes and recolor_background """
    for child in tree:
        if 'style' in child.attrib:
            styles = { a : b
                for (a, b) in (
                    x.split(":", 1)
                    for x in child.attrib['style'].split(';')
                    if ":" in x
                )}
            if "fill" in styles or "stroke" in styles:
                for key in ("fill", "stroke"):
                    if key in styles:
                        # Convert color to HSV
                        r,g,b,a = html_to_rgb(styles[key])
                        h,s,v = colorsys.rgb_to_hsv(r,g,b)
                        # Shift hue
                        h += add
                        while h > 1.0 : h -= 1.0
                        # Convert it back
                        r,g,b = colorsys.hsv_to_rgb(h,s,v)
                        # Store
                        styles[key] = rgb_to_html(r,g,b)
                child.attrib["style"] = ";".join(( ":".join((x,styles[x])) for x in styles ))
        recolor(child, add)

# Generate different colors for controller icons
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号