
    h(#                    4   % S SK Jr  S SKJrJrJr  S SKJrJr  S SK	r
S SKJr  S SKrS SKJr  S SKJrJr  S SKJr  S S	KJr  S S
KJrJr  S SKJrJrJr  \rS\S'   \r S\S'   / SQr!\RD                   " S S5      5       r# " S S\5      r$ " S S\$\S9r%SS jr&g)    )annotations)ABCabstractmethodABCMeta)OptionalIterableN)	TypeAlias)Configuration)
PropertiesBackendProperties)Color)
DXFGraphic)Vec2Matrix44)NumpyPath2dNumpyPoints2dsingle_pathsr	   BkPath2d
BkPoints2d)      ?        r   r   r   g      r   r   r   r   r   r   r   i  r   r   c                  h    \ rS rSr% SrS\S'   S\S'   S\S'   S	rS
\S'   SrS
\S'   SS jrSS jr	Sr
g)	ImageData   a  Image data.

Attributes:
    image: an array of RGBA pixels
    transform: the transformation to apply to the image when drawing
        (the transform from pixel coordinates to wcs)
    pixel_boundary_path: boundary path vertices in pixel coordinates, the image
        coordinate system has an inverted y-axis and the top-left corner is (0, 0)
    remove_outside: remove image outside the clipping boundary if ``True`` otherwise
        remove image inside the clipping boundary

z
np.ndarrayimager   	transformr   pixel_boundary_pathFbooluse_clipping_boundaryTremove_outsidec                8    U R                   R                  tpnX!4$ )z0Returns the image size as tuple (width, height).)r   shape)selfimage_heightimage_width_s       N/var/www/html/env/lib/python3.13/site-packages/ezdxf/addons/drawing/backend.py
image_sizeImageData.image_size4   s    (,

(8(8%A((    c                V    U R                  5       u  pU[        S'   [        [        5      $ )zUReturns the transformation matrix to align the image coordinate system with
the WCS.
   )r(   _IMAGE_FLIP_MATRIXr   )r#   r&   r$   s      r'   flip_matrixImageData.flip_matrix9   s)     //+!-2*++r*    N)returnztuple[int, int])r1   r   )__name__
__module____qualname____firstlineno____doc____annotations__r   r    r(   r.   __static_attributes__r0   r*   r'   r   r      s:     &&"'4'ND)
,r*   r   c                  @   \ rS rSrSr\SS j5       r\SS j5       r\SS j5       r\SS j5       r	\SS j5       r
\SS j5       r\      SS	 j5       r\SS
 j5       r\      SS j5       r\      SS j5       r\SS j5       r\SS j5       r\SS j5       rSrg)BackendInterfaceB   z+Public interface for 2D rendering backends.c                    [         eNNotImplementedErrorr#   configs     r'   	configureBackendInterface.configureE       !!r*   c                    [         er=   r>   r#   entity
propertiess      r'   enter_entityBackendInterface.enter_entityI   
     "!r*   c                    [         er=   r>   )r#   rG   s     r'   exit_entityBackendInterface.exit_entityN   rD   r*   c                    [         er=   r>   r#   colors     r'   set_backgroundBackendInterface.set_backgroundR   rD   r*   c                    [         er=   r>   r#   posrH   s      r'   
draw_pointBackendInterface.draw_pointV   rD   r*   c                    [         er=   r>   r#   startendrH   s       r'   	draw_lineBackendInterface.draw_lineZ   rD   r*   c                    [         er=   r>   )r#   linesrH   s      r'   draw_solid_lines!BackendInterface.draw_solid_lines^   
     "!r*   c                    [         er=   r>   )r#   pathrH   s      r'   	draw_pathBackendInterface.draw_pathd   rD   r*   c                    [         er=   r>   )r#   pathsrH   s      r'   draw_filled_paths"BackendInterface.draw_filled_pathsh   rc   r*   c                    [         er=   r>   r#   pointsrH   s      r'   draw_filled_polygon$BackendInterface.draw_filled_polygonn   rc   r*   c                    [         er=   r>   r#   
image_datarH   s      r'   
draw_imageBackendInterface.draw_imaget   rD   r*   c                    [         er=   r>   r#   s    r'   clearBackendInterface.clearx   rD   r*   c                    [         er=   r>   rw   s    r'   finalizeBackendInterface.finalize|   rD   r*   r0   NrA   r
   r1   NonerG   r   rH   r   r1   r~   rG   r   r1   r~   rQ   r   r1   r~   rV   r   rH   r   r1   r~   r[   r   r\   r   rH   r   r1   r~   r`   zIterable[tuple[Vec2, Vec2]]rH   r   r1   r~   re   r   rH   r   r1   r~   ri   Iterable[BkPath2d]rH   r   r1   r~   rn   r   rH   r   r1   r~   rs   r   rH   r   r1   r~   r1   r~   )r2   r3   r4   r5   r6   r   rB   rI   rM   rR   rW   r]   ra   rf   rj   ro   rt   rx   r{   r8   r0   r*   r'   r:   r:   B   sO   5" " " " " " " " " " " " "0">O"	" "
 " " "'"5F"	" "
 " ".?"	" "
 " " " " " "r*   r:   c                     \ rS rSrSS jrSS jrSS jrSS jr\SS j5       r	\
SS j5       r\
SS j5       r\
SS	 j5       r      SS
 jrSS jr      SS jr\
      SS j5       r\
SS j5       r\
SS j5       rSS jrSrg) Backend   c                0    / U l         [        5       U l        g r=   )entity_stackr
   rA   rw   s    r'   __init__Backend.__init__   s    AC%2_r*   c                    Xl         g r=   )rA   r@   s     r'   rB   Backend.configure   s    r*   c                <    U R                   R                  X45        g r=   )r   appendrF   s      r'   rI   Backend.enter_entity   s      &!56r*   c                R    U R                   R                  5       u  p#X!L d   S5       eg )Nzentity stack mismatch)r   pop)r#   rG   eps       r'   rM   Backend.exit_entity   s(      $$&{333{r*   c                L    U R                   (       a  U R                   S   S   $ S$ )z%Obtain the current entity being drawnr   N)r   rw   s    r'   current_entityBackend.current_entity   s'     ,0+<+<t  $Q'F$Fr*   c                    [         er=   r>   rP   s     r'   rR   Backend.set_background   rD   r*   c                    [         e)zUDraw a real dimensionless point, because not all backends support
zero-length lines!
r>   rU   s      r'   rW   Backend.draw_point   s
    
 "!r*   c                    [         er=   r>   rZ   s       r'   r]   Backend.draw_line   rD   r*   c                    U H@  u  p4UR                  U5      (       a  U R                  X25        M.  U R                  X4U5        MB     g)zDFast method to draw a bunch of solid lines with the same properties.N)iscloserW   r]   )r#   r`   rH   sr   s        r'   ra   Backend.draw_solid_lines   s7     DAyy||.qZ0	 r*   c                    [        U5      (       aU  [        UR                  U R                  R                  S95      n[        U5      nU H  nU R                  XEU5        UnM     gg)a8  Draw an outline path (connected string of line segments and Bezier
curves).

The :meth:`draw_path` implementation is a fall-back implementation
which approximates Bezier curves by flattening as line segments.
Backends can override this method if better path drawing functionality
is available for that backend.

distanceN)leniter
flatteningrA   max_flattening_distancenextr]   )r#   re   rH   verticesprevvertexs         r'   rf   Backend.draw_path   s\     t99)L)LMH >D"tZ8 # r*   c           	         U H?  nU R                  [        UR                  U R                  R                  S95      U5        MA     g)a  Draw multiple filled paths (connected string of line segments and
Bezier curves).

The current implementation passes these paths to the backend, all backends
included in ezdxf handle holes by the even-odd method.  If a backend requires
oriented paths (exterior paths in counter-clockwise and holes in clockwise
orientation) use the function :func:`oriented_paths` to separate and orient the
input paths.

The default implementation draws all paths as filled polygons.

Args:
    paths: sequence of paths
    properties: HATCH properties

r   N)ro   r   r   rA   r   )r#   ri   rH   re   s       r'   rj   Backend.draw_filled_paths   sA    & D$$OOT[[-P-POQ 	 r*   c                    [         e)zFill a polygon whose outline is defined by the given points.
Used to draw entities with simple outlines where :meth:`draw_path` may
be an inefficient way to draw such a polygon.
r>   rm   s      r'   ro   Backend.draw_filled_polygon   s
     "!r*   c                    [         e)z$Draw an image with the given pixels.r>   rr   s      r'   rt   Backend.draw_image   rK   r*   c                    [         e)zClear the canvas. Does not reset the internal state of the backend.
Make sure that the previous drawing is finished before clearing.

r>   rw   s    r'   rx   Backend.clear   s
     "!r*   c                    g r=   r0   rw   s    r'   r{   Backend.finalize   s    r*   )rA   r   Nr   r}   r   r   )r1   zOptional[DXFGraphic]r   r   r   r   r   r   r   r   )r2   r3   r4   r5   r   rB   rI   rM   propertyr   r   rR   rW   r]   ra   rf   rj   ro   rt   rx   r{   r8   r0   r*   r'   r   r      s    574 G G " " " " " "101>O1	1&'5F	6 " ".?"	" " " " " "r*   r   )	metaclassc                    SSK JnJn  U" [        U 5      5      nU" U5      u  pEU H  nUR	                  5         M     U H  nUR                  5         M     XE4$ )z{Separate paths into exterior paths and holes. Exterior paths are oriented
counter-clockwise, holes are oriented clockwise.
r   )winding_deconstructionmake_polygon_structure)
ezdxf.pathr   r   r   counter_clockwise	clockwise)ri   r   r   polygonsexternal_pathsholesr   s          r'   oriented_pathsr      sX     J%l5&9:H 38<N	 	   r*   )ri   r   r1   z%tuple[list[BkPath2d], list[BkPath2d]])'
__future__r   abcr   r   r   typingr   r   numpynptyping_extensionsr	   dataclassesezdxf.addons.drawing.configr
   ezdxf.addons.drawing.propertiesr   r   ezdxf.addons.drawing.type_hintsr   ezdxf.entitiesr   
ezdxf.mathr   r   ezdxf.npshapesr   r   r   r   r7   r   r-   	dataclassr   r:   r   r   r0   r*   r'   <module>r      s    # , , %  '  5 I 1 % % C C!) !%
I %  , , ,D<"s <"~w' wt!r*   