
    p"h                     P    S r SSKrSSKJrJr  SSKJr  SSKJr   " S S\\5      r	g)a  
The *Drawing* object is the overall container for all SVG
elements. It provides the methods to store the drawing into a file or a
file-like object. If you want to use stylesheets, the reference links
to this stylesheets were also stored (`add_stylesheet`)
in the *Drawing* object.

set/get SVG attributes::

    element['attribute'] = value
    value = element['attribute']

The Drawing object also includes a defs section, add elements to the defs
section by::

    drawing.defs.add(element)

    N)SVGDefs)ElementFactory)
pretty_xmlc                   j   ^  \ rS rSrSrSU 4S jjrU 4S jrSS jrSS jrSS jr	SS jr
S	 rS
rU =r$ )Drawing!   a  This is the SVG drawing represented by the top level *svg* element.

A drawing consists of any number of SVG elements contained within the drawing
element, stored in the *elements* attribute.

A drawing can range from an empty drawing (i.e., no content inside of the drawing),
to a very simple drawing containing a single SVG element such as a *rect*,
to a complex, deeply nested collection of container elements and graphics elements.
c                 L   > [         [        U ]
  " SSU0UD6  Xl        / U l        g)a[  
:param string filename: filesystem filename valid for :func:`open`
:param 2-tuple size: width, height
:param keywords extra: additional svg-attributes for the *SVG* object

Important (and not SVG Attributes) **extra** parameters:

:param string profile: ``'tiny | full'`` - define the SVG baseProfile
:param bool debug: switch validation on/off

sizeN )superr   __init__filename_stylesheets)selfr   r   extra	__class__s       B/var/www/html/env/lib/python3.13/site-packages/svgwrite/drawing.pyr   Drawing.__init__+   s)     	gt%94959     c                    > U R                   nU R                  nSU R                  S'   SU R                  S'   SU R                  S'   XR                  S'   X R                  S'   [        [        U ]  5       $ )	zxGet the XML representation as `ElementTree` object.

:return: XML `ElementTree` of this object and all its subelements

zhttp://www.w3.org/2000/svgxmlnszhttp://www.w3.org/1999/xlinkzxmlns:xlinkz!http://www.w3.org/2001/xml-eventszxmlns:evbaseProfileversion)profiler   attribsr   r   get_xml)r   r   r   r   s      r   r   Drawing.get_xml;   si     ,,,, <W&D]##FZ &-]#")YWd+--r   c                 >    U R                   R                  XX445        g)a  Add a stylesheet reference.

:param string href: link to stylesheet <URI>
:param string title: name of stylesheet
:param string alternate: ``'yes'|'no'``
:param string media: ``'all | aureal | braille | embossed | handheld | print | projection | screen | tty | tv'``

N)r   append)r   hreftitle	alternatemedias        r   add_stylesheetDrawing.add_stylesheetK   s     	  $y!@Ar   c                     UR                  S5        SnU R                   H  nUR                  XE-  5        M     U R                  5       nU(       a	  [        XcS9nUR                  U5        g)a  Write XML string to `fileobj`.

:param fileobj: a file-like object
:param pretty: True for easy readable output
:param indent: how much to indent if pretty is enabled, by default 2 spaces

Python 3.x - set encoding at the open command::

    open('filename', 'w', encoding='utf-8')
z(<?xml version="1.0" encoding="utf-8" ?>
zR<?xml-stylesheet href="%s" type="text/css" title="%s" alternate="%s" media="%s"?>
)indentN)writer   tostringr   )r   fileobjprettyr(   stylesheet_template
stylesheet
xml_strings          r   r)   Drawing.writeV   sa     	AB
7 ++JMM-:; , ]]_
#J>Jj!r   c                     [         R                  " U R                  SSS9nU R                  X1US9  UR	                  5         g)zWrite the XML string to `self.filename`.

:param pretty: True for easy readable output
:param indent: how much to indent if pretty is enabled, by default 2 spaces
wzutf-8)modeencodingr,   r(   N)ioopenr   r)   close)r   r,   r(   r+   s       r   saveDrawing.saver   s3     ''$--cGD

7&
9r   c                 .    Xl         U R                  X#S9  g)zWrite the XML string to `filename`.

:param string filename: filesystem filename valid for :func:`open`
:param pretty: True for easy readable output
:param indent: how much to indent if pretty is enabled, by default 2 spaces
r5   N)r   r9   )r   r   r,   r(   s       r   saveasDrawing.saveas|   s     !			/r   c                 "    U R                  5       $ )z|Show SVG in IPython, Jupyter Notebook, and Jupyter Lab

:return: unicode XML string of this object and all its subelements

)r*   )r   s    r   
_repr_svg_Drawing._repr_svg_   s     }}r   )r   r   )z
noname.svg)100%rA   )noscreen)F   )__name__
__module____qualname____firstlineno____doc__r   r   r%   r)   r9   r<   r?   __static_attributes____classcell__)r   s   @r   r   r   !   s1     . 	B"80 r   r   )
rI   r6   svgwrite.containerr   r   svgwrite.elementfactoryr   svgwrite.utilsr   r   r   r   r   <module>rO      s(   $ 
 ( 2 %kc> kr   