bg)ddlmZddlmZddddZddd d ZGd d eZGd deZGddeZGddeZ GddeZ GddeZ GddeZ dS)strlist is_stringxMidxMinxMax)centerleftrightYMidYMinYMax)middletopbottomc(eZdZdZd dZdZd dZd S) ViewBoxa The **ViewBox** mixin provides the ability to specify that a given set of graphics stretch to fit a particular container element. The value of the **viewBox** attribute is a list of four numbers **min-x**, **min-y**, **width** and **height**, separated by whitespace and/or a comma, which specify a rectangle in **user space** which should be mapped to the bounds of the viewport established by the given element, taking into account attribute **preserveAspectRatio**. rc2t||||g|d<dS)a~ Specify a rectangle in **user space** (no units allowed) which should be mapped to the bounds of the viewport established by the given element. :param number minx: left border of the viewBox :param number miny: top border of the viewBox :param number width: width of the viewBox :param number height: height of the viewBox viewBoxNr)selfminxminywidthheights `/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/svgwrite/mixins.pyviewboxzViewBox.viewboxs""D$v#>@@Ycd|d<dS)zh Stretch viewBox in x and y direction to fill viewport, does not preserve aspect ratio. nonepreserveAspectRatioN)rs rstretchzViewBox.stretch's'- "###rr rmeetc|jr|dvrtd|zt|t|d||d<dS)a Set the **preserveAspectRatio** attribute. :param string horiz: horizontal alignment ``'left | center | right'`` :param string vert: vertical alignment ``'top | middle | bottom'`` :param string scale: scale method ``'meet | slice'`` ============= ======================================================= Scale methods Description ============= ======================================================= ``'meet'`` preserve aspect ration and zoom to limits of viewBox ``'slice'`` preserve aspect ration and viewBox touch viewport on all bounds, viewBox will extend beyond the bounds of the viewport ============= ======================================================= )r$slicezInvalid scale parameter '%s' r!N)debug ValueError_horiz_vert)rhorizvertscales rfitz ViewBox.fit-sV" : E%'888;eCDD D39%==tee&T "###rN)rrrr)r rr$)__name__ __module__ __qualname____doc__rr#r/r"rrrrs_   A A A A--- UUUUUUrrcFeZdZdZdZd dZd dZd dZdZdZ d Z d Z dS) Transforma| The **Transform** mixin operates on the **transform** attribute. The value of the **transform** attribute is a ``, which is defined as a list of transform definitions, which are applied in the order provided. The individual transform definitions are separated by whitespace and/or a comma. All coordinates are **user space coordinates**. transformNcT|dt||gzdS)z Specifies a translation by **tx** and **ty**. If **ty** is not provided, it is assumed to be zero. :param number tx: user coordinate - no units allowed :param number ty: user coordinate - no units allowed z translate(%s)N_add_transformationr)rtxtys r translatezTransform.translateLs/   7RH3F3F!FGGGGGrcT|dt||gzdS)ac Specifies a rotation by **angle** degrees about a given point. If optional parameter **center** are not supplied, the rotate is about the origin of the current user coordinate system. :param number angle: rotate-angle in degrees :param 2-tuple center: rotate-center as user coordinate - no units allowed z rotate(%s)Nr8)rangler s rrotatezTransform.rotateVs/   %0J0J!JKKKKKrcT|dt||gzdS)a Specifies a scale operation by **sx** and **sy**. If **sy** is not provided, it is assumed to be equal to **sx**. :param number sx: scalar factor x-axis, no units allowed :param number sy: scalar factor y-axis, no units allowed z scale(%s)Nr8)rsxsys rr.zTransform.scalebs/   wBx/@/@!@AAAAArc6|d|zdS)z Specifies a skew transformation along the x-axis. :param number angle: skew-angle in degrees, no units allowed z skewX(%s)Nr9rr>s rskewXzTransform.skewXm#   u!455555rc6|d|zdS)z Specifies a skew transformation along the y-axis. :param number angle: skew-angle in degrees, no units allowed z skewY(%s)NrDrEs rskewYzTransform.skewYurGrc \|dt||||||gzdS)Nz matrix(%s)r8)rabcdefs rmatrixzTransform.matrix}s6   !Q1a9K0M0M!MNNNNNrc|j|jd}|d|||j<dS)Nr')attribsget transformnamestrip)r new_transform old_transforms rr9zTransform._add_transformationsF (();R@@ /<}}mm$L#S#S#U#UT    r)N) r0r1r2r3rVr<r?r.rFrIrQr9r"rrr5r5Bs MHHHH L L L L B B B B666666OOOVVVVVrr5c&eZdZdZdZddZdZdS)XLinkz XLink mixin c<||_|dS)a  Create a reference to **element**. :param element: if element is a `string` its the **id** name of the referenced element, if element is a **BaseElement** class the **id** SVG Attribute is used to create the reference. N)href update_id)relements rset_hrefzXLink.set_hrefs!  rNcB|||d<|||d<|||d<|||d<dSdS)zA Set XLink attributes (for `href` use :meth:`set_href`). Nz xlink:rolez xlink:arcrolez xlink:titlez xlink:showr")rtitleshowrolearcroles r set_xlinkzXLink.set_xlinksR  !%D   $+D !  "'D   !%D     rct|dsdSt|jr|j}n|j}||jd<dS)Nr]z xlink:href)hasattrrr]get_irirT)ridstrs rr^zXLink.update_idsYtV$$  F TY   (IEEI%%''E%* \"""r)NNNN)r0r1r2r3r`rfr^r"rrr[r[sL    & & & &+++++rr[c.eZdZdZddZ ddZddZdS) Presentationz8 Helper methods to set presentation attributes. Nc~|,t|r||d<n||d<|||d<|||d<|S)zS Set SVG Properties **fill**, **fill-rule** and **fill-opacity**. Nfillz fill-rulez fill-opacityrget_paint_server)rcolorruleopacitys rrnzPresentation.fills_   8$V $5577V   $D   #*D  rc|,t|r||d<n||d<|||d<|||d<|||d<|||d<|||d<|S)z Set SVG Properties **stroke**, **stroke-width**, **stroke-opacity**, **stroke-linecap** and **stroke-miterlimit**. Nstrokez stroke-widthzstroke-opacityzstroke-linecapzstroke-linejoinzstroke-miterlimitro)rrqrrslinecaplinejoin miterlimits rruzPresentation.strokes   :!&X!&!7!7!9!9X  #(D  %,D! "  %,D! "  &.D" #  !(2D$ % rc>|t|d|d<|||d<|S)at Set SVG Properties **stroke-dashoffset** and **stroke-dasharray**. Where *dasharray* specify the lengths of alternating dashes and gaps as of or values or a of comma and/or white space separated or . (e.g. as dasharray=[1, 0.5] or as dasharray='1 0.5') Nr'zstroke-dasharrayzstroke-dashoffsetr)r dasharrayoffsets rrzzPresentation.dasharrays5  '.y#'>'>D# $  (.D$ % r)NNN)NNNNNNNN)r0r1r2r3rnrurzr"rrrlrlsd DH)-2      rrlceZdZdZddZdS) MediaGroupz8 Helper methods to set media group attributes. Nc"|||d<|||d<|S)zV Set SVG Properties **viewport-fill** and **viewport-fill-opacity**. Nz viewport-fillzviewport-fill-opacityr")rrqrss r viewport_fillzMediaGroup.viewport_fills*  $)D !  ,3D( ) rr|)r0r1r2r3rr"rrr~r~s2      rr~ceZdZdZdZdS)Markersz3 Helper methods to set marker attributes. cd}t|r|||d<dS |\}}}|r|||d<|r|||d<|r|||d<dSdS#ttf$r|||d<YdSwxYw)a Set markers for line elements (line, polygon, polyline, path) to values specified by `markers`. * if `markers` is a 3-tuple: * attribute 'marker-start' = markers[0] * attribute 'marker-mid' = markers[1] * attribute 'marker-end' = markers[2] * `markers` is a `string` or a `Marker` class: * attribute 'marker' = `FuncIRI` of markers c@t|rd|zSd|dzS)Nzurl(%s)zurl(#%s)idr)values r get_funciriz(Markers.set_markers..get_funciri s. 0 5(("E$K//rmarkerz marker-startz marker-midz marker-endN)r TypeErrorKeyError)rmarkersr start_marker mid_marker end_markers r set_markerszMarkers.set_markerss  0 0 0 W   6([11DNNN 67>4 j*E+6;|+D+DD(A)4Z)@)@D&A)4Z)@)@D&&&AAx( 6 6 6!,W!5!5X 6s6ABBN)r0r1r2r3rr"rrrrs-$6$6$6$6$6rrceZdZddZdS)Clippingautoc *d|d|d|d|d |d<dS)z- Set SVG Property **clip**. zrect(,)clipNr")rrr rr s r clip_rectzClipping.clip_rect%s, /2cc555&&&$$$GV rN)rrrr)r0r1r2rr"rrrr$s.HHHHHHrrN) svgwrite.utilsrrr*r+objectrr5r[rlr~rrr"rrrs#"""""$$$$$$FV < <6F ; ;1U1U1U1U1Uf1U1U1Uf@V@V@V@V@V@V@V@VF!+!+!+!+!+F!+!+!+H:::::6:::z$)6)6)6)6)6f)6)6)6XHHHHHvHHHHHr