o
    OZŽh®  ã                   @   sž   d Z ddlZddlZddlZej ej e¡¡d Z	ej 
e	d¡Zz
ddlZddlZW n ey8   edƒ Y nw dd„ Zdd„ Zed	krMeƒ  eƒ  dS dS )
aµ   pygame.examples.blit_blends

Blending colors in different ways with different blend modes.

It also shows some tricks with the surfarray.
Including how to do additive blending.


Keyboard Controls
-----------------

* R, G, B - add a bit of Red, Green, or Blue.
* A - Add blend mode
* S - Subtractive blend mode
* M - Multiply blend mode
* = key BLEND_MAX blend mode.
* - key BLEND_MIN blend mode.
* 1, 2, 3, 4 - use different images.

é    NÚdataz$no surfarray for you!  install numpyc               
   C   sÖ  t  ¡  t j ¡  t j d¡} t  |  ¡ ¡}| d¡ t  |  ¡ ¡}| d¡ |}| 	d¡ i }||t j
< t j tj td¡¡|t j< t j tj td¡¡|t j< t j tj td¡¡|t j< | ¡ }| ¡ }i }t j|t j< t j|t j< t j|t j< t j|t j< t j|t j< i }d|t j< d	|t j< d
|t j< d|t j< d|t j< |   |d¡ t j !¡  t j" #¡ }	t$d| %d¡g ƒ d}
|
rå|	 &d¡ t j' (¡ D ]}|j)t j*krÖd}
|j)t j+krßt,ƒ  |j)t j+krî|j-t j.krîd}
qË|j)t j+kr|j-| /¡ v r||j- }| ¡ }qË|j)t j+kr>|j-| /¡ v r>t" "¡ }|  |dd ||j- ¡ t" "¡ }t$d| %d¡g ƒ t$d|| › dƒ qË|j)t j+kr|j-t j0fv r| /¡ D ].}t" "¡ }t1dƒD ]}|  |dd || ¡ q[t" "¡ }|| }t$d|› d|| › dƒ qQqË|j)t j+kr³|j-t j2fv r³t" "¡ }|  |d¡ t" "¡ }t$d| %d¡g ƒ t$d|| › dƒ qË|j)t j+krð|j-t j3krðt" "¡ }t4j5 6|¡}t4j5 6|¡}||7 }~~t" "¡ }t$d| %d¡g ƒ t$d|| › dƒ qË|j)t j+krG|j-t j7fv rGt" "¡ }t4j5 8|¡}t4j5 8|¡}| 9t:j;¡}| 9t:j;¡}||7 }t: <|d¡}t4j5 =||¡ ~~t" "¡ }t$d| %d¡g ƒ t$d|| › dƒ qË|j)t j+kr„|j-t j>t j?t j@fv r„i }d|t j>< d|t j?< d|t j@< t4j5 6|¡}|||j- 7 }~t$d| %d¡g ƒ qË|j)t j+kr|j-t jAkrt$d| %d¡g ƒ qË|j)t j+kr×|j-t jBkr×t" "¡ }| 	d¡ |  |d¡ | 	d¡ t" "¡ }t$d| %d¡g ƒ t$d|| › dƒ qË|   |d¡ t j !¡  |
sÁt  ¡  d S )N)i€  ià  )éd   r   r   )r   é2   r   é   z	chimp.pngz
alien3.gifz
liquid.bmpÚ	BLEND_ADDÚ	BLEND_SUBÚ
BLEND_MULTÚ	BLEND_MAXÚ	BLEND_MIN)r   r   zone pixel is:%s:Té<   Fztime to do:ú:i,  ztime to do :z: is :éÿ   i   é   é   )CÚpgÚinitZmixerÚquitÚdisplayÚset_modeZSurfaceÚget_sizeÚfillZ	set_alphaZK_1ÚimageÚloadÚosÚpathÚjoinÚdata_dirZK_2ZK_3ZK_4ÚconvertZconvert_alphar   ZK_ar   ZK_sr   ZK_mr	   ZK_EQUALSr
   ZK_MINUSZblitÚflipÚtimeZClockÚprintZget_atZtickÚeventÚgetÚtypeZQUITZKEYDOWNÚusageÚkeyZK_ESCAPEÚkeysZK_tÚrangeZK_oZK_SPACEÚpygameZ	surfarrayZpixels2dZK_zZpixels3dZastypeÚnumpyZuint16ÚminimumZ
blit_arrayZK_rZK_gZK_bZK_pZK_f)ÚscreenZim1Zim2Zim3ZimagesZimg_to_blitZiaaZblitsZblitsnÚclockZgoingr!   Út1Út2ZbkeyÚxZonedoingZim1pZim2pZim1p16Zim2p16Zcolmap© r0   úJ/var/www/auris/lib/python3.10/site-packages/pygame/examples/blit_blends.pyÚmain$   sä   














ö&




€
˜jr2   c                   C   s   t dƒ t dƒ t dƒ d S )Nz'press keys 1-5 to change image to blit.z&A - ADD, S- SUB, M- MULT, - MIN, + MAXz(T - timing test for special blend modes.)r    r0   r0   r0   r1   r$   ½   s   r$   Ú__main__)Ú__doc__r   r(   r   r   r   ÚsplitÚabspathÚ__file__Zmain_dirr   r   Zpygame.surfarrayr)   ÚImportErrorr    r2   r$   Ú__name__r0   r0   r0   r1   Ú<module>   s&   ÿ 
þ