U
    Dvf                     @   s^   d dl mZ d dlmZ d dlmZ ddlmZ ddlm	Z	 dd d	D Z
G d
d deZdS )    )TransformPen)etreetostr   )
parse_path)PathBuilderc                 C   s   g | ]}t |qS  r   ).0sr	   r	   B/tmp/pip-unpacked-wheel-qlge9rch/fontTools/svgLib/path/__init__.py
<listcomp>   s     r   )SVGPathr   c                   @   s0   e Zd ZdZd	ddZed
ddZdd ZdS )r   a  Parse SVG ``path`` elements from a file or string, and draw them
    onto a glyph object that supports the FontTools Pen protocol.

    For example, reading from an SVG file and drawing to a Defcon Glyph:

        import defcon
        glyph = defcon.Glyph()
        pen = glyph.getPen()
        svg = SVGPath("path/to/a.svg")
        svg.draw(pen)

    Or reading from a string containing SVG data, using the alternative
    'fromstring' (a class method):

        data = '<?xml version="1.0" ...'
        svg = SVGPath.fromstring(data)
        svg.draw(pen)

    Both constructors can optionally take a 'transform' matrix (6-float
    tuple, or a FontTools Transform object) to modify the draw output.
    Nc                 C   s2   |d krt  | _nt |}| | _|| _d S N)r   ElementTreerootparsegetroot	transform)selffilenamer   treer	   r	   r   __init__"   s
    

zSVGPath.__init__c                 C   s   | |d}t ||_|S )N)r   )r   
fromstringr   )clsdatar   r   r	   r	   r   r   *   s    
zSVGPath.fromstringc                 C   sp   | j rt|| j }t }| j D ]}|| q"|}t|j|jD ]&\}}|r\t||}n|}t	|| qDd S r   )
r   r   r   r   iterZadd_path_from_elementzippathsZ
transformsr   )r   ZpenZpbelZoriginal_penpathr   r	   r	   r   draw0   s    zSVGPath.draw)NN)N)__name__
__module____qualname____doc__r   classmethodr   r!   r	   r	   r	   r   r      s
   
r   N)ZfontTools.pens.transformPenr   ZfontTools.miscr   ZfontTools.misc.textToolsr   parserr   Zshapesr   __all__objectr   r	   r	   r	   r   <module>   s   