
    h6.                        S SK Jr  S SKJrJrJrJr  S SKJr  S SK	J
r
Jr  \(       a  S SKJr  S SKJr  SS/rS	r\R$                  rS
r\R*                  rSrSr " S S5      rg)    )annotations)AnyOptionalIteratorTYPE_CHECKING)colors)	validatorconst)Drawing)	DXFEntity
GfxAttribsTRANSPARENCY_BYBLOCK0ByLayer      ?g      c                     \ rS rSr% Sr\rS\S'   \r	S\S'   Sr
S\S	'   \rS\S
'   \rS\S'   SrS\S'   \rS\S'   \\S\\S\S.             S*S jjrS+S jrS+S jrS,S jrS-S.S jjrS-S/S jjr\S+S j5       r\R4                  S0S j5       r\S1S j5       r\R4                  S2S j5       r\S3S j5       r\R4                  S4S j5       r\S+S j5       r\R4                  S0S j5       r\S1S j5       r\R4                  S2S  j5       r\S5S! j5       r\R4                  S6S" j5       r\S7S# j5       r \ R4                  S8S$ j5       r \!S9S% j5       r"S:S& jr#\!S;S' j5       r$\!S<S( j5       r%S)r&g)=r      a   
Represents often used DXF attributes of graphical entities.

Args:
    layer (str): layer name as string
    color (int): :ref:`ACI` color value as integer
    rgb: RGB true color (red, green, blue) tuple, each channel value in the
        range from 0 to 255, ``None`` for not set
    linetype (str): linetype name, does not check if the linetype exist!
    lineweight (int):  see :ref:`lineweights` documentation for valid values
    transparency (float): transparency value in the range from 0.0 to 1.0,
        where 0.0 is opaque and 1.0 if fully transparent, -1.0 for
        transparency by block, ``None`` for transparency by layer
    ltscale (float): linetype scaling factor > 0.0, default factor is 1.0

Raises:
    DXFValueError: invalid attribute value

str_layerint
_aci_colorNOptional[colors.RGB]_true_color	_linetype_lineweightOptional[float]_transparencyfloat_ltscalelayercolorrgblinetype
lineweighttransparencyltscalec               X    Xl         X l        X0l        X@l        XPl        X`l        Xpl        g )Nr    )selfr!   r"   r#   r$   r%   r&   r'   s           B/var/www/html/env/lib/python3.13/site-packages/ezdxf/gfxattribs.py__init__GfxAttribs.__init__5   s(     

 $(    c                   / nU R                   [        :w  a  UR                  SU R                    S35        U R                  [        :w  a  UR                  SU R                   35        U R
                  b  UR                  SU R
                   35        U R                  [        :w  a  UR                  SU R                   S35        U R                  [        :w  a  UR                  SU R                   35        U R                  b(  UR                  S[        U R                  S5       35        U R                  [        :w  a(  UR                  S	[        U R                  S5       35        S
R                  U5      $ )Nzlayer=''zcolor=zrgb=z
linetype='zlineweight=ztransparency=   zltscale=z, )r   DEFAULT_LAYERappendr   DEFAULT_ACI_COLORr   r   DEFAULT_LINETYPEr   DEFAULT_LINEWEIGHTr   roundr   DEFAULT_LTSCALEjoin)r)   ss     r*   __str__GfxAttribs.__str__H   s-   ;;-'HHwt{{m1-.??//HHvdoo./0'HHtD,,-./>>--HHz$..!13411HH{4#3#3"456)HH}U4+=+=q%A$BCD==O+HHxdmmQ 789:yy|r-   c                V    U R                   R                   SU R                  5        S3$ )N())	__class____name__r:   r)   s    r*   __repr__GfxAttribs.__repr__[   s'    ..))*!DLLN+;1==r-   c                4    [        U R                  5       5      $ )zReturns iter(self).)iteritemsrA   s    r*   __iter__GfxAttribs.__iter__^   s    DJJL!!r-   c                   / nU(       d  U R                   [        :w  a  UR                  SU R                   45        U(       d  U R                  [        :w  a  UR                  SU R                  45        U R
                  b1  UR                  S[        R                  " U R
                  5      45        U(       d  U R                  [        :w  a  UR                  SU R                  45        U(       d  U R                  [        :w  a  UR                  SU R                  45        U R                  bg  U R                  [        :X  a"  UR                  S[        R                  45        O1UR                  S[        R                  " U R                  5      45        U(       d  U R                   ["        :w  a  UR                  SU R                   45        U$ )a   Returns the DXF attributes as list of name, value pairs, returns
also the default values if argument `default_values` is ``True``.
The true_color and transparency attributes do not have default values,
the absence of these attributes is the default value.
r!   r"   
true_colorr$   r%   r&   r'   )r   r1   r2   r   r3   r   r   rgb2intr   r4   r   r5   r%   r   r   float2transparencyr   r7   )r)   default_valuesdatas      r*   rF   GfxAttribs.itemsb   sJ    ')T[[M9KK$++./T__0AAKK$//23'KKv~~d6F6F'GHIT^^/??KKT^^45T--1CCKKt78)!!%99^V-H-HIJ&11$2D2DE T]]o=KKDMM23r-   c                6    [        U R                  U5      5      $ )zReturns the DXF attributes as :class:`dict`, returns also the
default values if argument `default_values` is ``True``.
The true_color and transparency attributes do not have default values,
the absence of these attributes is the default value.
)dictrF   )r)   rM   s     r*   asdictGfxAttribs.asdict   s     DJJ~.//r-   c                    U R                   $ )z
layer name)r   rA   s    r*   r!   GfxAttribs.layer   s     {{r-   c                z    [         R                  " U5      (       a  Xl        g [        R                  " SU S35      e)Nzinvalid layer name 'r/   )r	   is_valid_layer_namer   r
   DXFValueErrorr)   names     r*   r!   rU      s3    ((..K%%(<TF!&DEEr-   c                    U R                   $ )z:ref:`ACI` color value)r   rA   s    r*   r"   GfxAttribs.color   s     r-   c                z    [         R                  " U5      (       a  Xl        g [        R                  " SU S35      e)Nzinvalid ACI color value 'r/   )r	   is_valid_aci_colorr   r
   rX   r)   values     r*   r"   r\      s3    ''..#O%%(A%&JKKr-   c                    U R                   $ )zBtrue color value as (red, green, blue) tuple, ``None`` for not set)r   rA   s    r*   r#   GfxAttribs.rgb        r-   c                    Uc  S U l         g [        R                  " U5      (       a  Xl         g [        R                  " SU S35      e)Nzinvalid true color value 'r/   )r   r	   is_valid_rgbr
   rX   r_   s     r*   r#   rb      sA    =#D##E**$%%(B5'&KLLr-   c                    U R                   $ )zlinetype name)r   rA   s    r*   r$   GfxAttribs.linetype   s     ~~r-   c                z    [         R                  " U5      (       a  Xl        g [        R                  " SU S35      e)Nzinvalid linetype name 'r/   )r	   is_valid_table_namer   r
   rX   rY   s     r*   r$   rg      s3    ((..!N%%(?vQ&GHHr-   c                    U R                   $ )r%   )r   rA   s    r*   r%   GfxAttribs.lineweight   rc   r-   c                z    [         R                  " U5      (       a  Xl        g [        R                  " SU S35      e)Nzinvalid lineweight value 'r/   )r	   is_valid_lineweightr   r
   rX   r_   s     r*   r%   rk      s4    ((//$%%(B5'&KLLr-   c                    U R                   $ )ztransparency value from 0.0 for opaque to 1.0 is fully transparent,
-1.0 is for transparency by block and ``None`` if for transparency
by layer
)r   rA   s    r*   r&   GfxAttribs.transparency   s     !!!r-   c                    Uc  S U l         g U[        :X  a  [        U l         g [        U[        5      (       a  SUs=::  a  S::  a
  O  OXl         g [        R
                  " SU S35      e)Ng        r   zinvalid transparency value 'r/   )r   r   
isinstancer   r
   rX   r_   s     r*   r&   ro      sZ    =!%D**!5Du%%3%+>3+>!&%%(DUG1&MNNr-   c                    U R                   $ )zlinetype scaling factor)r   rA   s    r*   r'   GfxAttribs.ltscale   s     }}r-   c                    [        U[        [        45      (       a  US:  a  [        U5      U l        g [        R
                  " SU S35      e)Ngư>zinvalid linetype scale value 'r/   )rq   r   r   r   r
   rX   r_   s     r*   r'   rs      s?    eeS\**!%LDM%%(FugQ&OPPr-   c           
         UR                   nU " UR                  S[        5      UR                  S[        5      UR                  S[        5      UR                  S[
        5      UR                  S[        5      S9$ )a  Load default DXF attributes from the HEADER section.

There is no default true color value and the default transparency is not
stored in the HEADER section.

Loads following header variables:

    - ``$CLAYER`` - current layer name
    - ``$CECOLOR`` - current ACI color
    - ``$CELTYPE`` - current linetype name
    - ``$CELWEIGHT`` - current lineweight
    - ``$CELTSCALE`` - current linetype scaling factor

$CLAYER$CECOLOR$CELTYPE
$CELWEIGHT
$CELTSCALE)r!   r"   r$   r%   r'   )headergetr1   r3   r4   r5   r7   )clsdocr{   s      r*   load_from_headerGfxAttribs.load_from_header   sc      **Y6**Z):;ZZ
,<=zz,0BCJJ|_=
 	
r-   c                Z   UR                   nUR                  R                  U R                  5      (       a  U R                  US'   U R                  US'   UR
                  R                  U R                  5      (       a  U R                  US'   U R                  US'   U R                  US'   g)a  Write DXF attributes as default values to the HEADER section.

Writes following header variables:

    - ``$CLAYER`` - current layer name, if a layer table entry exist in `doc`
    - ``$CECOLOR`` - current ACI color
    - ``$CELTYPE`` - current linetype name, if a linetype table entry exist in `doc`
    - ``$CELWEIGHT`` - current lineweight
    - ``$CELTSCALE`` - current linetype scaling factor

rv   rw   rx   ry   rz   N)	r{   layers	has_entryr!   r"   	linetypesr$   r%   r'   )r)   r~   r{   s      r*   write_to_headerGfxAttribs.write_to_header  s     ::

++ $

F9!ZZz==""4==11!%F:#|#|||r-   c                t     UR                  5       nU R                  U5      $ ! [         a
    U " 5       s $ f = f)zKGet the graphical attributes of an `entity` as :class:`GfxAttribs`
object.
)graphic_propertiesAttributeError	from_dict)r}   entityds      r*   from_entityGfxAttribs.from_entity  s>    
	))+A }}Q  	5L	s   # 77c                `   U " 5       nS H  nX1;   d  M
  [        X#X   5        M     SU;   a  [        R                  " US   5      Ul        SU;   a^  US   n[	        U[
        5      (       a  XBl        U$ U[        R                  :X  a  [        Ul        U$ [        R                  " U5      Ul        U$ )a  Construct :class:`GfxAttribs` from a dictionary of raw DXF values.

Supported attributes are:

    - layer: layer name as string
    - color: :ref:`ACI` value as int
    - true_color: raw DXF integer value for RGB colors
    - rgb: RGB tuple of int or ``None``
    - linetype: linetype name as string
    - lineweight: lineweight as int, see basic concept of :ref:`lineweights`
    - transparency: raw DXF integer value of transparency or a float in the
      range from 0.0 to 1.0
    - ltscale: linetype scaling factor as float

)r!   r"   r$   r%   r'   r#   rJ   r&   )	setattrr   int2rgbr#   rq   r   r&   r   transparency2float)r}   r   attribsattrib_namer&   s        r*   r   GfxAttribs.from_dict!  s    " %
K an=
 1 ..<9GKQ^,L,..'3$
 	 !<!<<';$  (.'@'@'N$r-   )r   r   r   r   r   r   r   r"   r!   r$   r%   r'   r#   r&   )r!   r   r"   r   r#   r   r$   r   r%   r   r&   r   r'   r   )returnr   )r   zIterator[tuple[str, Any]])F)r   zlist[tuple[str, Any]])r   dict[str, Any])rZ   r   )r   r   )r`   r   )r   r   )r`   r   )r   r   )r`   r   )r   r   )r`   r   )r~   r   r   r   )r~   z	'Drawing'r   None)r   r   r   r   )r   r   r   r   )'r@   
__module____qualname____firstlineno____doc__r1   r   __annotations__r3   r   r   r4   r   r5   r   r   r7   r   r+   r:   rB   rG   rF   rR   propertyr!   setterr"   r#   r$   r%   r&   r'   classmethodr   r   r   r   __static_attributes__ r-   r*   r   r      sS   (  FC'J'(,K%,%Is%)K)%)M?)%He%
 #&$((,(,(  	
 "   & &&>"B0   \\F F   \\L L     	ZZM M   __I I     M M " " O O   ^^Q Q 
 
0,*     % %r-   N)
__future__r   typingr   r   r   r   ezdxfr   ezdxf.lldxfr	   r
   ezdxf.documentr   ezdxf.entitiesr   __all__r1   BYLAYERr3   r4   LINEWEIGHT_BYLAYERr5   r7   r   r   r   r-   r*   <module>r      sd    # 9 9  (&(/
0 NN  --  o or-   