svgparser.py 文件源码

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

项目:freehand-zxcalculus-recognition 作者: emmacaort 项目源码 文件源码
def addPoint(tree,point,pointtype='c'):
    """Draw a point on the XML tree. A function for testing. 

    Args:
        tree (obj): An XML tree.
        newpath (obj): The path to be added.
        pointtype (str): The string of point type. 
    """
    x_str,y_str = str(point[0]),str(point[1])
    root = tree.getroot()
    for pointaddr in root.iter('{http://www.w3.org/2000/svg}g'):
        point = ET.SubElement(pointaddr,'{http://www.w3.org/2000/svg}circle')
        # Offer two colour choice
        if pointtype == 'c':
            point.attrib['style'] = 'fill: #0000ff'
        else:
            point.attrib['style'] = 'fill: #FF0000'
        point.attrib['cx'] = x_str
        point.attrib['cy'] = y_str
        point.attrib['r'] = '0.5'
        point.tail = '\n'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号