
    j                         d Z ddlZ	 ddlmZmZmZ ddlmZmZmZmZ 	 	 	 	 	 dddd	eeedf   d
ee   fdZy# e$ r(Zddl	m
Z
  e
j                  e      ZeZeZeZY dZ[NdZ[ww xY w)zP
raster.py
------------

Turn 2D vector paths into raster images using `pillow`
    N)Image
ImageChops	ImageDraw   )
exceptions)	ArrayLikeFloatingOptionalUnionpathztrimesh.path.Path2Dpitchoriginc                 X   |e|Ft        j                  |t         j                        }| j                  |dz   z  j	                         }n| j                  j	                         dz  }|| j
                  d   |dz  z
  }t        j                  |t         j                        }t        j                  |t         j                        }|Qt        j                  t        j                  | j
                  |f      d      }t        j                  ||z        dz   }t        j                  |t         j                        }t        |j                               }| j                  D cg c]5  }||z
  |z  j                         j                  t         j                        7 }}| j                   }	| j"                  }
t%        j&                  d|      }t)        j*                  |      }|Ft-        |      }|D ]2  }|j/                  |j1                         j                         d	|
       4 |s|S |	D ]p  }|j3                  ||   j1                         j                         d	       |
|   D ]4  }|j3                  ||   j1                         j                         d       6 r |S c c}w )aI  
    Rasterize a Path2D object into a boolean image ("mode 1").

    Parameters
    ------------
    path : Path2D
      Original geometry
    pitch : float or (2,) float
      Length(s) in model space of pixel edges
    origin : (2,) float
      Origin position in model space
    resolution : (2,) int
      Resolution in pixel space
    fill :  bool
      If True will return closed regions as filled
    width : int
      If not None will draw outline this wide in pixels

    Returns
    ------------
    raster : PIL.Image
      Rasterized version of input as `mode 1` image
    )dtyper   i   r   g       @)axis1)modesize   )fillwidth)r   )nparrayint64extentsmaxbounds
asanyarrayfloat64ptpvstackceiltupletolistdiscreteroundastyperootenclosure_directedr   newr   Drawintlineflattenpolygon)r   r   r   
resolutionr   r   spanir%   roots	enclosureresultdrawcoordsr(   childs                   @/DATA/.local/lib/python3.12/site-packages/trimesh/path/raster.py	rasterizer:      s0   @ }!*BHH=J\\Z!^499;ELL$$&-E~Q53;/ MM%rzz2E]]64F vvbiif 56Q?WWTE\*Q.
z:Jz((*+J JNWA!f*%,,.55bhh?HW IIE''I YYCj1F>>&!D E
FIIfnn&--/auIE  M
 Xd^++-446Q?t_ELL%00299;!LD %	  M= Xs   (:J')NNNTN)__doc__numpyr   PILr   r   r   BaseExceptionE r   ExceptionWrapper_handletypedr   r	   r
   r   r:        r9   <module>rF      s    
00 9 8
 /3"&	
V
V9d*+V YV   *j))!,GEIJs   
8 A%A  A%