
    Ti                         d Z ddlZ	 ddlmZmZmZ n.# e$ r&Zddl	m
Z
  e
j        e          ZeZeZeZY dZ[ndZ[ww xY w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dS )zP
raster.py
------------

Turn 2D vector paths into raster images using `pillow`
    N)Image
ImageChops	ImageDraw   )
exceptions)	ArrayLikeFloatingOptionalUnionTpathztrimesh.path.Path2Dpitchoriginc                    ^|@t          j        |t           j                  }| j        |dz   z                                  n| j                                        dz  | j        d         dz  z
  t          j        t           j                  t          j        t           j                  |It          j        t          j	        | j        f          d          }t          j
        |z            dz   }t          j        |t           j                  }t          |                                          }fd| j        D             }| j        }| j        }	t!          j        d	|
          }
t%          j        |
          }|Tt)          |          }|D ]>}|                    |                                                                d|           ?|s|
S |D ]}|                    ||                                                                         d           |	|         D ]C}|                    ||                                                                         d           D|
S )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
    N)dtyper   i   r   g       @)axisc                 ~    g | ]9}|z
  z                                                       t          j                  :S  )roundastypenpint64).0ir   r   s     M/DATA/AppData/hermes/venv/lib/python3.11/site-packages/trimesh/path/raster.py
<listcomp>zrasterize.<locals>.<listcomp>Q   s>    WWWA!f*%,,..55bh??WWW    1)modesize   )fillwidth)r!   )r   arrayr   extentsmaxbounds
asanyarrayfloat64ptpvstackceiltupletolistdiscreterootenclosure_directedr   newr   Drawintlineflattenpolygon)r   r   r   
resolutionr!   r"   spanr.   roots	enclosureresultdrawcoordsr/   childs    ``            r   	rasterizer?      sn   @ }!*BH===J\Z!^499;;EEL$$&&-E~Q53;/ M%rz222E]6444F vbif 566Q???WTE\**Q.
z:::Jz((**++J XWWWWWWWH IE'I YCj111F>&!!D E

 	F 	FFIIfnn&&--//auIEEEE 	M
  E EXd^++--4466Q???t_ 	E 	EELL%002299;;!LDDDD	E Mr   )NNNTN)__doc__numpyr   PILr   r   r   BaseExceptionE r   ExceptionWrapper_handletypedr   r	   r
   r   r?   r   r   r   <module>rI      s0       
00000000000    *j)!,,GEIJJJJJJ 9 8 8 8 8 8 8 8 8 8 8 8
 /3"&	
V V
V9d*+V YV V V V V Vs   
 >9>