
     h^                         d Z ddlmZ ddlmZmZ ddlmZ  G d de      Z G d deee      Z	 G d	 d
e	      Z
 G d de	      Zy)a	  
Gradients consist of continuously smooth color transitions along a vector
from one color to another, possibly followed by additional transitions along
the same vector to other colors. SVG provides for two types of gradients:
linear gradients and radial gradients.
    )BaseElement)	TransformXLink)	is_stringc                   $     e Zd ZdZd fd	Z xZS )_GradientStopstopc                 X    t        t        | 
  di | ||| d<   ||| d<   ||| d<   y y )Noffsetz
stop-colorzstop-opacity )superr   __init__)selfr   coloropacityextra	__class__s        n/home/developers/rajanand/mypropertyqr-fmb-refixing-v2/venv/lib/python3.12/site-packages/svgwrite/gradients.pyr   z_GradientStop.__init__   sI    mT+4e4#DN!&D#*D      NNN)__name__
__module____qualname__elementnamer   __classcell__r   s   @r   r   r      s    K+ +r   r   c                   F     e Zd ZdZd fd	ZddZd	dZd
dZ fdZ xZ	S )_AbstractGradientgradientTransformc                     t        t        | 
  di | |=t        |      r| j	                  |       y | j	                  |j                                y y )Nr   )r   r   r   r   set_hrefget_iri)r   inheritr   r   s      r   r   z_AbstractGradient.__init__%   sH    /8%8!g&goo/0	 r   c                 ,    | j                         d|S )z( Returns the <FuncIRI> of the gradient.  )get_funciri)r   defaults     r   get_paint_serverz"_AbstractGradient.get_paint_server-   s    **,g66r   c                 B    | j                  t        ||||              | S )a:   Adds a stop-color to the gradient.

        :param offset: is either a <number> (usually ranging from 0 to 1) or
          a `<percentage>` (usually ranging from 0% to 100%) which indicates where
          the gradient stop is placed. Represents a location along the gradient
          vector. For radial gradients, it represents a percentage distance from
          (fx,fy) to the edge of the outermost/largest circle.
        :param color: indicates what color to use at that gradient stop
        :param opacity: defines the opacity of a given gradient stop
        )factory)addr   )r   r   r   r   s       r   add_stop_colorz _AbstractGradient.add_stop_color1   s      	vugtDEr   c                     |d   |d   z
  t        |      dz
  z  }|d   }|D ]$  }| j                  t        |d      ||       ||z  }& | S )z Add stop-colors from colors with linear offset distributuion
        from sweep[0] to sweep[1].

        i.e. colors=['white', 'red', 'blue']
          'white': offset = 0.0
          'red': offset = 0.5
          'blue': offset = 1.0
           r      )lenr,   round)r   colorssweepr   deltar   r   s          r   
add_colorsz_AbstractGradient.add_colors?   sd     qE!H$Vq9q 	Efa 0%AeOF	 r   c                 `    t        | d      r| j                          t        t        |          S )Nhref)hasattr	update_idr   r   get_xml)r   r   s    r   r:   z_AbstractGradient.get_xmlO   s(    4 NN&577r   )N)noner   ))g        g      ?N)
r   r   r   transformnamer   r(   r,   r5   r:   r   r   s   @r   r   r   "   s&    'M17 8 8r   r   c                   (     e Zd ZdZdZd fd	Z xZS )LinearGradientzE Linear gradients are defined by a SVG <linearGradient> element.
    linearGradientc                 z    t        t        | 
  d	d|i| ||d   | d<   |d   | d<   ||d   | d<   |d   | d<   yy)
z
        :param 2-tuple start: start point of the gradient (**x1**, **y1**)
        :param 2-tuple end: end point of the gradient (**x2**, **y2**)
        :param inherit: gradient inherits properties from `inherit` see: **xlink:href**

        r#   Nr   x1r.   y1x2y2r   )r   r>   r   )r   startendr#   r   r   s        r   r   zLinearGradient.__init__Z   s`     	nd,FWFFqDJqDJ?QDJQDJ r   r   r   r   r   __doc__r   r   r   r   s   @r   r>   r>   U   s    "K   r   r>   c                   (     e Zd ZdZdZd fd	Z xZS )RadialGradientzE Radial gradients are defined by a SVG <radialGradient> element.
    radialGradientc                     t        t        | 
  d
d|i| ||d   | d<   |d   | d<   ||| d<   ||d   | d<   |d   | d	<   yy)a-  
        :param 2-tuple center: center point for the gradient (**cx**, **cy**)
        :param r: radius for the gradient
        :param 2-tuple focal: focal point for the radial gradient (**fx**, **fy**)
        :param inherit: gradient inherits properties from `inherit` see: **xlink:href**

        r#   Nr   cxr.   cyrfxfyr   )r   rJ   r   )r   centerrO   focalr#   r   r   s         r   r   zRadialGradient.__init__o   so     	nd,FWFFDJDJ=DIqDJqDJ r   )NNNNrG   r   s   @r   rJ   rJ   j   s    "K" "r   rJ   N)rH   svgwrite.baser   svgwrite.mixinsr   r   svgwrite.utilsr   r   r   r>   rJ   r   r   r   <module>rW      sL    & , $+K +08Y 08f &  *"& "r   