
    iX                       d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ  ej                  d      xZZ ej                  d      xZZd	Zd
 Zd Zd Zd ZdDdZd Z G d d      Z G d dej4                        Z G d dej4                        Z G d d      Z G d dee      Z G d d      Z G d de      Z  G d de e      Z! G d  d!e      Z" G d" d#e"e      Z# G d$ d%e      Z$ G d& d'e$e      Z% G d( d)e      Z& G d* d+e&e      Z'd d gd,d gd,d,gd d,gfZ(g d-Z)d.d gd/d gd/d.gd0d.gd0d/gd/d/gd/d0gd.d0gd.d/gd d/gd d.gd.d.gfZ* G d1 d2      Z+ G d3 d4e+e      Z, G d5 d6      Z- G d7 d8e-e      Z. G d9 d:      Z/ G d; d<e/e      Z0 G d= d>      Z1 G d? d@e1e      Z2 G dA dBej4                        Z3e4dCk(  r ejj                          yy)E    N)draw)draw_py)SRCALPHA)
test_utils)Vector2redgreen	topleftmidtoptoprightmidrightbottomright	midbottom
bottomleftmidleftcenterc                    t        |      D cg c]  }| j                  |df       }}t        |      D cg c]  }| j                  d|f       }}t        |      D cg c]  }| j                  |dz
  |f       }}t        |      D cg c]  }| j                  ||dz
  f       }}||||gS c c}w c c}w c c}w c c}w )zRReturns a list containing lists with the values of the surface's
    borders.
    r      )rangeget_at)	surfacewidthheightx
border_topyborder_leftborder_rightborder_bottoms	            `/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/pygame/tests/draw_test.pyget_border_valuesr"      s     38,?Q'..!Q(?J?38=Aa7>>1a&)AKA<A&MJqGNNEAIq>2JLJ>CElKW^^Q
O4KMK\=AA @AJKs   B1B6 B;C c                 X    | j                         \  }}d|dz
  df|dz
  |dz
  fd|dz
  ffS )zmReturns a tuple with the corner positions of the given surface.

    Clockwise from the top left corner.
    r   r   r   r   )get_size)r   r   r   s      r!   cornersr&   +   sB    
 $$&ME6UQYNUQY
$;a!_MM    c           	          | j                   | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  f	S )zReturns a tuple with each corner, mid, and the center for a given rect.

    Clockwise from the top left corner and ending with the center point.
    r
   )rects    r!   rect_corners_mids_and_centerr*   4   sO     	
 
r'   c              #     K   | j                         \  }}|dz
  |dz
  }}t        |      D ]  }|df}|| j                  |      f  t        d|      D ]  }||f}|| j                  |      f  t        |dz
  dd      D ]  }||f}|| j                  |      f  t        |dz
  dd      D ]  }d|f}|| j                  |      f  yw)zlYields each border position and its color for a given surface.

    Clockwise from the top left corner.
    r   r   N)r%   r   r   )r   r   r   rightbottomr   posr   s           r!   border_pos_and_colorr0   F   s    
 $$&ME6AIvz6E 5\ '!f7>>#&&&' 1f 'aj7>>#&&&' 519b"% '&k7>>#&&&' 6A:q"% '!f7>>#&&&'s   CCc           	         | j                   }|3t        | j                               }t        | j                               }n@t        |j                  |j
                        }t        |j                  |j                        }| j                          |r)|D cg c]  }|D ]  } |||f      |k(  s||f  }	}}n(|D cg c]  }|D ]  } |||f      |k7  s||f  }	}}| j                          |	S c c}}w c c}}w )a  Get all the points of a given color on the surface within the given
    bounds.

    If bounds_rect is None the full surface is checked.
    If match_color is True, all points matching the color are returned,
        otherwise all points not matching the color are returned.
    )
r   r   	get_width
get_heightleftr-   topr.   lockunlock)
r   colorbounds_rectmatch_colorr   x_rangey_ranger   r   ptss
             r!   get_color_pointsr>   f   s     ^^F))+,**,-((+*;*;<););<LLN&S!S161a&>U;R1vSvSS&S!S161a&>U;R1vSvSSNNJ TSs   C71C7C=C=c                    | j                         j                  \  }}||}}d\  }}| j                  }	| j                          t	        |      D ]P  }
t	        |      D ]@  } |	||
f      |k7  st        ||      }t        ||      }t        |
|      }t        |
|      }B R | j                          d|k(  rt        j                  |d      S t        j                  ||f||z
  dz   ||z
  dz   f      S )zCreate a rect to bound all the pixels that don't match surf_color.

    The default_pos parameter is used to position the bounding rect for the
    case where all pixels match the surf_color.
    r,   r,   r,   r$   r   )
get_clipsizer   r6   r   minmaxr7   pygameRect)r   
surf_colordefault_posr   r   xminyminxmaxymaxr   r   r   s               r!   create_bounding_rectrM      s     $$&++ME6$DJD$^^FLLN6] $u 	$Aq!f~+1d|1d|1d|1d|	$$ NN	Tz{{;//;;d|dTkAotd{Q%GHHr'   c                       e Zd ZdZdZy)InvalidBoolz!To help test invalid bool values.N)__name__
__module____qualname____doc____bool__ r'   r!   rO   rO      s
    +Hr'   rO   c                   T   e Zd ZdZ eej                        Z eej                        Z	 eej                        Z eej                        Z eej                        Z eej                         Z eej$                        Z eej(                        Z eej,                        Zy)DrawTestCasez)Base class to test draw module functions.N)rP   rQ   rR   rS   staticmethodr   r)   	draw_rectpolygondraw_polygoncircledraw_circleellipsedraw_ellipsearcdraw_arcline	draw_linelines
draw_linesaalinedraw_aalineaalinesdraw_aalinesrU   r'   r!   rW   rW      s    3TYY'I-Lt{{+K-LDHH%HTYY'Idjj)Jt{{+K-Lr'   rW   c                       e Zd ZdZ eej                        Z eej                        Z eej                        Z eej                        Z	 eej                        Z
y)PythonDrawTestCasez,Base class to test draw_py module functions.N)rP   rQ   rR   rS   rX   r   r[   rc   re   rg   ri   rU   r'   r!   rk   rk      sY    6   4 45L W../Ig001Jw223K 4 45Lr'   rk   c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z y) DrawEllipseMixinzfMixin tests for drawing ellipses.

    This class contains all the general ellipse drawing tests.
    c                     | j                  t        j                  d      dt        j                  dd      d      }| j	                  |t        j                         y)z.Ensures draw ellipse accepts the correct args.   rp   r   
   r   2   r$   rp      r   Nr_   rE   SurfacerF   assertIsInstanceselfr9   s     r!   test_ellipse__argsz#DrawEllipseMixin.test_ellipse__args   sF    ''NN6"NFKK4OQR
 	k6;;7r'   c                     | j                  t        j                  d      dt        j                  dd            }| j	                  |t        j                         y)z6Ensures draw ellipse accepts the args without a width.ru   ru   r   r   r   c   r   r   Nrv   ry   s     r!    test_ellipse__args_without_widthz1DrawEllipseMixin.test_ellipse__args_without_width   sC    ''NN6"M6;;vv3N
 	k6;;7r'   c           	      
   | j                  t        j                  d      dt        j                  dd      d      }| j	                  |t        j                         | j                  |t        j                  dddd             y	)
z:Ensures draw ellipse accepts the args with negative width.ro   rq   ru   rp   rt   r,   ru   rp   r   N)r_   rE   rw   rF   rx   assertEqualry   s     r!   &test_ellipse__args_with_negative_widthz7DrawEllipseMixin.test_ellipse__args_with_negative_width   se    ''NN6"NFKK4OQS
 	k6;;7fkk!Q1&=>r'   c                    t        j                  dd      }| j                  t        j                  d      d||j                  dz  dz         }| j                  |t         j                         | j                  t        j                  d      d||j                  dz  dz         }| j                  |t         j                         y)zhEnsures draw ellipse accepts the args with
        width > rect.w // 2 and width > rect.h // 2.
        r$      r   ro   rq   ru   r   N)rE   rF   r_   rw   wrx   hrz   r)   r9   s      r!   'test_ellipse__args_with_width_gt_radiusz8DrawEllipseMixin.test_ellipse__args_with_width_gt_radius   s     {{66*''NN6"ND$&&A+/
 	k6;;7''NN6"ND$&&A+/
 	k6;;7r'   c                 *   t        j                  d      t        j                  d      t        j                  dd      ddt        j                  d      dd	d
g}|D ]4  } | j                  di |}| j                  |t         j                         6 y)z^Ensures draw ellipse accepts the correct kwargs
        with and without a width arg.
        r   yellowr$   rt   r   r   r8   r)   r   ru   r   r   rr      r   r   r   r   r   r8   r)   NrU   )rE   rw   ColorrF   r_   rx   rz   kwargs_listkwargsr9   s       r!   test_ellipse__kwargsz%DrawEllipseMixin.test_ellipse__kwargs   s     ">>&1h/FF3	 ">>&1$$
 " 	<F+$++5f5K!!+v{{;	<r'   c           	          | j                  dt        j                  d      dt        j                  dd            }| j	                  |t        j                         y)z6Ensures draw ellipse's kwargs are not order dependent.r   ru   rp   rt   r   r   r   r   )r8   r   r   r)   Nrv   ry   s     r!   &test_ellipse__kwargs_order_independentz7DrawEllipseMixin.test_ellipse__kwargs_order_independent  sM    ''NN6*VV,	 ( 
 	k6;;7r'   c                    t        j                  d      }| j                  t              5  | j	                  |t        j
                  d            }ddd       | j                  t              5  | j	                  |      }ddd       | j                  t              5  | j	                         }ddd       y# 1 sw Y   gxY w# 1 sw Y   DxY w# 1 sw Y   yxY w)z7Ensures draw ellipse detects any missing required args.r   r   N)rE   rw   assertRaises	TypeErrorr_   r   rz   r   r9   s      r!   test_ellipse__args_missingz+DrawEllipseMixin.test_ellipse__args_missing  s    ..(y) 	J++GV\\%5HIK	J y) 	5++G4K	5 y) 	.++-K	. 	.	J 	J	5 	5	. 	.#   &B7.CC7C CCc                 D   t        j                  d      t        j                  d      t        j                  dd      dd}dD ]N  }t	        |      }|j                  |       | j                  t              5   | j                  d	i |}ddd       P y# 1 sw Y   [xY w)
z9Ensures draw ellipse detects any missing required kwargs.r   ru   r   r   r}   ru   r   r)   r8   r   NrU   )	rE   rw   r   rF   dictpopr   r   r_   rz   r   nameinvalid_kwargsr9   s        r!   test_ellipse__kwargs_missingz-DrawEllipseMixin.test_ellipse__kwargs_missing$  s     ~~f-\\%(KK/	
 1 	BD!&\Nt$""9- B/d//A.AB B		BB B   8BB	c                 t   t        j                  d      }t        j                  d      }t        j                  dd      }| j	                  t
              5  | j                  |||d      }ddd       | j	                  t
              5  | j                  ||dd      }ddd       | j	                  t
              5  | j                  |d|d	      }ddd       | j	                  t
              5  | j                  |||d
      }ddd       y# 1 sw Y   xY w# 1 sw Y   zxY w# 1 sw Y   TxY w# 1 sw Y   yxY w)z/Ensures draw ellipse detects invalid arg types.r}   bluer   1Nr   ru   rp   r      r   ffffff@r   ru   rE   rw   r   rF   r   r   r_   rz   r   r8   r)   r9   s        r!   test_ellipse__arg_invalid_typesz0DrawEllipseMixin.test_ellipse__arg_invalid_types4  s.   ..(V${{66*y) 	G++GUD#FK	G y) 	P++GUOQOK	P y) 	C++GS$BK	C y) 	B++D%qAK	B 	B	G 	G	P 	P	C 	C	B 	Bs0   D
D:D",D.
DD"D+.D7c                 Z   t        j                  d      }t        j                  d      }t        j                  dd      }t         j                  ||dd|d|dd||ddd|||d	dg}|D ]2  }| j	                  t
              5   | j                  di |}d
d
d
       4 y
# 1 sw Y   ?xY w)z1Ensures draw ellipse detects invalid kwarg types.ro   r	   r   r   r   r   r   r   r   r   r   皙?NrU   r   rz   r   r8   r)   r   r   r9   s          r!   !test_ellipse__kwarg_invalid_typesz2DrawEllipseMixin.test_ellipse__kwarg_invalid_typesJ  s    ..(W%{{66* ">>	 #	 #!	  %L'
, " 	:F""9- :/d//9&9: :	:: :s   B!!B*	c                 (   t        j                  d      }t        j                  d      }t        j                  dd      }|||ddd|||ddg}|D ]2  }| j	                  t
              5   | j                  d	i |}ddd       4 y# 1 sw Y   ?xY w)
z1Ensures draw ellipse detects invalid kwarg names.r   cyanr   r}   r   )r   r8   r)   r   invalidr   r8   r)   r   NrU   r   r   s          r!    test_ellipse__kwarg_invalid_namez1DrawEllipseMixin.test_ellipse__kwarg_invalid_namei  s    ..(V${{66* #  %!L	
 " 	:F""9- :/d//9&9: :	:: :s   *BB	c                    t        j                  d      }d}t        j                  dd      }d}||||d}dD ]  }|j                  |       d|k(  r | j                  |fi |}nKd|k(  r | j                  ||fi |}n1d	|k(  r | j                  |||fi |}n | j                  ||||fi |}| j                  |t         j                          y
)z9Ensures draw ellipse accepts a combination of args/kwargsrp   r      r   r   r   r   r   r   r   r   r8   r)   N)rE   rw   rF   r   r_   rx   rz   r   r8   r)   r   r   r   r9   s           r!   test_ellipse__args_and_kwargsz.DrawEllipseMixin.test_ellipse__args_and_kwargs}  s    ..( {{66*$udUS9 	<DJJtD /d//B6BD/d//I&I4/d//OO/d//eVvV!!+v{{;	<r'   c                    d}t        j                  d      }t        j                  d      }d}||t        j                  |d      dd}dD ]t  }|j	                  |       ||d	<   |d
k\  r|n|} | j
                  di |}| j                  |j                  |      |       | j                  |t         j                         v y)z4Ensures draw ellipse accepts different width values.r   whiterp   r   rr   r      r   rt   Nr   ir,   r   r   rr   i  r   r   rU   	rE   r   rw   rF   fillr_   r   r   rx   	rz   r/   surface_colorr   r8   r   r   expected_colorr9   s	            r!    test_ellipse__valid_width_valuesz1DrawEllipseMixin.test_ellipse__valid_width_values  s    W-..(!KKV,	
 6 	<ELL'#F7O&+qjUmN+$++5f5KW^^C0.A!!+v{{;	<r'   c                    d}t        j                  d      }t        j                  d      }t        j                  d      }||ddd}t        j                  |d      |d	f|d   |d
   d
d
ff}|D ]k  }|j	                  |       ||d<    | j
                  di |}| j                  |j                  |      |       | j                  |t         j                         m y)z4Ensures draw ellipse accepts different rect formats.r   r   blackr   Nr   r   r   rp   r   r   r)   rU   r   	rz   r/   r   r   r   r   rectsr)   r9   s	            r!    test_ellipse__valid_rect_formatsz1DrawEllipseMixin.test_ellipse__valid_rect_formats  s    e,W-..($~tVWXS&)C=3q63q61a:PQ 	<DLL'!F6N+$++5f5KW^^C0.A!!+v{{;	<r'   c                    d}t        j                  d      }t        j                  d      }t        j                  d      }|dt        j                  |d      dd}d	d
|j	                  |      |f}|D ]  }|j                  |       ||d<   t        |t              r|j                  |      }n|} | j                  di |}	| j                  |j                  |      |       | j                  |	t         j                          y)z5Ensures draw ellipse accepts different color formats.r   r	   r   r   Nr   r   r   r   r   r   r   r   r   r   r8   rU   )rE   r   rw   rF   map_rgbr   
isinstanceint	unmap_rgbr_   r   r   rx   )
rz   r/   green_colorr   r   r   redsr8   r   r9   s
             r!   !test_ellipse__valid_color_formatsz2DrawEllipseMixin.test_ellipse__valid_color_formats  s    ll7+W-..(KKV,	
 OOK(	
  	<ELL'#F7O%%!(!2!25!9!,+$++5f5KW^^C0.A!!+v{{;	<r'   c                     d}t        j                  d      }|dt        j                  |d      dd}d|fD ]7  }||d<   | j                  t              5   | j
                  d	i |}ddd       9 y# 1 sw Y   DxY w)
z=Ensures draw ellipse handles invalid color formats correctly.r   r   rp   Nr}   r   r   r   r8   rU   )rE   rw   rF   r   r   r_   rz   r/   r   r   r   r9   s         r!   #test_ellipse__invalid_color_formatsz4DrawEllipseMixin.test_ellipse__invalid_color_formats  s    ..(KKV,	
  #Gn 	:N,F7O""9- :/d//9&9: :	:: :   A22A;	c           
          
 g d}g d}d

 fd}
 fd}|D ],  \  }}dD ]"  } ||||       |D ]  \  }}	 ||||||	        $ . y)zTests ellipses of differing sizes on surfaces of differing sizes.

        Checks if the number of sides touching the border of the surface is
        correct.
        )r$   r   r   r   )r   r   r   r   r   r   r   )r         r   c                     t        j                  | |f      }j                  |dd| |f|       t        || |      }|D ]  }j	                  |v         y)z4Test for ellipses with the same size as the surface.r   N)rE   rw   r_   r"   
assertTrue)r   r   border_widthr   bordersborderr8   rz   s         r!   	same_sizez0DrawEllipseMixin.test_ellipse.<locals>.same_size  sa    nneV_5Gguq!UF.C\R (?G! 101r'   c           	          t        j                  | |f      }
j                  |	||| dz
  |dz
  f|       t        || |      }|D cg c]  }	|v  c}j	                  d      }
j                  |d       yc c}w )z;Test for ellipses that aren't the same size as the surface.r   Tru   N)rE   rw   r_   r"   countr   )r   r   r   r4   r5   r   r   r   sides_touchingr8   rz   s            r!   not_same_sizez4DrawEllipseMixin.test_ellipse.<locals>.not_same_size  s    nneV_5GsEAIvz BL (?G =DD&evoDJJ4PN^Q/ Es   A8r   NrU   )rz   left_topsizesr   r   r   r   r   r4   r5   r8   s   `         @r!   test_ellipsezDrawEllipseMixin.test_ellipse  sw     40 		1	0 # 	JME6 & J%6!) JID#!%tSIJJ	Jr'   c                    d}d}d}t        d|z        }t        d|z        }t        j                  ||f      }| j                  |ddd||f|       d}t	        |      D ]  }|j                  ||f      dk(  s|dz  }  t	        |      D ]  }	|j                  |	|f      dk(  s|dz  }  | j                  ||dz         y)z5Test for big ellipse that could overflow in algorithmi  r   g?r   r   r   r   r   N)r   rE   rw   r_   r   r   r   )
rz   r   r   r   x_value_testy_value_testr   colored_pixelsr   r   s
             r!   test_ellipse__big_ellipsez*DrawEllipseMixin.test_ellipse__big_ellipse  s    3<(3<(..%1';Auf0EvNv 	$A~~|Q/0K?!#	$ u 	$A~~q,/0K?!#	$ 	!4r'   c                 H   t        j                  d      }t        j                  d      }t        j                  d      }t        j                  dd      }|j	                         j
                  |_        t        dt        |j                   dz  dz
        D ]  }|j                  |       | j                  ||||       |j                          |j                  }|j                  }|j                  |z   dz
  }t        ||dz         D ]&  }	| j                  |j                  ||	f      ||       ( | j                  |j                  ||dz
  f      ||       | j                  |j                  ||dz   f      ||       |j                  }|j                   |z
  }|j                   dz
  }t        ||dz         D ]&  }	| j                  |j                  ||	f      ||       ( | j                  |j                  ||dz
  f      ||       | j                  |j                  ||dz   f      ||       |j"                  }
|j"                  |z   dz
  }|j$                  }	t        |
|dz         D ]&  }| j                  |j                  ||	f      ||       ( | j                  |j                  |
dz
  |	f      ||       | j                  |j                  |dz   |	f      ||       |j&                  |z
  }
|j&                  dz
  }|j$                  }	t        |
|dz         D ]&  }| j                  |j                  ||	f      ||       ( | j                  |j                  |
dz
  |	f      ||       | j                  |j                  |dz   |	f      ||       |j)                           y)	z1Ensures a thick lined ellipse is drawn correctly.r   r   (   r  r$   )      r   ru   N)rE   r   rw   rF   get_rectr   r   rC   rB   r   r_   r6   centerxr5   r   r   r.   r4   centeryr-   r7   )rz   ellipse_colorr   r   r)   	thicknessr   y_starty_endr   x_startx_ends               r!   test_ellipse__thick_linez)DrawEllipseMixin.test_ellipse__thick_line*  sZ   X.W-..*{{68,&&(//
 q#tyy/Q"6":; 7	ILL'g}dIFLLN AhhGHHy(1,E7EAI. S  A!7	RS W^^Q!,<=}iXW^^Q	N;]IV AkkI-GKK!OE7EAI. S  A!7	RS W^^Q!,<=}iXW^^Q	N;]IV iiGII	)A-EA7EAI. S  A!7	RS W^^Wq[!,<=}iXW^^UQYN;]IV jj9,GJJNEA7EAI. S  A!7	RS W^^Wq[!,<=}iXW^^UQYN;]IVNNo7	r'   c                 V   d}d}t        j                  |dz   |f      }t        j                  dd||      }t        ddd      D ]  }|j	                  d       | j                  |d||       t        |      D ]  }d}d	}t        |dz         D ]b  }	|s)|j                  |	|f      t        j                  d      k(  s-|s1|j                  |	|f      t        j                  d      k(  s[| }|dz  }d ||k  s|||z
  dz
  kD  r| j                  |d
       | j                  |d         y )NP   F   r   r   %   r   BLACKREDFru   r   )	rE   rw   rF   r   r   r_   r   r   r   )
rz   r   r   r   r)   r  r   number_of_changesdrawn_pixelr   s
             r!   test_ellipse__no_holesz'DrawEllipseMixin.test_ellipse__no_holesn  s4   ..%!)V!45{{1a/q"a 	;ILL!gudI>6] ;$%!#uqy) /A'#NNAq62fll56II&#NNAq62fll76KK*5o)Q.)/ y=A(:Q(>$>$$%6:$$%6:;	;r'   c                    t        j                  d      }t        j                  d      }t        j                  d      }t        j                  dd      }|j	                         j
                  |_        t        |j                   dz   dz  }t        ||dz         D ]  }|j                  |       | j                  ||||       |j                          t        |j                  |j                        D ]/  }| j                  |j                  |j                   |f      |       1 t        |j"                  |j$                        D ]/  }| j                  |j                  ||j&                  f      |       1 | j                  |j                  |j                   |j                  dz
  f      |       | j                  |j                  |j                   |j                  dz   f      |       | j                  |j                  |j"                  dz
  |j&                  f      |       | j                  |j                  |j$                  dz   |j&                  f      |       |j)                           y	)
zCEnsures an ellipse with max width (and greater) is drawn correctly.r   r   r  r$   )r     r   ru   rp   N)rE   r   rw   rF   r  r   rC   rB   r   r   r_   r6   r5   r.   r   r   r	  r4   r-   r
  r7   )	rz   r  r   r   r)   max_thicknessr  r   r   s	            r!   test_ellipse__max_widthz(DrawEllipseMixin.test_ellipse__max_width  s   X.W-..*{{68,&&(//dii1,2}ma.?@ 	ILL'g}dIFLLN 488T[[1 S  q0A!BMRS 499djj1 S  DLL0A!BMRS dhhl;<m dkkAo>?
 		At||<=} 

Q=> NN?	r'   c           	         |j                         \  }|j                          fdt        |      D        D ]@  }|j                  |      r|}n|}| j	                  |j                  |      |d| d|        B |j                          y )Nc              3   F   K   | ]  }t              D ]  }||f 
  y wNr   ).0r   r   surf_ws      r!   	<genexpr>z@DrawEllipseMixin._check_1_pixel_sized_ellipse.<locals>.<genexpr>  s%     Iq5=IaQFIFI   !zcollide_rect=z, pos=)r%   r6   r   collidepointr   r   r7   )	rz   r   collide_rectr   r  surf_hr/   r   r$  s	           @r!   _check_1_pixel_sized_ellipsez-DrawEllipseMixin._check_1_pixel_sized_ellipse  s    
 !))+IE&MI 	C ((-!.!.s#~VC59	 	r'   c                 Z   t        j                  d      }t        j                  d      }d\  }}t        j                  ||f      }t        j                  dd      }|j	                         }d}|}	|}
|dz  }|dz  }t        dd	      D ]  }||_        ||_        |d
z    }|dz   }||dz  z
  }||f||f||f||f||
f||f||f||f||f||
f|	|f|	|f|	|f|	|f|	|
ff}|D ]H  }|j                  |       ||_        ||_        | j                  |||       | j                  ||||       J  y)zEnsures an ellipse with a width of 1 is drawn correctly.

        An ellipse with a width of 1 pixel is a vertical line.
        r   r   rr   r   r$   r   r,   ru      rr   r   N)rE   r   rw   rF   copyr   r   r   r   r_   r*  )rz   r  r   r$  r)  r   r)   r(  off_left	off_right
off_bottomcenter_xcenter_y	ellipse_hoff_tophalf_off_tophalf_off_bottom	positionsrect_poss                      r!   test_ellipse__1_pixel_widthz,DrawEllipseMixin.test_ellipse__1_pixel_width  s   
 U+W-..&&!12{{66*yy{ 	
Q;Q; q" &	I&LNDF "A&G&!^,L$	Q7O
 7#<(8$?+:&7#<(8$?+:&G$L)H%O,J'I$ & 	]+''/$!!'=$?11\=-	;&	r'   c                 x   t        j                  d      }t        j                  d      }d\  }}t        j                  ||f      }t        j                  dd|dz   f      }dd|dz  d	f|dz
  d	f|d	ff}|D ]A  }|j	                  |       ||_        | j                  |||       | j                  ||||       C y
)zEnsures an ellipse with a width of 1 is drawn correctly
        when spanning the height of the surface.

        An ellipse with a width of 1 pixel is a vertical line.
        r   r   r,  r$   r   ru   r@   r   r,   r,   NrE   r   rw   rF   r   r   r_   r*  	rz   r  r   r$  r)  r   r)   r8  r9  s	            r!   ,test_ellipse__1_pixel_width_spanning_surfacez=DrawEllipseMixin.test_ellipse__1_pixel_width_spanning_surface  s     U+W-..&&!12{{6Avz?3 q["aZRL
	 " 	HLL'#DLg}d;--}m	r'   c                 Z   t        j                  d      }t        j                  d      }d\  }}t        j                  ||f      }t        j                  dd      }|j	                         }|}d}	|}
|dz  }|dz  }t        dd	      D ]  }||_        ||_        |d
z    }|dz   }||dz  z
  }||	f||	f||	f||	f||	f||f||f||f||f||f||
f||
f||
f||
f||
ff}|D ]H  }|j                  |       ||_        ||_        | j                  |||       | j                  ||||       J  y)zEnsures an ellipse with a height of 1 is drawn correctly.

        An ellipse with a height of 1 pixel is a horizontal line.
        r   r   r   rr   r$   r   r,   ru   r-  rr   r   N)rE   r   rw   rF   r.  r   r   r   r   r_   r*  )rz   r  r   r$  r)  r   r)   r(  r0  r5  r1  r2  r3  	ellipse_wr/  half_off_lefthalf_off_rightr8  r9  s                      r!   test_ellipse__1_pixel_heightz-DrawEllipseMixin.test_ellipse__1_pixel_height'  s   
 U+W-..&&!12{{66*yy{ 	
Q;Q; q" &	I&LNDF #Q'H'1n-M#yA~6N
 7#(7#)G$8$)8$*H%:&
+:&,J'I$ & 	]+''/$!!'=$?11\=-	;&	r'   c                 x   t        j                  d      }t        j                  d      }d\  }}t        j                  ||f      }t        j                  d|dz   df      }ddd	|dz  fd	|dz
  fd	|ff}|D ]A  }|j	                  |       ||_        | j                  |||       | j                  ||||       C y
)zEnsures an ellipse with a height of 1 is drawn correctly
        when spanning the width of the surface.

        An ellipse with a height of 1 pixel is a horizontal line.
        r   r   rA  r$   ru   r   r@   r,   r   r,   Nr=  r>  s	            r!   -test_ellipse__1_pixel_height_spanning_surfacez>DrawEllipseMixin.test_ellipse__1_pixel_height_spanning_surfaced  s     U+W-..&&!12{{6FQJ?3 1!L
	 " 	HLL'#DLg}d;--}m	r'   c                 "   t        j                  d      }t        j                  d      }d\  }}t        j                  ||f      }t        j                  dd      }d}|}d}	|}
d}|dz
  }d}|dz
  }|d	z  }|d	z  }||	f||f||f||f||
f||	f||f||f||f||
f||	f||f||f||f||
f||	f||f||f||f||
f||	f||f||f||f||
ff}|D ]A  }|j	                  |       ||_        | j                  |||       | j                  ||||       C y
)zEnsures an ellipse with a width and height of 1 is drawn correctly.

        An ellipse with a width and height of 1 pixel is a single pixel.
        r   r   rr   rr   r$   r   r,   r   r   ru   Nr=  )rz   r  r   r$  r)  r   r)   r/  r0  r5  r1  	left_edge
right_edgetop_edgebottom_edger2  r3  r8  r9  s                      r!   &test_ellipse__1_pixel_width_and_heightz7DrawEllipseMixin.test_ellipse__1_pixel_width_and_height  s   
 U+W-..&&!12{{66* 	
	aZ
qjQ;Q;
 wx x {#z" !!$
#wx x {#z"!""%$ !!$
#3
	8 " 	HLL'#DLg}d;--}m	r'   c                 v   t        j                  d      }t        j                  d      }dx}}dx}}||f||ff}t        j                  ddd      }|j                         }	|	j	                  |dz  d	z   |dz  d	z         }
t        |	      t        |
      z   D ]  }t        D ]  }|D ]  \  }}t        j                  d
||f      }t        |||       dd	ddt        ||      fD ]P  }|j                  |       | j                  ||||      }t        |||j                        }| j                  ||       R    y)zEnsures draw ellipse returns the correct bounding rect.

        Tests ellipses on and off the surface and a range of width/thickness
        values.
        r   r   r      r   r   r       ru   r   r$   rp   N)rE   r   rw   r  inflater*   RECT_POSITION_ATTRIBUTESrF   setattrrC   r   r_   rM   r   r   )rz   r  rG   	min_width
min_height	max_width
max_heightr   r   	surf_rectbig_rectr/   attrr   r   ellipse_rectr  bounding_rectexpected_rects                      r!   test_ellipse__bounding_rectz,DrawEllipseMixin.test_ellipse__bounding_rect  so    U+\\'*
!""	J!""	JZ(9j*AB..1b1$$&	 $$Y]Q%6
Q8JK/
(23 	GC
 1 G%* GME6#);;vv#GLL$4&'Aq#eV2D%E G	Z0(,(9(9#]L)) )=#Z1E1E) ((FG	GG	Gr'   c                 2   dx}t        j                  d      }t        j                  d      }t        j                  |f      }|j                  |       t        j                  dd      }|j                         j                  |_        |j                         }dD ]  }t        |      D ]  }||_        |j                  d       |j                  |       | j                  ||||       t        |||      }	|j                  |       |j                  |       | j                  ||||       |j                          fdt        |      D        D ]-  }
|
|	v r|}n|}| j                  |j                  |
      ||
       / |j!                            y)	zuEnsures draw ellipse respects a surface's clip area.

        Tests drawing the ellipse filled and unfilled.
        r   r   r	   r$      rd  r   Nc              3   F   K   | ]  }t              D ]  }||f 
  y wr!  r"  r#  r   r   surfhs      r!   r%  z>DrawEllipseMixin.test_ellipse__surface_clip.<locals>.<genexpr>  %     NauNAAq6N6Nr&  )rE   r   rw   r   rF   r  r   r.  r*   set_clipr_   r>   r6   r   r   r   r7   )rz   surfwr  r   r   	clip_rectpos_rectr   r   expected_ptsptr   rg  s               @r!   test_ellipse__surface_clipz+DrawEllipseMixin.test_ellipse__surface_clip  ss   
 U+W-..%0]#KK1	"++-44	>># 	!E6yA ! #)  &]+!!'=(EJ/	R ]+  +!!'=(EJ O5<N MB\))6)6$$W^^B%7LM  9!	!r'   N)!rP   rQ   rR   rS   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r*  r:  r?  rE  rH  rO  ra  ro  rU   r'   r!   rm   rm      s    
88?8"<.	8.B B,:>:(<,<.<$<B:"'JR5&BH;2(T2;z@;z@>@)GV-!r'   rm   c                       e Zd ZdZy)DrawEllipseTestzTest draw module function ellipse.

    This class inherits the general tests from DrawEllipseMixin. It is also
    the class to add any draw.ellipse specific tests to.
    NrP   rQ   rR   rS   rU   r'   r!   rq  rq        r'   rq  c                   4    e Zd ZdZdZed        Zed        Zy)BaseLineMixinzMixin base for drawing various lines.

    This class contains general helper methods and setup for testing the
    different types of lines.
    )r   r   r   )r   r   r   )r   r   r   )r   r   r   )r   r   r   r   r   r   c                      g } dD ]g  }dD ]`  }dt         fD ]S  }t        j                  j                  |||      }| j	                  |       | j	                  |j                                U b i | S )N))1   rx  rs   rs   )      r   rS  r   )r   rE   displayset_modeappendconvert_alpha)surfacesrB   depthflagsr   s        r!   _create_surfaceszBaseLineMixin._create_surfacesG  sz     ( 	=D( =] =E$nn55dE5IGOOG,OOG$9$9$;<==	= r'   c              #      K   t        |       D ]=  }|| j                  | j                  fv r| j                  |f || j                  f ? y wr!  )r*   r   r   )r)   rn  s     r!   _rect_lineszBaseLineMixin._rect_linesS  sR      /t4 	%BdllDKK00<<$$t||$$	%s   AAN)rP   rQ   rR   rS   COLORSrX   r  r  rU   r'   r!   ru  ru  5  s6    	F 	 	 % %r'   ru  c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)	LineMixinznMixin test for drawing a single line.

    This class contains all the general single line drawing tests.
    c                     | j                  t        j                  d      dddd      }| j                  |t        j                         y)z+Ensures draw line accepts the correct args.ro   rq   r$   r   r   Nrc   rE   rw   rx   rF   ry   s     r!   test_line__argszLineMixin.test_line__argsh  s:    nnNN6"NFFA
 	k6;;7r'   c                     | j                  t        j                  d      ddd      }| j                  |t        j                         y)z3Ensures draw line accepts the args without a width.r}   r   r   r   rs   r$   Nr  ry   s     r!   test_line__args_without_widthz'LineMixin.test_line__args_without_widthp  s8    nnNN6"M66
 	k6;;7r'   c                     t        j                  d      }t        j                  d      }d}d}||||dd||||dg}|D ]4  } | j                  d	i |}| j	                  |t         j
                         6 y)
z[Ensures draw line accepts the correct kwargs
        with and without a width arg.
        r   r   r   r}   r   r   r8   	start_posend_posr   r   r8   r  r  NrU   )rE   rw   r   rc   rx   rF   rz   r   r8   r  r  r   r   r9   s           r!   test_line__kwargszLineMixin.test_line__kwargsx  s     ..(X&	 #&" #&"	
  " 	<F($..262K!!+v{{;	<r'   c           	          | j                  ddddt        j                  d            }| j                  |t        j                         y)z3Ensures draw line's kwargs are not order dependent.r   r   ru   rr   r   r   rt   )r  r  r   r8   r   Nr  ry   s     r!   #test_line__kwargs_order_independentz-LineMixin.test_line__kwargs_order_independent  sC    nnNN6* % 
 	k6;;7r'   c                 4   t        j                  d      }t        j                  d      }| j                  t              5  | j                  ||d      }ddd       | j                  t              5  | j                  ||      }ddd       | j                  t              5  | j                  |      }ddd       | j                  t              5  | j                         }ddd       y# 1 sw Y   xY w# 1 sw Y   sxY w# 1 sw Y   PxY w# 1 sw Y   yxY w)z4Ensures draw line detects any missing required args.r   r   r$   NrE   rw   r   r   r   rc   rz   r   r8   r9   s       r!   test_line__args_missingz!LineMixin.test_line__args_missing  s    ..(V$y) 	A..%@K	A y) 	9..%8K	9 y) 	2..1K	2 y) 	+..*K	+ 	+	A 	A	9 	9	2 	2	+ 	+0    C*1C6!DD*C36C?DDc                    t        j                  d      t        j                  d      dddd}dD ]N  }t        |      }|j	                  |       | j                  t              5   | j                  d	i |}ddd       P y# 1 sw Y   [xY w)
z6Ensures draw line detects any missing required kwargs.rt   r   r   r}   r   r  r  r  r8   r   NrU   )rE   rw   r   r   r   r   r   rc   r   s        r!   test_line__kwargs_missingz#LineMixin.test_line__kwargs_missing  s     ~~f-\\%(
 A 	?D!&\Nt$""9- ?,dnn>~>? ?		?? ?   %BB	c                    t        j                  d      }t        j                  d      }d}d}| j                  t              5  | j                  ||||d      }ddd       | j                  t              5  | j                  |||d      }ddd       | j                  t              5  | j                  ||d|      }ddd       | j                  t              5  | j                  |d	||      }ddd       | j                  t              5  | j                  d
|||      }ddd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   `xY w# 1 sw Y   yxY w)z,Ensures draw line detects invalid arg types.r}   r   r   r   r   Nr   r   r   r   ru   rp   r   r  rz   r   r8   r  r  r9   s         r!   test_line__arg_invalid_typesz&LineMixin.test_line__arg_invalid_types  s_   ..(V$	y) 	R..%GSQK	R y) 	O..%INK	O y) 	H..%wGK	H y) 	K..#y'JK	K y) 	R..uiQK	R 	R!	R 	R	O 	O	H 	H	K 	K	R 	Rs<   D+7D7)EEE+D47E EEE$c           
      P   t        j                  d      }t        j                  d      }d}d}d}t         j                  ||||d|d|||d||d||d|||d	|d||||d
dg}|D ]2  }| j                  t              5   | j
                  di |}ddd       4 y# 1 sw Y   ?xY w)z.Ensures draw line detects invalid kwarg types.ro   r	   r   ru   r   r   r  r   r   r   333333?NrU   r  )	rz   r   r8   r  r  r   r   r   r9   s	            r!   test_line__kwarg_invalid_typesz(LineMixin.test_line__kwarg_invalid_types  s    ..(W%	 ">>&" #&" #&" #& #&";$
L " 	7F""9- 7,dnn6v67 7	77 7s   >BB%	c                    t        j                  d      }t        j                  d      }d}d}||||ddd||||ddg}|D ]2  }| j                  t              5   | j
                  d	i |}ddd       4 y# 1 sw Y   ?xY w)
z.Ensures draw line detects invalid kwarg names.r   r   r   r  r   )r   r8   r  r  r   r   r   r8   r  r  r   NrU   r  r  s           r!   test_line__kwarg_invalid_namez'LineMixin.test_line__kwarg_invalid_name  s    ..(V$	 #&" #&"
$ " 	7F""9- 7,dnn6v67 7	77 7   A88B	c                    t        j                  d      }d}d}d}d}|||||d}dD ]  }|j                  |       d|k(  r | j                  |fi |}nhd|k(  r | j                  ||fi |}nNd	|k(  r | j                  |||fi |}n3d
|k(  r | j                  ||||fi |}n | j                  |||||fi |}| j	                  |t         j
                          y)z6Ensures draw line accepts a combination of args/kwargsrt   r   r   r   r   r  r   r8   r  r  N)rE   rw   r   rc   rx   rF   )	rz   r   r8   r  r  r   r   r   r9   s	            r!   test_line__args_and_kwargsz$LineMixin.test_line__args_and_kwargs+  s   ..( 	"
 J 	<DJJtD ,dnnW??D,dnnWeFvF$,dnnWeYQ&Qd",dnnUIw:@ -dnnUIwAG !!+v{{;%	<r'   c                    t        j                  d      }t        j                  d      }t        j                  d      }d}|||ddd}dD ]t  }|j                  |       ||d	<   |d
kD  r|n|} | j                  di |}| j                  |j                  |      |       | j                  |t         j                         v y)z1Ensures draw line accepts different width values.r   r   r   r   r}   Nr  ir   r,   r   r   rr   d   r   r   rU   )	rE   r   rw   r   rc   r   r   rx   rF   	rz   
line_colorr   r   r/   r   r   r   r9   s	            r!   test_line__valid_width_valuesz'LineMixin.test_line__valid_width_valuesN  s    \\(+
W-..(
 4 	<ELL'#F7O+019Z-N($..262KW^^C0.A!!+v{{;	<r'   c                    t        j                  d      }t        j                  d      }t        j                  d      }||dddd}d\  }}||f|d	z   |f||d	z   f|d	z   |d	z   ffD ]  }t        t        t
        fD ]s  }|j                  |        ||      |d
<    | j                  di |}	| j                  |j                  ||f      |       | j                  |	t         j                         u  y)z6Ensures draw line accepts different start_pos formats.r   r   r   Nr}   ru   r  r   皙?r  rU   rE   r   rw   tuplelistr   r   rc   r   r   rx   rF   )
rz   r   r   r   r   r   r   r  seq_typer9   s
             r!   "test_line__valid_start_pos_formatsz,LineMixin.test_line__valid_start_pos_formatsf  s   e,W-..(#
 1 a&1s7A,AGq3wC>PQ 		@I"D'2 @]+&.y&9{#,dnn6v6  A!7H%%k6;;?@		@r'   c                    t        j                  d      }t        j                  d      }t        j                  d      }||dddd}d\  }}||f|d	z   |f||d	z   f|d	z   |d	z   ffD ]  }t        t        t
        fD ]s  }|j                  |        ||      |d
<    | j                  di |}	| j                  |j                  ||f      |       | j                  |	t         j                         u  y)z4Ensures draw line accepts different end_pos formats.r   r   r   r   Nru   r  r}   g?r  rU   r  )
rz   r   r   r   r   r   r   r  r  r9   s
             r!    test_line__valid_end_pos_formatsz*LineMixin.test_line__valid_end_pos_formats  s   e,W-..(#
 1 AS!q!c'lQWa#g<NO 		@G"D'2 @]+$,W$5y!,dnn6v6  A!7H%%k6;;?@		@r'   c                    t        j                  d      t        j                  d      dddd}ddd	d
dhd
dif}|D ]7  }||d<   | j                  t              5   | j
                  di |}ddd       9 y# 1 sw Y   DxY w)z>Ensures draw line handles invalid start_pos formats correctly.r   r   Nr}   r   r  ru   ru   r   r   ru   r   ru   r  rU   r  rz   r   start_pos_fmtsr  r9   s        r!   $test_line__invalid_start_pos_formatsz.LineMixin.test_line__invalid_start_pos_formats  s     ~~f-\\%(
 FF
 ( 	7I"+F;""9- 7,dnn6v67 7	77 7   A77B 	c                    t        j                  d      t        j                  d      dddd}ddd	d
dhd
dif}|D ]7  }||d<   | j                  t              5   | j
                  di |}ddd       9 y# 1 sw Y   DxY w)z<Ensures draw line handles invalid end_pos formats correctly.r   r   r}   Nr   r  r  r  r  ru   r  rU   r  rz   r   end_pos_fmtsr  r9   s        r!   "test_line__invalid_end_pos_formatsz,LineMixin.test_line__invalid_end_pos_formats  s     ~~f-\\%(
 FF
 $ 	7G 'F9""9- 7,dnn6v67 7	77 7r  c                    t        j                  d      }t        j                  d      }t        j                  d      }d}|d|ddd}d	d
|j                  |      |f}|D ]  }|j	                  |       ||d<   t        |t              r|j                  |      }n|} | j                  di |}	| j                  |j                  |      |       | j                  |	t         j                          y)z2Ensures draw line accepts different color formats.r	   r   r   r   Nr   rp   r  r   r   r8   rU   )rE   r   rw   r   r   r   r   r   rc   r   r   rx   rF   
rz   r   r   r   r/   r   greensr8   r   r9   s
             r!   test_line__valid_color_formatsz(LineMixin.test_line__valid_color_formats  s    ll7+W-..(
 OOK(	
  	<ELL'#F7O%%!(!2!25!9!,($..262KW^^C0.A!!+v{{;	<r'   c                     t        j                  d      ddddd}d| fD ]7  }||d<   | j                  t              5   | j                  d	i |}ddd       9 y# 1 sw Y   DxY w)
z:Ensures draw line handles invalid color formats correctly.r   Nr   r   r   r  r   r8   rU   )rE   rw   r   r   rc   rz   r   r   r9   s       r!    test_line__invalid_color_formatsz*LineMixin.test_line__invalid_color_formats  s|     ~~f-
  #Dk 	7N,F7O""9- 7,dnn6v67 7	77 7   AA$	c                     d}| j                         D ]L  }| j                  D ];  }| j                  |||d       | j                  |j	                  |      |d|        = N y)z-Tests if the line drawn is the correct color.r$   r   pos=Nr  r  rc   r   r   rz   r/   r   r   s       r!   test_line__colorzLineMixin.test_line__color  si    ,,. 	TG"&++ TwVD  !4nSElST	Tr'   c           	         ddd| j                         D ]c  }| j                  D ]R  }| j                  ||ffd       fddD        D ]'  }| j                  |j	                  |      |d|        ) T e y)z6Ensures a thick line is drawn using the correct color.r   rr   c              3   >   K   | ]  }fD ]  }||z   f   y wr!  rU   )r#  ir   from_xto_xr   s      r!   r%  z<LineMixin.test_line__color_with_thickness.<locals>.<genexpr>  s)     S1VTNSqQAJSJSs   )r   ru   r  Nr  )rz   r   r   r/   r  r  r   s       @@@r!   test_line__color_with_thicknessz)LineMixin.test_line__color_with_thickness  s    ,,. 	XG"&++ XwdAYPQRS
S XC$$W^^C%8.DQTPU,WXX	Xr'   c                     d}| j                         D ]d  }|j                         }| j                  ||d|dz
  df       t        |      D ]+  }|df}| j	                  |j                  |      |d|        - f y)z*Tests if the line drawn contains any gaps.rv  r$   r   r   r  Nr  r2   rc   r   r   r   rz   r   r   r   r   r/   s         r!   test_line__gapszLineMixin.test_line__gaps  s    (,,. 	TG%%'ENN7NFUQYNK5\ T!f  !4nSElST		Tr'   c           	      P   d}d}| j                         D ]  }|j                         dz
  }|dz  }|dz  }| j                  ||d|d|z   f|       t        |dz         D ]E  }t        dd      D ]4  }|||dz   dz  z   f}	| j	                  |j                  |	      |d|	        6 G  y	)
z/Ensures a thick line is drawn without any gaps.rv  r   r   r   r   rp   rz  ru   r  Nr  )
rz   r   r  r   r   r   r   r   r   r/   s
             r!   test_line__gaps_with_thicknessz(LineMixin.test_line__gaps_with_thickness  s    (	,,. 		XG%%'!+E
AAANN7NFQAJ	R1q5\ Xq! XAaAEa<01C$$W^^C%8.DQTPU,WXX		Xr'   c                    t        | t              r| j                  d       t        j                  d      }t        j                  d      }dx}}t        j
                  d||f      }|dz   |dz   f|dz
  |dz
  ffD ]  }t        j                  |dd      }|j                         }t        |      D ]  }	|	|_	        t        d	d      D ]  }
| j                  |      D ]y  \  }}|j                  |       | j                  |||||
      }d|
k  rt        |||      }nt        j
                  |d      }| j                  ||d
j!                  ||||
             {    y)zEnsures draw line returns the correct bounding rect.

        Tests lines with endpoints on and off the surface and a range of
        width/thickness values.
        z1bounding rects not supported in draw_py.draw_liner   r   r   r$   r   r   rS  r,   z'start={}, end={}, size={}, thickness={}N)r   rk   skipTestrE   r   rF   rw   r  r*   r   r   r  r   rc   rM   r   format)rz   r  rG   r   r   helper_rectrB   r   r[  r/   r  startendr_  r`  s                  r!   test_line__bounding_rectz"LineMixin.test_line__bounding_rect*  sx    d./MMMN\\%(
\\'*
kk&5&/: ai!,uqy&1*.EF "	DnnT1b1G((*I 4I> %(" "'r1 I&*&6&6{&C 
sZ0(,#ZY) y= -A 'U-M
 -3KKv,FM(())ELL %sD)#	"	r'   c           	         dx}t        j                  d      }t        j                  d      }t        j                  |f      }|j                  |       t        j                  dd      }|j                         j                  |_        |j                         }dD ]#  }t        |      D ]  }||_        |j                  d       |j                  |       | j                  |||j                  |j                  |       t        |||      }	|j                  |       |j                  |       | j                  |||j                  |j                  |       |j                          fdt        |      D        D ]-  }
|
|	v r|}n|}| j!                  |j#                  |
      ||
       / |j%                           & y)	z1Ensures draw line respects a surface's clip area.r   r   r	   r$   rc  r   Nc              3   F   K   | ]  }t              D ]  }||f 
  y wr!  r"  rf  s      r!   r%  z4LineMixin.test_line__surface_clip.<locals>.<genexpr>  rh  r&  )rE   r   rw   r   rF   r  r   r.  r*   ri  rc   r   r   r>   r6   r   r   r   r7   )rz   rj  r  r   r   rk  rl  r  r   rm  rn  r   rg  s               @r!   test_line__surface_clipz!LineMixin.test_line__surface_clip_  s   \\%(
W-..%0]#KK1	"++-44	>># "	!I6yA  ! #)  &]+Z(:L:Li  0YO ]+  +Z(:L:Li  O5<N MB\))3)6$$W^^B%7LM  A !"	!r'   N)rP   rQ   rR   rS   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rU   r'   r!   r  r  b  s    
88<:
8+"?"R6/7b78!<F<0@4@47070 <D7 T	X	TX3j.!r'   r  c                   "    e Zd ZdZd Zd Zd Zy)DrawLineTestzTest draw module function line.

    This class inherits the general tests from LineMixin. It is also the class
    to add any draw.line specific tests to.
    c           	      4   dD ]  }t        j                  dd|      }|j                  t        j                  ddd             | j	                  |t        j                  ddd      ddd       | j                  |j                  d      j                  dd	       |j                  t        j                  ddd             | j	                  |t        j                  ddd      ddd       | j                  |j                  d      j                  dd
        yztest color component order)r   rS  r   rp   r   r   r   r   r   r   zthere should be red herezthere should be blue hereN)	rE   rw   r   r   rc   assertGreaterr   rbrz   r  r   s      r!   test_line_endiannessz!DrawLineTest.test_line_endianness  s     
	YEnnVQ6GLLaA./NN7FLLa$;VVQOw~~f577<VWLLaA./NN7FLLAs$;VVQOw~~f577<WX
	Yr'   c                 @   d| _         t        j                  | j                   t        j                        | _        d| _        t        j                  | j                  | j
                  dd      }| j                  |j                  dd       t        j                  |      D ]7  }| j                  | j                  j                  |      | j
                         9 t        j                  |      D ]7  }| j                  | j                  j                  |      | j
                         9 d}d}||f}| j                   d	   |z
  |d
   f}|d	   | j                   d
   |z
  f}|d	   |d
   f}|d	   |z   |d
   f}	|d	   |d	   dz   f}
||f||f||f||f||f||f||f||f||	f|	|f||
f|
|f||fg}|D ]m  \  }}| d| }|d	   |d	   k  r|}|}n|}|}| j                  j                  d       t        j                  | j                  d|||      }d	x}}t!        |d	   |d	   z
        t!        |d
   |d
   z
        kD  rd
}nd
}t#        |      D ]  }|d	   ||z  z   |d
   ||z  z   f}| j                  | j                  j                  |      d|       |d	   ||z  z   |d
   ||z  z   f}| j                  | j                  j                  |      d|        |d	   d
z
  |d
   f}| j                  | j                  j                  |      d|       |d	   ||z  z   |d
   ||z  z   f}| j                  | j                  j                  |      d|       |d	   ||z  z   |d
   ||z  z   f}| j                  | j                  j                  |      d|       |d	   |d	   k  r|d	   }n|d	   }|d
   |d
   k  r|d
   }n|d
   }t!        |d	   |d	   z
        d
z   ||d
z
  z  z   }t!        |d
   |d
   z
        d
z   ||d
z
  z  z   }|d| z  }| j                  |||||f|       p y )Ni@     r   r   r      r   )r  r      z3end point arg should be (or at least was) inclusiveru   r   r   r   z - r   rv  z, )	surf_sizerE   rw   r   surfr8   r   rb   r   r-   r   rect_area_ptsr   rect_outer_boundsassertNotEqualr   absr   )rz   drawnrn  
line_widthoffsetar  cdefrd   p1p2msgplowphighrecxincyincr  prxryr   r   s                             r!   	test_linezDrawLineTest.test_line  s   #NN4>>6??C	%
		$))TZZBKKS	

 **51 	?BTYY--b14::>	? ..u5 	BB		 0 0 4djjA	B 
V^^A'1.qT4>>!$v-.qT1Q4LqTF]AaD!qT1Q4!8FFFFFFFFFFFFF
   0	7FBDB4.C!u1~IINN9%))DIIB
KCOD42a52a5=!C11$66:& LUTAX%r!utax'78  !1!1!!4osKUTAX%r!utax'78  !1!1!!4osKL a1d1g&ATYY--a0)SAa4*,,d1gz8I.IJATYY--a0)SAqD:--uQx$:K/KLATYY--a0)SA!ur!u}UU!ur!u}UUBqEBqEM"Q&a)@@ABqEBqEM"Q&a)@@ARu:CS2r1a.#6a0	7r'   c                      ddt        j                  ft         j                        fd fd} |dd        |dd        |dd       y )Nr  c                     g d}d}t        |D cg c]$  \  }}j                  | |z   ||z   f      |k(  s#d& c}}      S c c}}w )N)r   r   rG  r<  )r   r   r   r   r   )lenr   )r   r   offsetsWHITEdxdyr  s         r!   white_surrounded_pixelsz@DrawLineTest.test_line_for_gaps.<locals>.white_surrounded_pixels  sL    8G(E!(Svr2DKKRR8H,IU,RS Ss
   $A
A
c                 &   j                  d       t        j                  j                  d| |d       d}t	        d	dz
        D ]H  }t	        ddz
        D ]4  }j                  ||f      |k(  sj                   ||      dk         6 J y )Nr   rv  r   r   r   r   r   r   rp   )r   rE   r   rb   r   r   r   )
r  r  r  r   r   r   rz   r  r#  r   s
        r!   check_white_linez9DrawLineTest.test_line_for_gaps.<locals>.check_white_line  s    IIi KKT?E3C"E1eai( Kq&1*- KA{{Aq6*e3(?1(E(IJKKr'   ry  )   r   )r   x   )      )rE   rw   r   )rz   r&  r   r  r#  r   s   ` @@@@r!   test_line_for_gapszDrawLineTest.test_line_for_gaps  sX     ~~ufov?		K 	K 	8,8,:.r'   N)rP   rQ   rR   rS   r  r  r+  rU   r'   r!   r  r    s    Y\7|/r'   r  c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)
LinesMixinz`Mixin test for drawing lines.

    This class contains all the general lines drawing tests.
    c                     | j                  t        j                  d      dddd      }| j                  |t        j                         y)z,Ensures draw lines accepts the correct args.ro   rq   Fr$   r   r   Nre   rE   rw   rx   rF   ry   s     r!   test_lines__argszLinesMixin.test_lines__args4  s;    ooNN6"NE;KQ
 	k6;;7r'   c                     | j                  t        j                  d      ddd      }| j                  |t        j                         y)z4Ensures draw lines accepts the args without a width.r}   r  Fr/  Nr0  ry   s     r!   test_lines__args_without_widthz)LinesMixin.test_lines__args_without_width<  s9    ooNN6"M5:J
 	k6;;7r'   c                     t        j                  d      }t        j                  d      }d}||d|dd||d|dg}|D ]4  } | j                  d	i |}| j	                  |t         j
                         6 y)
z\Ensures draw lines accepts the correct kwargs
        with and without a width arg.
        r   r   r$   r   r}   Fr   r   r8   closedpointsr   r   r8   r7  r8  NrU   )rE   rw   r   re   rx   rF   rz   r   r8   r8  r   r   r9   s          r!   test_lines__kwargszLinesMixin.test_lines__kwargsD  s     ..(X&) #   %5FS	
 " 	<F)$//3F3K!!+v{{;	<r'   c           	          | j                  ddddt        j                  d            }| j                  |t        j                         y)z4Ensures draw lines's kwargs are not order dependent.r   r5  ru   r  rt   )r7  r8  r   r8   r   Nr0  ry   s     r!   $test_lines__kwargs_order_independentz/LinesMixin.test_lines__kwargs_order_independent[  sC    oo+NN6* & 
 	k6;;7r'   c                 4   t        j                  d      }t        j                  d      }| j                  t              5  | j                  ||d      }ddd       | j                  t              5  | j                  ||      }ddd       | j                  t              5  | j                  |      }ddd       | j                  t              5  | j                         }ddd       y# 1 sw Y   xY w# 1 sw Y   sxY w# 1 sw Y   PxY w# 1 sw Y   yxY w)z5Ensures draw lines detects any missing required args.r   r   r   NrE   rw   r   r   r   re   r  s       r!   test_lines__args_missingz#LinesMixin.test_lines__args_missingg  s    ..(V$y) 	=//'5!<K	= y) 	://'59K	: y) 	3//'2K	3 y) 	,//+K	, 	,	= 	=	: 	:	3 	3	, 	,r  c                    t        j                  d      t        j                  d      dddd}dD ]N  }t        |      }|j	                  |       | j                  t              5   | j                  di |}ddd       P y# 1 sw Y   [xY w)	z7Ensures draw lines detects any missing required kwargs.rt   r   r   r}   r   r6  r8  r7  r8   r   NrU   )rE   rw   r   r   r   r   r   re   r   s        r!   test_lines__kwargs_missingz%LinesMixin.test_lines__kwargs_missingx  s     ~~f-\\%(&
 = 	@D!&\Nt$""9- @-doo??@ @		@@ @r  c                    t        j                  d      }t        j                  d      }d}d}| j                  t              5  | j                  ||||d      }ddd       | j                  t              5  | j                  |||d      }ddd       | j                  t              5  | j                  ||t               |      }ddd       | j                  t              5  | j                  |d||      }ddd       | j                  t              5  | j                  d	|||      }ddd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   `xY w# 1 sw Y   yxY w)
z-Ensures draw lines detects invalid arg types.r}   r   r   r   r   r   Nr   r   r  )rE   rw   r   r   r   re   rO   rz   r   r8   r7  r8  r9   s         r!   test_lines__arg_invalid_typesz(LinesMixin.test_lines__arg_invalid_types  sa   ..(V$!y) 	O//'5&&#NK	O y) 	M//'5&)LK	M y) 	Q//'5+-PK	Q y) 	H//'3GK	H y) 	O//,vvNK	O 	O!	O 	O	M 	M	Q 	Q	H 	H	O 	O<   D37D?)E#EE#3D<?EEE #E,c                 H   t        j                  d      t        j                  d      dddd}t         j                  dt               dd	d}dD ]E  }t	        |      }||   ||<   | j                  t              5   | j                  di |}d
d
d
       G y
# 1 sw Y   RxY w)z/Ensures draw lines detects invalid kwarg types.ro   r	   FrF  r   r6  r   r   r  NrU   )rE   rw   r   rO   r   r   r   re   rz   valid_kwargsr   kwargr   r9   s         r!   test_lines__kwarg_invalid_typesz*LinesMixin.test_lines__kwarg_invalid_types  s     ~~f-\\'*&
 ~~!m
 G 	8E,'F*51F5M""9- 8-doo778 8		88 8   :BB!	c                    t        j                  d      }t        j                  d      }d}d}||||ddd||||ddg}|D ]2  }| j                  t              5   | j
                  di |}ddd       4 y# 1 sw Y   ?xY w)	z/Ensures draw lines detects invalid kwarg names.r   r   r   rF  )r   r8   r7  r8  r   r   r   r8   r7  r8  r   NrU   r?  rz   r   r8   r7  r8  r   r   r9   s           r!   test_lines__kwarg_invalid_namez)LinesMixin.test_lines__kwarg_invalid_name  s    ..(V$! #   #  
$ " 	8F""9- 8-doo778 8	88 8r  c                    t        j                  d      }d}d}d}d}|||||d}dD ]  }|j                  |       d|k(  r | j                  |fi |}nhd|k(  r | j                  ||fi |}nNd	|k(  r | j                  |||fi |}n3d
|k(  r | j                  ||||fi |}n | j                  |||||fi |}| j	                  |t         j
                          y)z7Ensures draw lines accepts a combination of args/kwargsrt   r   r   rF  r   r6  r   r8   r7  r8  N)rE   rw   r   re   rx   rF   )	rz   r   r8   r7  r8  r   r   r   r9   s	            r!   test_lines__args_and_kwargsz&LinesMixin.test_lines__args_and_kwargs  s   ..( !
 F 	<DJJtD -doog@@D-dooguGGT!-doogufOOT!-dooguffWPVW-dooUFFE=C !!+v{{;!	<r'   c                    t        j                  d      }t        j                  d      }t        j                  d      }d}||d|dfdd}d	D ]t  }|j                  |       ||d
<   |dkD  r|n|} | j                  di |}| j                  |j                  |      |       | j                  |t         j                         v y)z2Ensures draw lines accepts different width values.r   r   r   r   Fr   Nr6  r  r   r   rU   	rE   r   rw   r   re   r   r   rx   rF   r  s	            r!   test_lines__valid_width_valuesz)LinesMixin.test_lines__valid_width_values  s    \\(+
W-..(Fm
 4 	<ELL'#F7O+019Z-N)$//3F3KW^^C0.A!!+v{{;	<r'   c           	         d}t        j                  d      }t        j                  d      }||dddd}t        t        t        t        ft        t        t        t        ft
        t
        t
        t
        ft        t
        t        t
        ff}d}t        t        f}|D ]  }|D ]  }	|	d	   }
t        |	      D cg c]  \  }} ||   |       }}}|D ]q  }|j                  |        ||      |d
<    | j                  di |}| j                  |j                  |
      |       | j                  |t         j                         s   yc c}}w )z4Ensures draw lines accepts different points formats.r   r   r   FNr   r6  r   r   r}   r   )r   )皙@r    @r\  )r   r^  r   r8  rU   )rE   r   rw   r  r  r   	enumerater   re   r   r   rx   rF   rz   r   r   r   r   point_typespoint_values	seq_types
point_typevalues	check_posr  rn  r8  r  r9   s                   r!   test_lines__valid_points_formatz*LinesMixin.test_lines__valid_points_format  sH   *W-..(#
 E5%(4t$gw07E7+	

 DM	% 	DJ& D"1I	9B69JK2-*Q-+KK ) DHLL/'/'7F8$"1$//";F";K$$W^^I%>O))+v{{CD	D	D Ls   6E	
c           	         t        j                  d      t        j                  d      dddd}ddd	d
ddhfd
dddfd
dhdddf}|D ]7  }||d<   | j                  t              5   | j
                  di |}ddd       9 y# 1 sw Y   DxY w)z<Ensures draw lines handles invalid points formats correctly.r   r   FNr   r6  r   r  r   ru   ru   ru   r   ru   2r   ru   rp   r   r   r   r   r   r8  rU   r?  rz   r   points_fmtsr8  r9   s        r!   "test_lines__invalid_points_formatsz-LinesMixin.test_lines__invalid_points_formats>  s     ~~f-\\%(
 aVq\"VaL
 " 	8F%F8""9- 8-doo778 8	88 8r  c                 "   t        j                  d      t        j                  d      dddd}g dfD ]N  }t        t        fD ]=  } ||      |d<   | j                  t              5   | j                  d	i |}ddd       ? P y# 1 sw Y   LxY w)
z;Ensures draw lines handles invalid points values correctly.r   r   FNr   r6  r   r8  rU   )rE   rw   r   r  r  r   
ValueErrorre   rz   r   r8  r  r9   s        r!   !test_lines__invalid_points_valuesz,LinesMixin.test_lines__invalid_points_valuesX  s     ~~f-\\%(
 9o 	<F"DM <#+F#3x &&z2 <"1$//";F";K< <<	<< <s   %BBc                    t        j                  d      }t        j                  d      }t        j                  d      }d}||dddd}d	dd
ddddgdf}ddddg df}||z   D ]q  }|j                  |       ||d<   |r|n|}	 | j                  di |}
| j                  |j                  |      |	       | j                  |
t         j                         s y)z3Ensures draw lines accepts different closed values.r   r   r   r   N)r   r   ro   r   r   r6  rr   rn  @r   r   T r   rU   Fr7  rW  rz   r  r   r   r/   r   true_valuesfalse_valuesr7  r   r9   s              r!   test_lines__valid_closed_valuesz*LinesMixin.test_lines__valid_closed_valuesi  s    \\&)
W-..(6
 1b#sD1#t<b!RU3!L0 	<FLL'%F8+1Z}N)$//3F3KW^^C0.A!!+v{{;	<r'   c                    t        j                  d      }t        j                  d      }t        j                  d      }d}|dd|dfdd	}d
d|j                  |      |f}|D ]  }|j	                  |       ||d<   t        |t              r|j                  |      }n|} | j                  di |}	| j                  |j                  |      |       | j                  |	t         j                          y)z3Ensures draw lines accepts different color formats.r	   r   r   r   NFr   rp   r6  r   r   r8   rU   )rE   r   rw   r   r   r   r   r   re   r   r   rx   rF   r  s
             r!   test_lines__valid_color_formatsz*LinesMixin.test_lines__valid_color_formats  s    ll7+W-..(Fm
 OOK(	
  	<ELL'#F7O%%!(!2!25!9!,)$//3F3KW^^C0.A!!+v{{;	<r'   c                     t        j                  d      ddddd}d| fD ]7  }||d<   | j                  t              5   | j                  d	i |}ddd       9 y# 1 sw Y   DxY w)
z;Ensures draw lines handles invalid color formats correctly.r   NFr   r   r   r6  r   r8   rU   )rE   rw   r   r   re   r  s       r!   !test_lines__invalid_color_formatsz,LinesMixin.test_lines__invalid_color_formats  s|     ~~f-&
  #Dk 	8N,F7O""9- 8-doo778 8	88 8r  c           
          | j                         D ]Y  }| j                  D ]H  }| j                  ||dt        |             t	        |      D ]  \  }}| j                  ||d|         J [ y)zTests if the lines drawn are the correct color.

        Draws lines around the border of the given surface and checks if all
        borders of the surface only contain the given color.
        Tr  N)r  r  re   r&   r0   r   rz   r   r   r/   r8   s        r!   test_lines__colorzLinesMixin.test_lines__color  s|     ,,. 	JG"&++ Jww?OP"6w"? JJC$$UNd3%LIJJ	Jr'   c                    dx}}| j                         D ]  }|j                         dz
  }|j                         dz
  }||f||f||f||ff}| j                  D ]  }| j	                  ||d|d       dD ]  }t        ||dz         D ]7  }	||fD ].  }
|	|
|z   f}| j                  |j                  |      |d|        0 9 t        ||dz         D ]7  }
||fD ].  }	|	|z   |
f}| j                  |j                  |      |d|        0 9    y)z6Ensures thick lines are drawn using the correct color.r   Trp   r,   r   r   r   r  N)r  r2   r3   r  re   r   r   r   )rz   x_lefty_topr   x_righty_bottom	endpointsr   tr   r   r/   s               r!    test_lines__color_with_thicknessz+LinesMixin.test_lines__color_with_thickness  sl   ,,. 	G'')A-G))+a/H% (#"	I #'++ y!L# A"67Q;7 "'!2 A#$a!e*C ,, 's 3 ."&se #5(Q,7 "('!2 A#$q5!*C ,, 's 3 ."&se	r'   c           	          d}| j                         D ]H  }| j                  ||dt        |             t        |      D ]  \  }}| j	                  ||d|         J y)zTests if the lines drawn contain any gaps.

        Draws lines around the border of the given surface and checks if
        all borders of the surface contain any gaps.
        rv  Tr  N)r  re   r&   r0   r   rz   r   r   r/   r8   s        r!   test_lines__gapszLinesMixin.test_lines__gaps  sl     ),,. 	FGOOG^T77;KL27; F
U  $seEF	Fr'   c           	      N   d}dx}}| j                         D ]  }|j                         dz
  dz  }|dz  }||z   }||z   }||f||f||ff}	| j                  ||d|	d       t        ||dz         D ]j  }
dD ]c  }|
||z   f}| j	                  |j                  |      |d|        |
||z   |
dz
  dz  z   f}| j	                  |j                  |      |d|        e l t        ||dz         D ]5  }dD ].  }||z   |f}| j	                  |j                  |      |d|        0 7  y	)
z/Ensures thick lines are drawn without any gaps.rv  r   rd  Trp   r   r  r  N)r  r2   re   r   r   r   )rz   r   r  r  r   r   r   r  r  r  r   r  r/   r   s                 r!   test_lines__gaps_with_thicknessz*LinesMixin.test_lines__gaps_with_thickness  s   (,,. 	XG""$r)a/AAAqjGqyH %7E*:Wh<OPIOOG^T9aH67Q;/ X# XAeai.C$$W^^C%8.DQTPU,WeaiAEa<89C$$W^^C%8.DQTPU,W	XX 5(Q,/ X# XA"Q;*C$$W^^C%8.DQTPU,WXX	Xr'   c                    t        j                  d      }t        j                  d      }dx}}t        j                  d||f      }|dz   |dz   f|dz
  |dz
  ffD ]  }t        j                  |dd      }|j	                         }t        |      D ]  }	|	|_        |j                  |j                  |j                  f}
|
d   }	t        dd      D ]j  }d	D ]c  }|j                  |       | j                  ||||
|      }d|k  rt        |||	      }nt        j                  |	d      }| j                  ||       e l   y
)zEnsures draw lines returns the correct bounding rect.

        Tests lines with endpoints on and off the surface and a range of
        width/thickness values.
        r   r   r   r$   r   r   rS  r,   TFN)rE   r   rF   rw   r  r*   r   r   r   r   r   r   re   rM   r   )rz   r  rG   r   r   rl  rB   r   r[  r/   r=   r  r7  r_  r`  s                  r!   test_lines__bounding_rectz$LinesMixin.test_lines__bounding_rect	  sb    \\%(
\\'*
;;vv7 ai!,uqy&1*.EF 	GDnnT1b1G((*I 4I> G"%''(:K:KL!f "'r1 GI"/ GZ0(,#Zi) y= -A 'S-M
 -3KKV,DM((F#GGG	Gr'   c           
         dx}t        j                  d      }t        j                  d      }t        j                  |f      }|j                  |       t        j                  dd      }|j                         j                  |_        |j                         }t        |      D ]  }||_        |j                  |j                  |j                  f}dD ]  }	dD ]  }
|j                  d       |j                  |       | j                  |||	||
       t        |||      }|j                  |       |j                  |       | j                  |||	||
       |j                          fd	t        |      D        D ]-  }||v r|}n|}| j!                  |j#                  |      ||       / |j%                             y)
z2Ensures draw lines respects a surface's clip area.r   r   r	   r$   rc  r  r   Nc              3   F   K   | ]  }t              D ]  }||f 
  y wr!  r"  rf  s      r!   r%  z6LinesMixin.test_lines__surface_clip.<locals>.<genexpr>]	  s%     R!U5\R1vRvRr&  )rE   r   rw   r   rF   r  r   r.  r*   r   r   ri  re   r>   r6   r   r   r   r7   )rz   rj  r  r   r   rk  rl  r   r=   r7  r  rm  rn  r   rg  s                 @r!   test_lines__surface_clipz#LinesMixin.test_lines__surface_clip7	  s   \\%(
W-..%0]#KK1	"++-44	>># 39=  	%F$HO??HOOX5G5GHC' %!' %I $$T*LL/OOGZiP#3GZ#SL LL/$$Y/OOGZiPLLN SuU|R Q--7N-:N(();^RPQ NN$7%%	 	%r'   N)rP   rQ   rR   rS   r1  r3  r;  r=  r@  rD  rH  rN  rS  rU  rX  rg  rr  rw  r  r  r  r  r  r  r  r  r  rU   r'   r!   r-  r-  .  s    
88<.
8,"@"O68288<B<0*DX84<"<6 <D8 JBFX.-G^.%r'   r-  c                       e Zd ZdZy)DrawLinesTestzTest draw module function lines.

    This class inherits the general tests from LinesMixin. It is also the class
    to add any draw.lines specific tests to.
    Nrr  rU   r'   r!   r  r  r	  rs  r'   r  c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)AALineMixinzrMixin test for drawing a single aaline.

    This class contains all the general single aaline drawing tests.
    c                     | j                  t        j                  d      dddd      }| j                  |t        j                         y)z-Ensures draw aaline accepts the correct args.ro   rq   r$   r   r   Nrg   rE   rw   rx   rF   ry   s     r!   test_aaline__argszAALineMixin.test_aaline__args	  s<    &&NN6"NFFA
 	k6;;7r'   c                     | j                  t        j                  d      ddd      }| j                  |t        j                         y)z5Ensures draw aaline accepts the args without a blend.r}   r  r$   Nr  ry   s     r!   test_aaline__args_without_blendz+AALineMixin.test_aaline__args_without_blend	  s:    &&NN6"M66
 	k6;;7r'   c                 b   t        j                  d      5 }t        j                  d       | j                  t	        j
                  d      dddd       | j                  t        |      d       | j                  t        |d	   j                  t                     d
d
d
       y
# 1 sw Y   y
xY w);From pygame 2, blend=False should raise DeprecationWarning.Trecordalwaysr}   r  r$   Fr   r,   N)warningscatch_warningssimplefilterrg   rE   rw   r   r  r   
issubclasscategoryDeprecationWarningrz   r   s     r!   test_aaline__blend_warningz&AALineMixin.test_aaline__blend_warning	  s    $$D1 		LQ!!(+v&vvu SVQ'OOJqu~~7IJK		L 		L 		L   BB%%B.c                     t        j                  d      }t        j                  d      }d}d}||||dg}|D ]4  } | j                  di |}| j	                  |t         j
                         6 y)z.Ensures draw aaline accepts the correct kwargsr   r   r   r}   r  NrU   )rE   rw   r   rg   rx   rF   r  s           r!   test_aaline__kwargszAALineMixin.test_aaline__kwargs	  s|    ..(X&	 #&"	
 " 	<F*$**4V4K!!+v{{;	<r'   c                     | j                  dddt        j                  d            }| j                  |t        j                         y)z5Ensures draw aaline's kwargs are not order dependent.r   r   r  rt   )r  r  r8   r   Nr  ry   s     r!   %test_aaline__kwargs_order_independentz1AALineMixin.test_aaline__kwargs_order_independent	  sB    &&NN6*	 ' 
 	k6;;7r'   c                 4   t        j                  d      }t        j                  d      }| j                  t              5  | j                  ||d      }ddd       | j                  t              5  | j                  ||      }ddd       | j                  t              5  | j                  |      }ddd       | j                  t              5  | j                         }ddd       y# 1 sw Y   xY w# 1 sw Y   sxY w# 1 sw Y   PxY w# 1 sw Y   yxY w)z6Ensures draw aaline detects any missing required args.r   r   r$   NrE   rw   r   r   r   rg   r  s       r!   test_aaline__args_missingz%AALineMixin.test_aaline__args_missing	      ..(V$y) 	C**7E6BK	C y) 	;**7E:K	; y) 	4**73K	4 y) 	-**,K	- 	-	C 	C	; 	;	4 	4	- 	-r  c                    t        j                  d      t        j                  d      ddd}dD ]N  }t        |      }|j	                  |       | j                  t              5   | j                  di |}ddd       P y# 1 sw Y   [xY w)	z8Ensures draw aaline detects any missing required kwargs.rt   r   r   r}   r  r  NrU   )rE   rw   r   r   r   r   r   rg   r   s        r!   test_aaline__kwargs_missingz'AALineMixin.test_aaline__kwargs_missing	  s     ~~f-\\%(	
 A 	AD!&\Nt$""9- A.d..@@A A		AA A   $BB	c                 P   t        j                  d      }t        j                  d      }d}d}| j                  t              5  | j                  |||d      }ddd       | j                  t              5  | j                  ||d|      }ddd       | j                  t              5  | j                  |d||      }ddd       | j                  t              5  | j                  d	|||      }ddd       y# 1 sw Y   xY w# 1 sw Y   zxY w# 1 sw Y   TxY w# 1 sw Y   yxY w)
z.Ensures draw aaline detects invalid arg types.r}   r   r   r   r   Nr  zinvalid-colorr  )rE   rw   r   r   r   rg   ru  r  s         r!   test_aaline__arg_invalid_typesz*AALineMixin.test_aaline__arg_invalid_types	  s)   ..(V$	y) 	Q**7E9iPK	Q y) 	J**7E4IK	J z* 	Y**7OYPWXK	Y y) 	T**<	7SK	T 	T	Q 	Q	J 	J	Y 	Y	T 	Ts0   C86D(DD8DDDD%c                 6   t        j                  d      }t        j                  d      }d}d}t         j                  |||d|d||d||d|d|||ddg}|D ]2  }| j                  t              5   | j
                  d
i |}d	d	d	       4 y	# 1 sw Y   ?xY w)z0Ensures draw aaline detects invalid kwarg types.ro   r	   r   r  r  r   r   r  NrU   r  r  s           r!    test_aaline__kwarg_invalid_typesz,AALineMixin.test_aaline__kwarg_invalid_types	  s    ..(W%	 ">>&"	 #&"	 #&"	 #&	'
6 " 	9F""9- 9.d..889 9	99 9   1BB	c                    t        j                  d      }t        j                  d      }d}d}||||dd||||ddg}|D ]2  }| j                  t              5   | j
                  di |}ddd       4 y# 1 sw Y   ?xY w)	z0Ensures draw aaline detects invalid kwarg names.r   r   r   r  r   r  NrU   r  r  s           r!   test_aaline__kwarg_invalid_namez+AALineMixin.test_aaline__kwarg_invalid_name
  s    ..(V$	 #&" #&"
" " 	9F""9- 9.d..889 9	99 9r  c                    t        j                  d      }d}d}d}||||d}dD ]  }|j                  |       d|k(  r | j                  |fi |}ngd|k(  r | j                  ||fi |}nMd|k(  r | j                  |||fi |}n2d	|k(  r | j                  ||||fi |}n | j                  ||||fi |}| j	                  |t         j
                          y
)z8Ensures draw aaline accepts a combination of args/kwargsrt   r   r   r   r  r   r8   r  r  N)rE   rw   r   rg   rx   rF   )rz   r   r8   r  r  r   r   r9   s           r!   test_aaline__args_and_kwargsz(AALineMixin.test_aaline__args_and_kwargs7
  s   ..( 	"	
 A 	<DJJtD .d..wA&AD.d..wHH$.d..wySFSd".d..UIw:@ /d..UIw:@ !!+v{{;%	<r'   c                 $   t        j                  d      }t        j                  d      }t        j                  d      }||ddd}d\  }}||f|dz   |f||dz   f|dz   |dz   ff}|D ]  }t        t        t
        fD ]  }	|j                  |        |	|      |d	<    | j                  di |}
|j                  ||f      }t        |      D ]  \  }}| j                  ||   d
z   ||         | j                  |
t         j                  |         y)z8Ensures draw aaline accepts different start_pos formats.r   r   r   Nr}   r  r   g{Gz?r  r-  rU   rE   r   rw   r  r  r   r   rg   r   r_  assertGreaterEqualrx   rF   )rz   r   r   r   r   r   r   r8  r  r  r9   r8   r  	sub_colors                 r!   $test_aaline__valid_start_pos_formatsz0AALineMixin.test_aaline__valid_start_pos_formatsX
  s2   e,W-..(#	
 1Va$h]QDMAHa$h;OP	" 	KI"D'2 K]+&.y&9{#.d..881v.$-n$= PLAy ++E!HqL)YOP %%k6;;	JK	Kr'   c                 $   t        j                  d      }t        j                  d      }t        j                  d      }||ddd}d\  }}||f|dz   |f||dz   f|dz   |dz   ff}|D ]  }t        t        t
        fD ]  }	|j                  |        |	|      |d	<    | j                  di |}
|j                  ||f      }t        |      D ]  \  }}| j                  ||   d
z   ||         | j                  |
t         j                  |         y)z6Ensures draw aaline accepts different end_pos formats.r   r   r   r   Nr  r}   g{Gz?r     rU   r  )rz   r   r   r   r   r   r   r8  r  r  r9   r8   r  r  s                 r!   "test_aaline__valid_end_pos_formatsz.AALineMixin.test_aaline__valid_end_pos_formatst
  s2   e,W-..(#	
 1Va$h]QDMAHa$h;OP	  	IG"D'2 I]+$,W$5y!.d..881v.$-n$= OLAy ++E!HrM9gNO %%k6;;HI	Ir'   c                    t        j                  d      t        j                  d      ddd}dddd	d
hd	d
if}|D ]7  }||d<   | j                  t              5   | j
                  di |}ddd       9 y# 1 sw Y   DxY w)z@Ensures draw aaline handles invalid start_pos formats correctly.r   r   Nr}   r  r  r  r  ru   r   r  rU   r  r  s        r!   &test_aaline__invalid_start_pos_formatsz2AALineMixin.test_aaline__invalid_start_pos_formats
  s     ~~f-\\%(	
 FF
 ( 	9I"+F;""9- 9.d..889 9	99 9   A66A?	c                    t        j                  d      t        j                  d      ddd}dddd	d
hd	d
if}|D ]7  }||d<   | j                  t              5   | j
                  di |}ddd       9 y# 1 sw Y   DxY w)z>Ensures draw aaline handles invalid end_pos formats correctly.r   r   r}   Nr  r  r  r  ru   r   r  rU   r  r  s        r!   $test_aaline__invalid_end_pos_formatsz0AALineMixin.test_aaline__invalid_end_pos_formats
  s     ~~f-\\%(	
 FF
 $ 	9G 'F9""9- 9.d..889 9	99 9r  c                    t        j                  d      }t        j                  d      }t        j                  d      }d}|d|dd}dd	|j                  |      |f}|D ]  }|j	                  |       ||d
<   t        |t              r|j                  |      }n|} | j                  di |}	| j                  |j                  |      |       | j                  |	t         j                          y)z4Ensures draw aaline accepts different color formats.r	   r   r   r   Nr   r  r   r   r8   rU   )rE   r   rw   r   r   r   r   r   rg   r   r   rx   rF   r  s
             r!    test_aaline__valid_color_formatsz,AALineMixin.test_aaline__valid_color_formats
  s    ll7+W-..(	
 OOK(	
  	<ELL'#F7O%%!(!2!25!9!,*$**4V4KW^^C0.A!!+v{{;	<r'   c                     t        j                  d      dddd}d| fD ]7  }||d<   | j                  t              5   | j                  di |}ddd       9 y# 1 sw Y   DxY w)	z<Ensures draw aaline handles invalid color formats correctly.r   Nr   r   r  r   r8   rU   )rE   rw   r   r   rg   r  s       r!   "test_aaline__invalid_color_formatsz.AALineMixin.test_aaline__invalid_color_formats
  s{     ~~f-	
  #Dk 	9N,F7O""9- 9.d..889 9	99 9   AA#	c                     d}| j                         D ]L  }| j                  D ];  }| j                  |||d       | j                  |j	                  |      |d|        = N y)z/Tests if the aaline drawn is the correct color.r$   r   r  N)r  r  rg   r   r   r  s       r!   test_aaline__colorzAALineMixin.test_aaline__color
  sk    ,,. 	TG"&++ T  .#vF  !4nSElST	Tr'   c                     d}| j                         D ]d  }|j                         }| j                  ||d|dz
  df       t        |      D ]+  }|df}| j	                  |j                  |      |d|        - f y)zHTests if the aaline drawn contains any gaps.

        See: #512
        rv  r$   r   r   r  N)r  r2   rg   r   r   r   r  s         r!   test_aaline__gapszAALineMixin.test_aaline__gaps
  s    
 ),,. 	TG%%'EWnfuqy!nM5\ T!f  !4nSElST		Tr'   c           	         t        j                  d      }t        j                  d      }dx}}t        j                  d||f      }|dz   |dz   f|dz
  |dz
  ffD ]  }t        j                  |dd      }|j	                         }t        |      D ]f  }	|	|_        | j                  |      D ]I  \  }
}|j                  |       | j                  |||
|      }t        |||
      }| j                  ||       K h  y)	z{Ensures draw aaline returns the correct bounding rect.

        Tests lines with endpoints on and off the surface.
        r   r   r   r$   r   r   rS  N)rE   r   rF   rw   r  r*   r   r  r   rg   rM   r   )rz   r  rG   r   r   r  rB   r   r[  r/   r  r  r_  r`  s                 r!   test_aaline__bounding_rectz&AALineMixin.test_aaline__bounding_rect  s   
 \\%(
\\&)
kk&5&/: ai!,uqy&1*.EF 	CDnnT1b1G((*I 4I> C%(""&"2"2;"? 	CJE3LL,$($4$4Wj%QT$UM %9*e$TM$$]MB	CC	Cr'   c                   
 dx}
t        j                  d      }t        j                  d      }t        j                  |
f      }|j                  |       t        j                  dd      }|j                         j                  |_        |j                         }t        |      D ].  }||_        |j                  d       |j                  |       | j                  |||j                  |j                         t        |||d      }|j                  |       |j                  |       | j                  |||j                  |j                         |j                          
fdt        |      D        D ]K  }	|	|v r#| j!                  |j#                  |	      ||	       *| j%                  |j#                  |	      ||	       M |j'                          1 y)	z3Ensures draw aaline respects a surface's clip area.r   r   r	   r$   rc  NFc              3   F   K   | ]  }t              D ]  }||f 
  y wr!  r"  rf  s      r!   r%  z8AALineMixin.test_aaline__surface_clip.<locals>.<genexpr>J  s%     J!U5\J1vJvJr&  )rE   r   rw   r   rF   r  r   r.  r*   ri  rg   r   r   r>   r6   r   r  r   r   r7   )rz   rj  aaline_colorr   r   rk  rl  r   rm  rn  rg  s             @r!   test_aaline__surface_clipz%AALineMixin.test_aaline__surface_clip&  s   ||E*W-..%0]#KK1	"++-44	>># 39= 	F$HO T"LL'WlHOOXEWEWX+G]IuUL LL'Y'WlHOOXEWEWXLLN KuU|J L%''r(:M2N$$W^^B%7K	L NN9	r'   N)rP   rQ   rR   rS   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rU   r'   r!   r  r  }	  s|    
88L<(	8-"A T.#9J96<BK8I89.9.<B9TTCB*r'   r  c                   8    e Zd ZdZd Z	 d	dZd Zd Zd Zd Z	y)
DrawAALineTestzTest draw module function aaline.

    This class inherits the general tests from AALineMixin. It is also the
    class to add any draw.aaline specific tests to.
    c           	      4   dD ]  }t        j                  dd|      }|j                  t        j                  ddd             | j	                  |t        j                  ddd      ddd       | j                  |j                  d      j                  dd	       |j                  t        j                  ddd             | j	                  |t        j                  ddd      ddd       | j                  |j                  d      j                  dd
        yr  )	rE   rw   r   r   rg   r  r   r  r  r  s      r!   test_aaline_endiannessz%DrawAALineTest.test_aaline_endiannessd  s     
	YEnnVQ6GLLaA./Wfll31&=vvqQw~~f577<VWLLaA./Wfll1a&=vvqQw~~f577<WX
	Yr'   c                 h     |rt         x||<   ||<    fd} ||||       ||k7  r ||||       yy)z@Draw a line between two points and check colors of check_points.c                 z   j                  j                  t        | |d       D ]`  }|j                  |t              }j                  | ||      5  j                  j                  j                  |      |       d d d        b t        j                  j                  t        dd       y # 1 sw Y   xY w)NT)from_ptrn  tor   r   rr   rr   r   )
rg   r   FG_GREENgetBG_REDsubTestr   r   r   r)   )
from_pointto_pointshouldrn  r8   check_pointsrz   s        r!   check_one_directionz?DrawAALineTest._check_antialiasing.<locals>.check_one_directiony  s    T\\8Z4P" E

2v.\\*\I E$$T\\%8%8%<eDE EE IIdllFNA>	E Es   ,B11B:	N)r  )rz   r  r  r  r  set_endpointsr  s   `   `  r!   _check_antialiasingz"DrawAALineTest._check_antialiasingr  sH     4<<F:!1		? 	J&9!*f= "r'   c                     t        j                  d       _        t        j                   j                  t
        dd       t        dd      D cg c]  }t        dd      D ]  }||f  c}} fd} |ddg         |dd	g         |d
ddg        |ddg         |dddg        |ddg         |dddg        |ddg         |dddg       yc c}}w )z9test very short not anti aliased lines in all directions.rJ  r  r   rp   rz  c                 `    |D ci c]	  }|t          }}j                  | ||       y c c}w r!  )r  r  )r  to_ptother_pointsrn  r  r  rz   s        r!   check_both_directionszNDrawAALineTest.test_short_non_antialiased_lines.<locals>.check_both_directions  s3    -9:rb(l:F:$$WeV\J ;s   +r   r   rQ  r   rQ  r   rQ  r   r-  r   r   r-  r-  r-  r-  r   )rQ  rQ  r   r-  NrE   rw   r   r   r)   r  r   )rz   r  jr  r  s   `   @r!    test_short_non_antialiased_linesz/DrawAALineTest.test_short_non_antialiased_lines  s    
 ~~h/		$,,:(-aI1U1a[IAII	K
 	ffb1ffb1ffvh7 	ffb1ffvh7ffb1ffvh7ffb1ffvh7' Js   Cc                 t    t        j                  d       _        t        j                   j                  t
        dd       t        dd      D cg c]  }t        dd      D ]  }||f  c}} fd}d}d}d	} |d
d||d        |dd||d        |d
d||d        |dd||d       t        dd      D cg c]  }t        dd      D ]  }||f  c}}||||||d} |dd|       ||||||d} |dd|       ||||||d} |dd|       ||||||d} |dd|       y c c}}w c c}}w )NrJ  r  r   rp   rz  c                 .    j                  | ||       y r!  )r  )r  r  r  r  rz   s      r!   r  zKDrawAALineTest.test_short_line_anti_aliasing.<locals>.check_both_directions  s    $$WeV\Jr'      r  r      ?   r   r  r  r   r   r  )r   r   r   r   r  )r   r   r   r  ru   	   r   r  )r-  rp   r   r   r   ro   r  r   rQ  rp   )r   r   r  r   r   r  r   r  r  r  r  )	rz   r  r  r  brownreddishgreenishr  r  s	   `       @r!   test_short_line_anti_aliasingz,DrawAALineTest.test_short_line_anti_aliasing  s   ~~h/		$,,:(-aI1U1a[IAII	K 
 	ffue.LMffue.LM 	ffue.LMffue.LM ).aI1U1a[IAII 
 	fff5 
 	fff5 
 	fff5 
 	fff5{ J( Js   D.D4c                    t        j                  d      | _        t        j                  | j                  t
        dd       t        d      D cg c]  }t        d      D ]  }||f  }}}d}d}d}dt        i}| j                  d	d	||d
       dt        i}| j                  dd||d
       |t        d}| j                  d	d||d
       |t        |d}| j                  d	d||d
       |t        d}| j                  dd	||d
       ||d}| j                  d	d||d
       t        dd      D 	ci c]  }dD ]  }	||	f|	  }}}	| j                  dd||d
       |t        |d}| j                  dd||d
       ||d}| j                  dd||d
       dD 	ci c]  }t        dd      D ]  }	||	f|	  }}}	| j                  d	d||d
       |t        |d}| j                  dd||d
       |t        |d}| j                  d d!||d
       ||||d"}| j                  dd#||d
       ||||||d$}| j                  d%d&||d
       y'c c}}w c c}	}w c c}	}w )(z-Float coordinates should be blended smoothly.rJ  r  r   r   r
  r  r  r}   )      ?ru   F)r  r   )gQ@g@)r   r}   )r   r}   rt   )      @ru   )r}   r   r   )      ?ru   ru   )ru   r  )r   r  r   r}   r   )ru   r  )r   r}   )ru   r  )r  r   )r   r}   ro   r  r  )r  r  )r   r}   r   )r  r  )r  r  )r   r}   rt   ro   )rp   r  )r   r}   rt   ro   r   r   )ru   g      ?)r   g      
@N)	rE   rw   r   r   r)   r  r   r  r  )
rz   r  r  r  r  r  r  expectedr   r   s
             r!   $test_anti_aliasing_float_coordinatesz3DrawAALineTest.test_anti_aliasing_float_coordinates  s'    ~~h/		$,,:(-aC1%(CQACCC H%  h,e 	! 	
 H%  hE 	! 	
 "84  fhE 	! 	
 "8UC  h,e 	! 	
 "84  HhE 	! 	
 "84  i<u 	! 	

 ,1A;GaG1QFEMGFGG  h,e 	! 	
 "8UC  h,e 	! 	
 "84  i<u 	! 	
 ,2Ga5A;GaQFEMGFGG  h,e 	! 	

 "8UC  
Hl% 	! 	
 "8UC  
Hl% 	! 	
 "5%O  h,e 	! 	

 
 	  y(L 	! 	
a DF H  Hs   I7I#I"c           	         t        j                  d      | _        t        j                  | j                  t
        dd       t        d      D cg c]  }t        d      D ]  }||f  }}}d}d}d}d\  }}||||||d	}	d
D ]i  \  }
}|d   |
z   |d   |z   f}|d   |
z   |d   |z   f}|	j                         D ci c]  \  \  }}}||
z   ||z   f| }}}}| j                  ||||       k yc c}}w c c}}}w )z:Ensures antialiasing works correct at a surface's borders.rJ  r  r   rr   r  r
  r  )ro   r  r  ))r   )r   r   )r   )r   r   )r   r  )r   r-  )r   rQ  )r   r   )r   r"  )r"  r   r   N)	rE   rw   r   r   r)   r  r   itemsr  )rz   r  r  r  r  r  r  r  r  r  r!  r"  firstsecondr   r   r8   r  s                     r!   ,test_anti_aliasing_at_and_outside_the_borderz;DrawAALineTest.test_anti_aliasing_at_and_outside_the_borderD  s.    ~~h/		$,,:(-b	E159EaAEEE-
H

 	LFB qMB&
1(::Ea[2%x{R'77FEK\\^TTMFQERR(%/THT$$UFHlK#	L F< Us   C0=C6
N)T)
rP   rQ   rR   rS   r  r  r  r  r  r&  rU   r'   r!   r  r  ]  s2    Y IM>08:A6FX
t&Lr'   r  c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)AALinesMixinzdMixin test for drawing aalines.

    This class contains all the general aalines drawing tests.
    c                     | j                  t        j                  d      dddd      }| j                  |t        j                         y)z.Ensures draw aalines accepts the correct args.ro   rq   Fr/  r   Nri   rE   rw   rx   rF   ry   s     r!   test_aalines__argszAALinesMixin.test_aalines__argsv  s=    ''NN6"NE;KQ
 	k6;;7r'   c                     | j                  t        j                  d      ddd      }| j                  |t        j                         y)z6Ensures draw aalines accepts the args without a blend.r}   r  Fr/  Nr*  ry   s     r!    test_aalines__args_without_blendz-AALinesMixin.test_aalines__args_without_blend~  s;    ''NN6"M5:J
 	k6;;7r'   c                 b   t        j                  d      5 }t        j                  d       | j                  t	        j
                  d      dddd       | j                  t        |      d       | j                  t        |d	   j                  t                     d
d
d
       y
# 1 sw Y   y
xY w)r  Tr  r  r}   r  Fr/  r   r,   N)r  r  r  ri   rE   rw   r   r  r   r  r  r  r  s     r!   test_aalines__blend_warningz(AALinesMixin.test_aalines__blend_warning  s    $$D1 		LQ!!(+v&u>NPU SVQ'OOJqu~~7IJK		L 		L 		Lr  c                     t        j                  d      }t        j                  d      }d}||d|dg}|D ]4  } | j                  di |}| j	                  |t         j
                         6 y)z0Ensures draw aalines accepts the correct kwargs.r   r   r5  Fr9  NrU   )rE   rw   r   ri   rx   rF   r:  s          r!   test_aalines__kwargsz!AALinesMixin.test_aalines__kwargs  sp    ..(X&)%5FS
 " 	<F+$++5f5K!!+v{{;	<r'   c                     | j                  dddt        j                  d            }| j                  |t        j                         y)z6Ensures draw aalines's kwargs are not order dependent.r   r5  r  rt   )r7  r8  r8   r   Nr*  ry   s     r!   &test_aalines__kwargs_order_independentz3AALinesMixin.test_aalines__kwargs_order_independent  sB    ''+NN6*	 ( 
 	k6;;7r'   c                 4   t        j                  d      }t        j                  d      }| j                  t              5  | j                  ||d      }ddd       | j                  t              5  | j                  ||      }ddd       | j                  t              5  | j                  |      }ddd       | j                  t              5  | j                         }ddd       y# 1 sw Y   xY w# 1 sw Y   sxY w# 1 sw Y   PxY w# 1 sw Y   yxY w)z7Ensures draw aalines detects any missing required args.r   r   r   NrE   rw   r   r   r   ri   r  s       r!   test_aalines__args_missingz'AALinesMixin.test_aalines__args_missing  s    ..(V$y) 	?++GUA>K	? y) 	<++GU;K	< y) 	5++G4K	5 y) 	.++-K	. 	.	? 	?	< 	<	5 	5	. 	.r  c                    t        j                  d      t        j                  d      ddd}dD ]N  }t        |      }|j	                  |       | j                  t              5   | j                  di |}ddd       P y# 1 sw Y   [xY w)	z9Ensures draw aalines detects any missing required kwargs.rt   r   r   rB  r9  rC  NrU   )rE   rw   r   r   r   r   r   ri   r   s        r!   test_aalines__kwargs_missingz)AALinesMixin.test_aalines__kwargs_missing  s     ~~f-\\%(&	
 = 	BD!&\Nt$""9- B/d//A.AB B		BB Br  c                    t        j                  d      }t        j                  d      }d}d}| j                  t              5  | j                  ||||d      }ddd       | j                  t              5  | j                  |||d      }ddd       | j                  t              5  | j                  ||t               |      }ddd       | j                  t              5  | j                  |d||      }ddd       | j                  t              5  | j                  d	|||      }ddd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   `xY w# 1 sw Y   yxY w)
z/Ensures draw aalines detects invalid arg types.r}   r   r   rF  r   Nr   r   r  )rE   rw   r   r   r   ri   rO   rG  s         r!   test_aalines__arg_invalid_typesz,AALinesMixin.test_aalines__arg_invalid_types  sk   ..(V$!y) 	Q++GUFFCPK	Q y) 	O++GUFINK	O y) 	S++GUKM6RK	S y) 	J++GS&&IK	J y) 	Q++L%PK	Q 	Q!	Q 	Q	O 	O	S 	S	J 	J	Q 	QrI  c                 D   t        j                  d      t        j                  d      ddd}t         j                  dt               dd}dD ]E  }t	        |      }||   ||<   | j                  t              5   | j                  d	i |}ddd       G y# 1 sw Y   RxY w)
z1Ensures draw aalines detects invalid kwarg types.ro   r	   FrF  r9  r   r   NrU   )rE   rw   r   rO   r   r   r   ri   rK  s         r!   !test_aalines__kwarg_invalid_typesz.AALinesMixin.test_aalines__kwarg_invalid_types  s     ~~f-\\'*&	
 ~~!m	
 > 	:E,'F*51F5M""9- :/d//9&9: :		:: :r   c                    t        j                  d      }t        j                  d      }d}d}||||dd||||ddg}|D ]2  }| j                  t              5   | j
                  di |}ddd       4 y# 1 sw Y   ?xY w)z1Ensures draw aalines detects invalid kwarg names.r   r   r   rF  rQ  NrU   r5  rR  s           r!    test_aalines__kwarg_invalid_namez-AALinesMixin.test_aalines__kwarg_invalid_name  s    ..(V$! #   #  
" " 	:F""9- :/d//9&9: :	:: :r  c                    t        j                  d      }d}d}d}||||d}dD ]  }|j                  |       d|k(  r | j                  |fi |}ngd|k(  r | j                  ||fi |}nMd|k(  r | j                  |||fi |}n2d	|k(  r | j                  ||||fi |}n | j                  ||||fi |}| j	                  |t         j
                          y
)z9Ensures draw aalines accepts a combination of args/kwargsrt   r   r   rF  r9  r   r8   r7  r8  N)rE   rw   r   ri   rx   rF   )rz   r   r8   r7  r8  r   r   r9   s           r!   test_aalines__args_and_kwargsz*AALinesMixin.test_aalines__args_and_kwargs  s   ..( !	
 = 	<DJJtD /d//B6BD/d//I&IT!/d//Q&QT!/d//UFF6< 0d//UFF6< !!+v{{;%	<r'   c           	         d}t        j                  d      }t        j                  d      }||ddd}t        t        t        t        ft        t        t        t        ft
        t
        t
        t
        ft        t
        t        t
        ff}d}t        t        f}|D ]  }|D ]  }	|	d   }
t        |	      D cg c]  \  }} ||   |       }}}|D ]q  }|j                  |        ||      |d	<    | j                  d
i |}| j                  |j                  |
      |       | j                  |t         j                         s   yc c}}w )z6Ensures draw aalines accepts different points formats.r   r   r   FNr9  rZ  r   r8  rU   )rE   r   rw   r  r  r   r_  r   ri   r   r   rx   rF   r`  s                   r!   !test_aalines__valid_points_formatz.AALinesMixin.test_aalines__valid_points_format;  sG   *W-..(#	
 E5%(4t$gw07E7+	

 DM	% 	DJ& D"1I	9B69JK2-*Q-+KK ) DHLL/'/'7F8$"3$"3"3"=f"=K$$W^^I%>O))+v{{CD	D	D L   5E
c           	         t        j                  d      t        j                  d      ddd}dddd	d
dhfd	d
ddfd	dhdddf}|D ]7  }||d<   | j                  t              5   | j
                  di |}ddd       9 y# 1 sw Y   DxY w)z>Ensures draw aalines handles invalid points formats correctly.r   r   FNr9  ri  rj  rl  r   ru   rp   r   r   r   r   ro  r8  rU   r5  rp  s        r!   $test_aalines__invalid_points_formatsz1AALinesMixin.test_aalines__invalid_points_formatsf  s     ~~f-\\%(	
 aVq\"VaL
 " 	:F%F8""9- :/d//9&9: :	:: :r  c                     t        j                  d      t        j                  d      ddd}g dfD ]N  }t        t        fD ]=  } ||      |d<   | j                  t              5   | j                  di |}ddd       ? P y# 1 sw Y   LxY w)	z=Ensures draw aalines handles invalid points values correctly.r   r   FNr9  rt  r8  rU   )rE   rw   r   r  r  r   ru  ri   rv  s        r!   #test_aalines__invalid_points_valuesz0AALinesMixin.test_aalines__invalid_points_values  s     ~~f-\\%(	
 9o 	>F"DM >#+F#3x &&z2 >"3$"3"3"=f"=K> >>	>> >   $BBc                    t        j                  d      }t        j                  d      }t        j                  d      }d}||ddd}dd	d
ddddgdf}ddddg df}||z   D ]q  }|j                  |       ||d<   |r|n|}	 | j                  di |}
| j                  |j                  |      |	       | j                  |
t         j                         s y)z5Ensures draw aalines accepts different closed values.r   r   r   r   N)r   )r   r   r   ro  r9  ry  r   rr   rn  rz  r{  r   Tr|  r   rU   Fr7  )	rE   r   rw   r   ri   r   r   rx   rF   r}  s              r!   !test_aalines__valid_closed_valuesz.AALinesMixin.test_aalines__valid_closed_values  s    \\&)
W-..(6	
 1b#sD1#t<b!RU3!L0 	<FLL'%F8+1Z}N+$++5f5KW^^C0.A!!+v{{;	<r'   c                    t        j                  d      }t        j                  d      }t        j                  d      }d}|dd|dfd}d	d
|j                  |      |f}|D ]  }|j	                  |       ||d<   t        |t              r|j                  |      }n|} | j                  di |}	| j                  |j                  |      |       | j                  |	t         j                          y)z5Ensures draw aalines accepts different color formats.r	   r   r   r   NFr   r9  r   r   r8   rU   )rE   r   rw   r   r   r   r   r   ri   r   r   rx   rF   r  s
             r!   !test_aalines__valid_color_formatsz.AALinesMixin.test_aalines__valid_color_formats  s    ll7+W-..(Fm	
 OOK(	
  	<ELL'#F7O%%!(!2!25!9!,+$++5f5KW^^C0.A!!+v{{;	<r'   c                     t        j                  d      dddd}d| fD ]7  }||d<   | j                  t              5   | j                  di |}ddd       9 y# 1 sw Y   DxY w)	z=Ensures draw aalines handles invalid color formats correctly.r   NFr  r9  r   r8   rU   )rE   rw   r   r   ri   r  s       r!   #test_aalines__invalid_color_formatsz0AALinesMixin.test_aalines__invalid_color_formats  s{     ~~f-&	
  #Dk 	:N,F7O""9- :/d//9&9: :	:: :r  c           
          | j                         D ]Y  }| j                  D ]H  }| j                  ||dt        |             t	        |      D ]  \  }}| j                  ||d|         J [ y)zTests if the aalines drawn are the correct color.

        Draws aalines around the border of the given surface and checks if all
        borders of the surface only contain the given color.
        Tr  N)r  r  ri   r&   r0   r   r  s        r!   test_aalines__colorz AALinesMixin.test_aalines__color  s~     ,,. 	JG"&++ J!!'>4AQR"6w"? JJC$$UNd3%LIJJ	Jr'   c           	          d}| j                         D ]H  }| j                  ||dt        |             t        |      D ]  \  }}| j	                  ||d|         J y)zTests if the aalines drawn contain any gaps.

        Draws aalines around the border of the given surface and checks if
        all borders of the surface contain any gaps.

        See: #512
        rv  Tr  N)r  ri   r&   r0   r   r  s        r!   test_aalines__gapszAALinesMixin.test_aalines__gaps  sn     ),,. 	FGg~tWW=MN27; F
U  $seEF	Fr'   c           	      $   t        j                  d      }t        j                  d      }dx}}t        j                  d||f      }|dz   |dz   f|dz
  |dz
  ffD ]  }t        j                  |dd      }|j	                         }t        |      D ]|  }	|	|_        |j                  |j                  |j                  f}
|
d   }	dD ]F  }|j                  |       | j                  ||||
      }t        |||	      }| j                  ||       H ~  y	)
zEnsures draw aalines returns the correct bounding rect.

        Tests lines with endpoints on and off the surface and blending
        enabled and disabled.
        r   r   r   r$   r   r   rS  r  N)rE   r   rF   rw   r  r*   r   r   r   r   r   ri   rM   r   )rz   r  rG   r   r   rl  rB   r   r[  r/   r=   r7  r_  r`  s                 r!   test_aalines__bounding_rectz(AALinesMixin.test_aalines__bounding_rect  s(    \\%(
\\&)
;;vv7 ai!,uqy&1*.EF 	CDnnT1b1G((*I 4I> C"%''(:K:KL!f+ 	CFLL,$($5$5gz6SV$WM %9*c$RM$$]MB	CC	Cr'   c                    dx}t        j                  d      }t        j                  d      }t        j                  |f      }|j                  |       t        j                  dd      }|j                         j                  |_        |j                         }t        |      D ]1  }||_        |j                  |j                  |j                  f}dD ]  }	|j                  d       |j                  |       | j                  |||	|       t        |||d      }
|j                  |       |j                  |       | j                  |||	|       |j                          fd	t        |      D        D ]K  }||
v r#| j!                  |j#                  |      ||       *| j%                  |j#                  |      ||       M |j'                           4 y)
z4Ensures draw aalines respects a surface's clip area.r   r   r	   r$   rc  r  NFc              3   F   K   | ]  }t              D ]  }||f 
  y wr!  r"  rf  s      r!   r%  z:AALinesMixin.test_aalines__surface_clip.<locals>.<genexpr>A  rh  r&  )rE   r   rw   r   rF   r  r   r.  r*   r   r   ri  ri   r>   r6   r   r  r   r   r7   )rz   rj  r  r   r   rk  rl  r   r=   r7  rm  rn  rg  s               @r!   test_aalines__surface_clipz'AALinesMixin.test_aalines__surface_clip  s   ||E*W-..%0]#KK1	"++-44	>># 39= 	!F$HO??HOOX5G5GHC' !   &]+!!'<E/]Iu  ]+  +!!'<E O5<N PB\)++GNN2,>rR(();]BO	P  9!	!r'   N)rP   rQ   rR   rS   r+  r-  r/  r1  r3  r6  r8  r:  r<  r>  r@  rB  rE  rG  rJ  rL  rN  rP  rR  rT  rW  rU   r'   r!   r(  r(  p  s{    
88L<	8."B Q6:.:6<B)DV:2> <4<B:JF#CJ-!r'   r(  c                       e Zd ZdZy)DrawAALinesTestzTest draw module function aalines.

    This class inherits the general tests from AALinesMixin. It is also the
    class to add any draw.aalines specific tests to.
    Nrr  rU   r'   r!   rY  rY  T  rs  r'   rY  rp   )r   rp   r   r  r   ru   r   r-  c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)DrawPolygonMixinzfMixin tests for drawing polygons.

    This class contains all the general polygon drawing tests.
    c                 8    t        j                  d      | _        y )NrR  )rE   rw   r   rz   s    r!   setUpzDrawPolygonMixin.setUpv  s    ~~h/r'   c                     | j                  t        j                  d      ddd      }| j                  |t        j                         y)z.Ensures draw polygon accepts the correct args.ro   rq   r5  r   Nr[   rE   rw   rx   rF   ry   s     r!   test_polygon__argsz#DrawPolygonMixin.test_polygon__argsy  s;    ''NN6"N4La
 	k6;;7r'   c                     | j                  t        j                  d      dd      }| j                  |t        j                         y)z6Ensures draw polygon accepts the args without a width.r}   r  r5  Nra  ry   s     r!    test_polygon__args_without_widthz1DrawPolygonMixin.test_polygon__args_without_width  s9    ''NN6"M3K
 	k6;;7r'   c                     t        j                  d      }t        j                  d      }d}|||dd|||dg}|D ]4  } | j                  di |}| j	                  |t         j
                         6 y)	z^Ensures draw polygon accepts the correct kwargs
        with and without a width arg.
        r   r   r5  r   r   r8   r8  r   )r   r8   r8  NrU   )rE   rw   r   r[   rx   rF   r:  s          r!   test_polygon__kwargsz%DrawPolygonMixin.test_polygon__kwargs  s|     ..(X&)%6AN%6B

 " 	<F+$++5f5K!!+v{{;	<r'   c                     | j                  dt        j                  d      dd      }| j                  |t        j                         y)z6Ensures draw polygon's kwargs are not order dependent.r  rt   r   r   r   r   )r8   r   r   r8  Nra  ry   s     r!   &test_polygon__kwargs_order_independentz7DrawPolygonMixin.test_polygon__kwargs_order_independent  sB    ''NN6*+	 ( 
 	k6;;7r'   c                    t        j                  d      }t        j                  d      }| j                  t              5  | j                  ||      }ddd       | j                  t              5  | j                  |      }ddd       | j                  t              5  | j                         }ddd       y# 1 sw Y   gxY w# 1 sw Y   DxY w# 1 sw Y   yxY w)z7Ensures draw polygon detects any missing required args.r   r   NrE   rw   r   r   r   r[   r  s       r!   test_polygon__args_missingz+DrawPolygonMixin.test_polygon__args_missing  s    ..(V$y) 	<++GU;K	< y) 	5++G4K	5 y) 	.++-K	. 	.	< 	<	5 	5	. 	.s$    B90CC9CCCc                    t        j                  d      t        j                  d      ddd}dD ]N  }t        |      }|j	                  |       | j                  t              5   | j                  di |}ddd       P y# 1 sw Y   [xY w)	z9Ensures draw polygon detects any missing required kwargs.r   r   r  r   rf  )r8  r8   r   NrU   )rE   rw   r   r   r   r   r   r[   r   s        r!   test_polygon__kwargs_missingz-DrawPolygonMixin.test_polygon__kwargs_missing  s     ~~f-\\%(.	
 3 	BD!&\Nt$""9- B/d//A.AB B		BB Br  c                 F   t        j                  d      }t        j                  d      }d}| j                  t              5  | j                  |||d      }ddd       | j                  t              5  | j                  ||d      }ddd       | j                  t              5  | j                  |d|      }ddd       | j                  t              5  | j                  d||      }ddd       y# 1 sw Y   xY w# 1 sw Y   xxY w# 1 sw Y   SxY w# 1 sw Y   yxY w)	z/Ensures draw polygon detects invalid arg types.r}   r   )r   r   r   r   Nr   r   r  rl  )rz   r   r8   r8  r9   s        r!   test_polygon__arg_invalid_typesz0DrawPolygonMixin.test_polygon__arg_invalid_types  s   ..(V$)y) 	I++GUFCHK	I y) 	G++GUIFK	G y) 	B++GS&AK	B y) 	I++L%HK	I 	I	I 	I	G 	G	B 	B	I 	Is0   C34C?%DD3C<?DDD c                 6   t        j                  d      }t        j                  d      }d}d}t         j                  |||d|d||d||d|d|||ddg}|D ]2  }| j                  t              5   | j
                  d
i |}d	d	d	       4 y	# 1 sw Y   ?xY w)z1Ensures draw polygon detects invalid kwarg types.ro   r	   )r$   r   r  r   rf  r   )r  r  r  r  NrU   rl  )rz   r   r8   r8  r   r   r   r9   s           r!   !test_polygon__kwarg_invalid_typesz2DrawPolygonMixin.test_polygon__kwarg_invalid_types  s    ..(W%) ">> 	 # 	 #,	  %6CP'
, " 	:F""9- :/d//9&9: :	:: :r  c                     t        j                  d      }t        j                  d      }d}|||ddd|||ddg}|D ]2  }| j                  t              5   | j
                  di |}ddd       4 y# 1 sw Y   ?xY w)	z1Ensures draw polygon detects invalid kwarg names.r   r   )r   r   r   r   )r   r8   r8  r   r   )r   r8   r8  r   NrU   rl  r:  s          r!    test_polygon__kwarg_invalid_namez1DrawPolygonMixin.test_polygon__kwarg_invalid_name  s    ..(V$) #   %6aP	
 " 	:F""9- :/d//9&9: :	:: :   A44A=	c                    t        j                  d      }d}d}d}||||d}dD ]  }|j                  |       d|k(  r | j                  |fi |}nKd|k(  r | j                  ||fi |}n1d|k(  r | j                  |||fi |}n | j                  ||||fi |}| j	                  |t         j
                          y	)
z9Ensures draw polygon accepts a combination of args/kwargsr   r   ri  r   rf  r   r8   r8  N)rE   rw   r   r[   rx   rF   )rz   r   r8   r8  r   r   r   r9   s           r!   test_polygon__args_and_kwargsz.DrawPolygonMixin.test_polygon__args_and_kwargs  s    ..( )$uQVW; 	<DJJtD /d//B6BD/d//I&IT!/d//Q&Q/d//XQWX!!+v{{;	<r'   c                 l   t        j                  d      }t        j                  d      }d}||ddd}|d   d   }d	D ]t  }|j                  |       ||d
<   |dk\  r|n|} | j                  di |}| j                  |j                  |      |       | j                  |t         j                         v y)z4Ensures draw polygon accepts different width values.r   r   r   r[  Nrf  r8  r   r  r   rU   )	rE   r   rw   r   r[   r   r   rx   rF   )	rz   r   r   r8   r   r/   r   r   r9   s	            r!    test_polygon__valid_width_valuesz1DrawPolygonMixin.test_polygon__valid_width_values#  s    W-..(!6	
 Xq!3 	<ELL'#F7O&+qjUmN+$++5f5KW^^C0.A!!+v{{;	<r'   c           	         d}t        j                  d      }t        j                  d      }||ddd}t        t        t        t        ft        t        t        t        ft
        t
        t
        t
        ft        t
        t        t
        ff}d}t        t        f}|D ]  }|D ]  }	|	d   }
t        |	      D cg c]  \  }} ||   |       }}}|D ]q  }|j                  |        ||      |d<    | j                  d	i |}| j                  |j                  |
      |       | j                  |t         j                         s   yc c}}w )
z6Ensures draw polygon accepts different points formats.r   r   r   Nr   rf  rZ  r8  rU   )rE   r   rw   r  r  r   r_  r   r[   r   r   rx   rF   r`  s                   r!   !test_polygon__valid_points_formatz2DrawPolygonMixin.test_polygon__valid_points_format:  sG   *W-..(#	
 E5%(4t$gw07E7+	

 DM	% 	DJ& D"1I	9B69JK2-*Q-+KK ) DHLL/'/'7F8$"3$"3"3"=f"=K$$W^^I%>O))+v{{CD	D	D LrC  c                 $   t        j                  d      t        j                  d      ddd}dddd	d
ddhfd	d
dddfh ddddddf}|D ]7  }||d<   | j                  t              5   | j
                  di |}ddd       9 y# 1 sw Y   DxY w)z>Ensures draw polygon handles invalid points formats correctly.r   r   Nr   rf  )r   r   r  )r   r   rk  )r   r   rm  r   r   ru   rp   r   >   r   r   r}   r   r   r   r  r8  rU   rl  rp  s        r!   $test_polygon__invalid_points_formatsz5DrawPolygonMixin.test_polygon__invalid_points_formatse  s     ~~f-\\%(	
 #'&VaV$Vq\*,aA!$
 " 	:F%F8""9- :/d//9&9: :	:: :s   (BB	c                     t        j                  d      t        j                  d      ddd}d}|D ]N  }t        t        fD ]=  } ||      |d<   | j                  t              5   | j                  di |}ddd       ? P y# 1 sw Y   LxY w)	z=Ensures draw polygon handles invalid points values correctly.r   r   Nr   rf  )rU   rt  )r   r   r8  rU   )rE   rw   r   r  r  r   ru  r[   )rz   r   rq  r8  r  r9   s         r!   #test_polygon__invalid_points_valuesz4DrawPolygonMixin.test_polygon__invalid_points_values~  s     ~~f-\\%(	

 " 	>F"DM >#+F#3x &&z2 >"3$"3"3"=f"=K> >>	>> >rH  c                    t        j                  d      }t        j                  d      }t        j                  d      }|dddd}|d   d   }d	d
|j                  |      |f}|D ]  }|j	                  |       ||d<   t        |t              r|j                  |      }n|} | j                  di |}	| j                  |j                  |      |       | j                  |	t         j                          y)z5Ensures draw polygon accepts different color formats.r	   r   r   Nr[  r   rf  r8  r   r   r8   rU   )rE   r   rw   r   r   r   r   r   r[   r   r   rx   rF   )
rz   r   r   r   r   r/   r  r8   r   r9   s
             r!   !test_polygon__valid_color_formatsz2DrawPolygonMixin.test_polygon__valid_color_formats  s    ll7+W-..(6	
 Xq!OOK(	
  	<ELL'#F7O%%!(!2!25!9!,+$++5f5KW^^C0.A!!+v{{;	<r'   c                     t        j                  d      dddd}d| fD ]7  }||d<   | j                  t              5   | j                  di |}ddd       9 y# 1 sw Y   DxY w)	z=Ensures draw polygon handles invalid color formats correctly.r   Nr[  r   rf  r   r8   rU   )rE   rw   r   r   r[   r  s       r!   #test_polygon__invalid_color_formatsz4DrawPolygonMixin.test_polygon__invalid_color_formats  s{     ~~f-6	
  #Dk 	:N,F7O""9- :/d//9&9: :	:: :r  c                     | j                  | j                  t        t        d       t	        d      D ]C  }t	        d      D ]3  }| j                  | j                  j                  ||f      t               5 E y )Nr   r   )r[   r   r  SQUAREr   r   r   rz   r   r   s      r!   test_draw_squarez!DrawPolygonMixin.test_draw_square  si    $,,VQ7 q 	CA1X C  !4!4aV!<cBC	Cr'   c           	         t         j                  j                  | j                  t        dd       | j                  | j                  t        t        d       t        D ]C  \  }}| j                  | j                  j                  ||f      t        t        ||f             E t        dd      D ]D  }t        dd      D ]3  }| j                  | j                  j                  ||f      t               5 F y )Nr  r   r  ru   r   )rE   r   r)   r   r  r[   GREENDIAMONDr   r   strr   r  s      r!   test_draw_diamondz"DrawPolygonMixin.test_draw_diamond  s    sNA>$,,w: 	RDAqT\\00!Q8%S!Q[Q	Rq! 	EA1a[ E  !4!4aV!<eDE	Er'   c           
         t         j                  j                  | j                  t        dd       | j                  | j                  t        t        D cg c]	  \  }}|df c}}d       d}t        |dz         D ]  }| j                  | j                  j                  |df      t               | j                  | j                  j                  |df      t               | j                  | j                  j                  |df      t                t         j                  j                  | j                  t        dd       | j                  | j                  t        t        D cg c]	  \  }}|df c}}d       t        |dz         D ]  }| j                  | j                  j                  |df      t               | j                  | j                  j                  |df      t               | j                  | j                  j                  |df      t                t         j                  j                  | j                  t        dd       | j                  | j                  t        t        D cg c]	  \  }}d|f c}}d       t        |dz         D ]  }| j                  | j                  j                  d|f      t               | j                  | j                  j                  d|f      t               | j                  | j                  j                  d|f      t                t         j                  j                  | j                  t        dd       | j                  | j                  t        t        D cg c]	  \  }}d|f c}}d       t        |dz         D ]  }| j                  | j                  j                  d|f      t               | j                  | j                  j                  d|f      t               | j                  | j                  j                  d|f      t                y c c}}w c c}}w c c}}w c c}}w )	Nr  r   ru   r-  r   rp   r   r   )rE   r   r)   r   r  r[   r  CROSSr   r   r   )rz   r   _y
cross_size_xr   s         r!    test_1_pixel_high_or_wide_shapesz1DrawPolygonMixin.test_1_pixel_high_or_wide_shapes  sE   sNA>$,,E/J51bA/JAN
zA~& 	?AT\\00!Q8#>T\\00!Q8%@T\\00!Q8#>	? 	sNA>$,,E/J51bA/JANzA~& 	?AT\\00!Q8#>T\\00!Q8%@T\\00!Q8#>	? 	sNA>$,,E/J52qA/JANzA~& 	?AT\\00!Q8#>T\\00!Q8%@T\\00!Q8#>	? 	sNA>$,,E/J52qA/JANzA~& 	?AT\\00!Q8#>T\\00!Q8%@T\\00!Q8#>	?/ 0K 0K 0K 0Ks   Q(Q9Q
Qc           
         t         j                  j                  | j                  t        dd       | j                  | j                  t        t        d       t        dd      D cg c]  }|df c}t        dd      D cg c]  }d|f c}z   }t        d      D ]  }t        d      D ]  }||f|v r2| j                  | j                  j                  ||f      t               ;|t        dd      v r|d	k  s|t        dd      v r7|d	k  r2| j                  | j                  j                  ||f      t               | j                  | j                  j                  ||f      t                 t         j                  j                  | j                  t        dd       | j                  | j                  t        t        d       t        dd      D cg c]  }|df c}t        dd      D cg c]  }d|f c}z   }t        d      D ]  }t        d      D ]  }|t        dd      v r|d	k  s|t        dd      v rD|d	k  r?| j                  | j                  j                  ||f      t        t        ||f      
       h| j                  | j                  j                  ||f      t                 yc c}w c c}w c c}w c c}w )znon-regression on issue #234 : x and y where handled inconsistently.

        Also, the result is/was different whether we fill or not the polygon.
        r  r   r   r-  rp   rr   ru   r   rQ  r  N)rE   r   r)   r   r  r[   r  r  r   r   r   r  )rz   r   r   insides       r!   test_draw_symetric_crossz)DrawPolygonMixin.test_draw_symetric_cross  sY    	sNA>$,,ua8"'1+.Q1a&.%1+1NQ1a&1NNr 		GA2Y Gq6V#$$T\\%8%8!Q%@#F5A;&1q5a5A;6F1q5$$T\\%8%8!Q%@%H $$T\\%8%8!Q%@#FG		G 	sNA>$,,ua8"'1+.Q1a&.%1+1NQ1a&1NNr 		GA2Y Gq!$QAq!4DQ$$++QF3UQF % 
 $$T\\%8%8!Q%@#FG		G! /1N /1Ns   %J7 J<K0Kc                    t        j                  d      }d|j                  dz
  df|j                  dz
  dfdd|j                  dz
  fd|j                  dz
  fg}t         j                  j                  | j                  t        dd       | j                  | j                  t        |dd d       t        d	      D ]3  }| j                  | j                  j                  |df      t               5 t        d|j                  dz
  dz         D ]3  }| j                  | j                  j                  |df      t               5 t         j                  j                  | j                  t        dd       | j                  | j                  t        |d       t        d|j                  dz
  dz         D ]3  }| j                  | j                  j                  |df      t               5 y)
znon-regression on issue #313)r   r   r   r   r$   r   r   r   r   r   Nr   )rE   rF   r   r   r   r)   r   r  r[   r  r   r   r   )rz   r)   	path_datar   s       r!   test_illumine_shapez$DrawPolygonMixin.test_illumine_shape  s   {{>*ZZ!^QZZ!^U#DKK!O$a 
	6 	sNA> 	$,,y!}a@r 	AAT\\00!Q8%@	Aq$**q.1,- 	AAT\\00!Q8%@	A 	sNA>$,,y!<q$**q.1,- 	AAT\\00!Q8%@	Ar'   c                 8      j                  t         fd       y )Nc                  H     j                   j                  t        dd      S )N)r$   )r   r   rR  r   r   )r[   r   r  r^  s   r!   <lambda>z6DrawPolygonMixin.test_invalid_points.<locals>.<lambda>I  s     D%%c#BA r'   )r   r   r^  s   `r!   test_invalid_pointsz$DrawPolygonMixin.test_invalid_pointsF  s    	
r'   c           
         t        j                  d      }t        j                  d      }dx}}dx}}||f||ff}t        j                  ddd      }|j                         }	|	j	                  |dz  d	z   |dz  d	z         }
t        |	      t        |
      z   D ]  }t        D ]  }|D ]  \  }}t        j                  d
||f      }t        |||       |j                  |j                  |j                  f}t        d      D ]M  }|j                  |       | j                  ||||      }t        |||d         }| j!                  ||d|        O    y)zEnsures draw polygon returns the correct bounding rect.

        Tests polygons on and off the surface and a range of width/thickness
        values.
        r   r   r   rQ  rR  r   rS  ru   r   r$   r   
thickness=N)rE   r   rw   r  rT  r*   rU  rF   rV  r   r   r   r   r   r[   rM   r   )rz   polygon_colorrG   rW  rX  rY  rZ  r   r   r[  r\  r/   r]  r   r   rl  verticesr  r_  r`  s                       r!   test_polygon__bounding_rectz,DrawPolygonMixin.test_polygon__bounding_rectN  s    U+\\'*
!""	J!""	JZ(9j*AB..1b1$$&	 $$Y]Q%6
Q8JK/
(23 $	C 1 %* ME6%{{6E6?CHHdC0 !((  ,, H &+1X 	Z0(,(9(9#]Hi) )=#Z!) (())(4$	r'   c                    dx}t        j                  d      }t        j                  d      }t        j                  |f      }|j                  |       t        j                  dd      }|j                         j                  |_        |j                         }dD ]'  }t        |      D ]  }||_        |j                  |j                  |j                  |j                  f}	|j                  d       |j                  |       | j                  |||	|       t        |||      }
|j                  |       |j                  |       | j                  |||	|       |j!                          fdt#        |      D        D ]-  }||
v r|}n|}| j%                  |j'                  |      ||       / |j)                           * y)	zuEnsures draw polygon respects a surface's clip area.

        Tests drawing the polygon filled and unfilled.
        r   r   r	   r$   rz  rr   r   Nc              3   F   K   | ]  }t              D ]  }||f 
  y wr!  r"  rf  s      r!   r%  z>DrawPolygonMixin.test_polygon__surface_clip.<locals>.<genexpr>  rh  r&  )rE   r   rw   r   rF   r  r   r.  r*   r   r   r   r   ri  r[   r>   r6   r   r   r   r7   )rz   rj  r  r   r   rk  rl  r   r   r  rm  rn  r   rg  s                @r!   test_polygon__surface_clipz+DrawPolygonMixin.test_polygon__surface_clip  s   
 U+W-..%0]#KK0	"++-44	>># $	!E6yA "! #)$$%%((''	   &]+!!'=(EJ/	R ]+  +!!'=(EJ O5<N MB\))6)6$$W^^B%7LM  E"!$	!r'   c                    d}d}d}d}d}d}dx}}t        j                  ||f      d}	d	t         j                  j                  d
d
||fd
       fd}
fd}fd}fd}fd}fd}fd}| j	                  |	|||f        |
|        t         j                  j                  d
d
||fd
       | j	                  |	|||f        ||         ||        t         j                  j                  d
d
||fd
       | j	                  |	|||f        ||         ||        t         j                  j                  d
d
||fd
       | j	                  |	|||f        ||         ||        y)zy
        Ensures draw polygon works correctly with large points.
        Testing the drawings of filled polygons
        )X  rs   )rs   r  )  順 )p`y)r  r  )r  r  i  r   r%  r   c                     | j                  j                  d             | j                  j                  d             y )N)  rs   )rs   r  r   r   rz   r   r   s    r!   extreme_pointszGDrawPolygonMixin.test_polygon_large_coords_3989.<locals>.extreme_points  s5    W^^I6>W^^I6>r'   c                 H    | j                  j                  d             y )N)r     r  r  s    r!   extreme_negative_passzNDrawPolygonMixin.test_polygon_large_coords_3989.<locals>.extreme_negative_pass  s    W^^I6>r'   c                 H    | j                  j                  d             y )Nr   r  r   r  s    r!   extreme_negative_failzNDrawPolygonMixin.test_polygon_large_coords_3989.<locals>.extreme_negative_fail  s    v 6>r'   c                 H    | j                  j                  d             y N)r  r  r  r  s    r!   extreme_x_passzGDrawPolygonMixin.test_polygon_large_coords_3989.<locals>.extreme_x_pass      W^^J7?r'   c                 H    | j                  j                  d             y )N)r  r  r  r  s    r!   extreme_x_failzGDrawPolygonMixin.test_polygon_large_coords_3989.<locals>.extreme_x_fail      z :EBr'   c                 H    | j                  j                  d             y r  r  r  s    r!   extreme_y_passzGDrawPolygonMixin.test_polygon_large_coords_3989.<locals>.extreme_y_pass  r  r'   c                 H    | j                  j                  d             y )N),  r  r  r  s    r!   extreme_y_failzGDrawPolygonMixin.test_polygon_large_coords_3989.<locals>.extreme_y_fail  r  r'   N)rE   rw   r   r)   r[   )rz   point_apoint_bextreme_points_coordsextreme_negative_coordsextreme_negative_xextreme_negative_yr$  r)  r	   r  r  r  r  r  r  r  r   r   s                    @@r!   test_polygon_large_coords_3989z/DrawPolygonMixin.test_polygon_large_coords_3989  s   
  /"3--..&&!12 	%!Q)?C	?
	?	?	@	C	@	C
 	'57G=R*STt%!Q)?C'57G=T*UVd#d#%!Q)?C'57G=O*PQtt%!Q)?C'57G=O*PQttr'   N)rP   rQ   rR   rS   r_  rb  rd  rg  rj  rm  ro  rq  rs  ru  rx  rz  r|  r~  r  r  r  r  r  r  r  r  r  r  r  r  rU   r'   r!   r\  r\  p  s    
088<"	8.B I,:@:(<,<.)DV:2>,<B:CE?>!GF+AZ
5n3!nAr'   r\  c                       e Zd ZdZy)DrawPolygonTestzTest draw module function polygon.

    This class inherits the general tests from DrawPolygonMixin. It is also
    the class to add any draw.polygon specific tests to.
    Nrr  rU   r'   r!   r  r     rs  r'   r  c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)DrawRectMixinz`Mixin tests for drawing rects.

    This class contains all the general rect drawing tests.
    c                     | j                  t        j                  d      dt        j                  dd      dddddd		      }| j	                  |t        j                         y
)z+Ensures draw rect accepts the correct args.r}   )r   rr   r      r$   r   ru   r   rp   r   r   NrY   rE   rw   rF   rx   ry   s     r!   test_rect__argszDrawRectMixin.test_rect__args  sU    nnNN6"KK'

 	k6;;7r'   c                     | j                  t        j                  d      dt        j                  dd            }| j	                  |t        j                         y)z?Ensures draw rect accepts the args without a width and borders.rZ  r%  r$   r   Nr  ry   s     r!   test_rect__args_without_widthz+DrawRectMixin.test_rect__args_without_width,  sA    nnNN6"NFKK4O
 	k6;;7r'   c           
      4   t        j                  d      t        j                  d      t        j                  dd      ddddd	d
d	t        j                  d      dddg}|D ]4  } | j                  di |}| j                  |t         j                         6 y)zmEnsures draw rect accepts the correct kwargs
        with and without a width and border_radius arg.
        r   r   r$   r   r   rr   r   r   r  r   	r   r8   r)   r   border_radiusborder_top_left_radiusborder_top_right_radiusborder_bottom_left_radiusborder_bottom_right_radius)r   r  r  r   r   NrU   )rE   rw   r   rF   rY   rx   r   s       r!   test_rect__kwargszDrawRectMixin.test_rect__kwargs4  s     ">>&1e,FF3!#*++--/./
 ">>&1&$
& " 	<F($..262K!!+v{{;	<r'   c                     | j                  ddt        j                  d      ddddt        j                  dd      d	
	      }| j	                  |t        j                         y)z3Ensures draw rect's kwargs are not order dependent.)r   r   ru   rr   r   r   r  r   r   r$   r  )	r8   r  r   r  r   r  r  r)   r  Nr  ry   s     r!   #test_rect__kwargs_order_independentz1DrawRectMixin.test_rect__kwargs_order_independentP  sZ    nnNN6*#$$&'(VV,&( % 

 	k6;;7r'   c                    t        j                  d      }| j                  t              5  | j	                  |t        j
                  d            }ddd       | j                  t              5  | j	                  |      }ddd       | j                  t              5  | j	                         }ddd       y# 1 sw Y   gxY w# 1 sw Y   DxY w# 1 sw Y   yxY w)z4Ensures draw rect detects any missing required args.r   r   N)rE   rw   r   r   rY   r   r   s      r!   test_rect__args_missingz%DrawRectMixin.test_rect__args_missing`  s    ..(y) 	I..&,,w2GHK	I y) 	2..1K	2 y) 	+..*K	+ 	+	I 	I	2 	2	+ 	+r   c           
      N   t        j                  d      t        j                  d      t        j                  dd      dddddd	d
	}dD ]N  }t	        |      }|j                  |       | j                  t              5   | j                  di |}ddd       P y# 1 sw Y   [xY w)z6Ensures draw rect detects any missing required kwargs.r   r   r$   r}   r   rr   r   r  r   r  r   NrU   )	rE   rw   r   rF   r   r   r   r   rY   r   s        r!   test_rect__kwargs_missingz'DrawRectMixin.test_rect__kwargs_missingm  s     ~~f-\\%(KK/&''))+*+

 1 	?D!&\Nt$""9- ?,dnn>~>? ?		?? ?s   =BB$	c                    t        j                  d      }t        j                  d      }t        j                  dd      }| j	                  t
              5  | j                  |||dd      }ddd       | j	                  t
              5  | j                  |||dd      }ddd       | j	                  t
              5  | j                  |||dd	      }ddd       | j	                  t
              5  | j                  |||dd
      }ddd       | j	                  t
              5  | j                  |||dd      }ddd       | j	                  t
              5  | j                  |||dd      }ddd       | j	                  t
              5  | j                  ||ddd      }ddd       | j	                  t
              5  | j                  |d|dd      }ddd       | j	                  t
              5  | j                  |||dd      }ddd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   XxY w# 1 sw Y   1xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   yxY w)z,Ensures draw rect detects invalid arg types.ro   r   r   ru   rad)r  N)r  )r  r   )r  rn  r   r   r-  r   rp   rz  rr   rE   rw   r   rF   r   r   rY   r   s        r!   test_rect__arg_invalid_typesz*DrawRectMixin.test_rect__arg_invalid_types  sz   ..(W%{{66*y) 	..aE ) K	 y) 	..a5 ) K	 y) 	..a ) K	 y) 	..a ) K	 y) 	I..%q%HK	I y) 	G..%sAFK	G y) 	J..%AqIK	J y) 	C..#tQBK	C y) 	C..udArBK	C 	CQ	 		 		 		 		I 	I	G 	G	J 	J	C 	C	C 	Csl   H
H>H+2H8&III?I*2I6HH(+H58IIII'*I36I?c                    t        j                  d      }t        j                  d      }t        j                  dd      }t         j                  ||ddddd	d
d	|d|ddddd	d
d	||dddddd	d
d	|||ddddd	d
d	|||ddddd	d
d	|||ddddd	d
d	|||ddddd	d
d	|||dddddd
d	|||ddddd	dd	g	}|D ]2  }| j	                  t
              5   | j                  di |}ddd       4 y# 1 sw Y   ?xY w)z.Ensures draw rect detects invalid kwarg types.r   r   r$   r   r   rr   r   r   r  r   r  r   )r   r   ru   r   g      %@      @r  r  r  NrU   r  r   s          r!   test_rect__kwarg_invalid_typesz,DrawRectMixin.test_rect__kwarg_invalid_types  s   ..(U#{{66* ">>!#*++--/./
 #!#*++--/./
 #!!#*++--/./
 #!#*++--/./
 #!%*++--/./
 #!#*-+--/./
 #!#*++.-/./
 #!#*++--0./
 #!#*++--/.1
sd
L " 	7F""9- 7,dnn6v67 7	77 7s   C,,C5	c                 2   t        j                  d      }t        j                  d      }t        j                  dd      }|||ddddd	d
dd
|||ddg}|D ]2  }| j	                  t
              5   | j                  di |}ddd       4 y# 1 sw Y   ?xY w)z.Ensures draw rect detects invalid kwarg names.r   r	   r$   ro   r   rr   r   r   r  r   )
r   r8   r)   r   r  r  r  r  r  r   r   NrU   r  r   s          r!   test_rect__kwarg_invalid_namez+DrawRectMixin.test_rect__kwarg_invalid_name#  s    ..(W%{{66* #!#*++--/./  %!L
  " 	7F""9- 7,dnn6v67 7	77 7s   /BB	c                    t        j                  d      }d}t        j                  dd      }d}||||d}dD ]  }|j                  |       d|k(  r | j                  |fi |}nKd|k(  r | j                  ||fi |}n1d	|k(  r | j                  |||fi |}n | j                  ||||fi |}| j                  |t         j                          y
)z6Ensures draw rect accepts a combination of args/kwargsr   )r   r   r   r   r   )ru   r   r   r   r   r8   r)   N)rE   rw   rF   r   rY   rx   r   s           r!   test_rect__args_and_kwargsz(DrawRectMixin.test_rect__args_and_kwargs<  s    ..("{{66*$udUS9 	<DJJtD ,dnnW??D,dnnWeFvF4,dnnWeTLVL,dnnWeT5SFS!!+v{{;	<r'   c                    d}t        j                  d      }t        j                  d      }d}||t        j                  |d      dd}dD ]t  }|j	                  |       ||d	<   |d
k\  r|n|} | j
                  di |}| j                  |j                  |      |       | j                  |t         j                         v y)z1Ensures draw rect accepts different width values.r   r   r   )r   ru   rp   r   r}   Nr   r   r   r   rU   	rE   r   rw   rF   r   rY   r   r   rx   r   s	            r!   test_rect__valid_width_valuesz+DrawRectMixin.test_rect__valid_width_valuesQ  s    W-..(KKV,	
 6 	<ELL'#F7O&+qjUmN($..262KW^^C0.A!!+v{{;	<r'   c                    d}t        j                  d      }t        j                  d      }t        j                  d      }||ddd}t        j                  |d      |df|d   |d	   d
d
f|dgf}|D ]k  }|j	                  |       ||d<    | j
                  di |}| j                  |j                  |      |       | j                  |t         j                         m y)z1Ensures draw rect accepts different rect formats.r   r   r   r   Nr   r   r}   r   rp   r]  r)   rU   r  r   s	            r!   test_rect__valid_rect_formatsz+DrawRectMixin.test_rect__valid_rect_formatsh  s    h/W-..($~tVWXKKV$&MVSVQ"*	
  	<DLL'!F6N($..262KW^^C0.A!!+v{{;	<r'   c                    t        j                  d      t        j                  d      ddd}g dgddgg dg d	h d
g df}|D ]7  }||d<   | j                  t              5   | j
                  di |}ddd       9 y# 1 sw Y   DxY w)z9Ensures draw rect handles invalid rect formats correctly.r   r   Nr   r   r   ru   r   r   >   r   ru   rp   r   )r   ru   rp   4r)   rU   )rE   rw   r   r   r   rY   )rz   r   invalid_fmtsr)   r9   s        r!   test_rect__invalid_rect_formatsz-DrawRectMixin.test_rect__invalid_rect_formats  s     ~~f-\\%(	
 CF
 ! 	7D!F6N""9- 7,dnn6v67 7	77 7s   !A??B	c                    d}t        j                  d      }t        j                  d      }t        j                  d      }|dt        j                  |d      dd}dd	|j	                  |      |f}|D ]  }|j                  |       ||d
<   t        |t              r|j                  |      }n|} | j                  di |}	| j                  |j                  |      |       | j                  |	t         j                          y)z2Ensures draw rect accepts different color formats.r   r   r   r   Nrp   r   r   r   r   r   r   r8   rU   )rE   r   rw   rF   r   r   r   r   r   rY   r   r   rx   )
rz   r/   	red_colorr   r   r   r   r8   r   r9   s
             r!   test_rect__valid_color_formatsz,DrawRectMixin.test_rect__valid_color_formats  s    LL'	W-..(KKV,	
 -wy/I9U 	<ELL'#F7O%%!(!2!25!9!*($..262KW^^C0.A!!+v{{;	<r'   c                     d}t        j                  d      }|dt        j                  |d      dd}d| fD ]7  }||d<   | j                  t              5   | j
                  di |}ddd       9 y# 1 sw Y   DxY w)	z:Ensures draw rect handles invalid color formats correctly.r   r   Nr   r   r   r8   rU   )rE   rw   rF   r   r   rY   r   s         r!    test_rect__invalid_color_formatsz.DrawRectMixin.test_rect__invalid_color_formats  s    ..(KKV,	
  #Dk 	7N,F7O""9- 7,dnn6v67 7	77 7r   c                    dx\  | _         | _        | _        t        j                  | j                  t        j
                        | _        d| _        t        j                  dddd      }| j                  | j                  | j                  |d      }| j                  ||       t        j                  |      D ]9  }| j                  j                  |      }| j                  || j                         ; t        j                  |      D ]9  }| j                  j                  |      }| j                  || j                         ; t        j                   d      }| j                  j#                  |       t        j                  dd| j                   d	z
  d      }t        j                  dd
d| j                  dz
        }| j                  | j                  | j                  |d      }| j                  ||       |j$                  \  }}	|j&                  \  }
}| j                  | j                  j                  |dz
  |	f      |       | j                  | j                  j                  ||
z   |	f      |       t)        |||
z         D ]9  }| j                  | j                  j                  ||	f      | j                         ; | j                  | j                  | j                  |d      }| j                  ||       |j$                  \  }}	|j&                  \  }
}| j                  | j                  j                  ||	dz
  f      |       | j                  | j                  j                  ||	|z   f      |       t)        |	|	|z         D ]9  }| j                  | j                  j                  ||f      | j                         ; y )Nr  r  rr   r  r   r   r   r   ru   rp   r   )r$  r)  r  rE   rw   r   r  r8   rF   rY   r   r   r  r   r  r  r   r   r   rB   r   )rz   r)   r  rn  color_at_ptbgcolorhrectvrectr   r   r   r   r  s                r!   test_rect__fillzDrawRectMixin.test_rect__fill  s   4>> T[4>NN4>>6??C	%
{{2r2r*tyy$**dA>% **40 	6B))**2.K[$**5	6 ..t4 	9B))**2.KTZZ8	9 ,,w'		wAq$++/15Aq!T[[1_5tyy$**eQ?&}}1zz1))1q5!*5w?))1q5!*5w?q!a% 	CATYY--q!f5tzzB	C tyy$**eQ?&}}1zz1))1a!e*5w?))1a!e*5w?q!a% 	CATYY--q!f5tzzB	Cr'   c                 L   t        j                  dt         j                        | _        d| _        t        j
                  dddd      }| j                  | j                  | j                  |d      }| j                  ||       t        j                  |      D ]9  }| j                  j                  |      }| j                  || j                         ; t        j                  |      D ]9  }| j                  j                  |      }| j                  || j                         ; y )Nr  r  rr   8   r   r   )rE   rw   r   r  r8   rF   rY   r   r   rect_perimeter_ptsr   r  r  )rz   r)   r  rn  r  s        r!   test_rect__one_pixel_linesz(DrawRectMixin.test_rect__one_pixel_lines  s    NN:v?	%
{{2r2r*tyy$**dA>% //6 	6B))**2.K[$**5	6 ..u5 	9B))**2.KTZZ8	9r'   c           
         t        j                  d      }|j                  d       t        j                  ddd      }d}d}d}t         j                  j                  ||t        j                  dd||      |       t        |      D ]  }| j                  |j                  ||f      |       | j                  |j                  ||z
  dz
  |f      |       | j                  |j                  |||z
  dz
  f      |       | j                  |j                  ||z
  dz
  ||z
  dz
  f      |        | j                  |j                  ||f      d	       | j                  |j                  ||z
  dz
  |f      d	       | j                  |j                  |||z
  dz
  f      d	       | j                  |j                  ||z
  dz
  ||z
  dz
  f      d	       y )
Nr  r  r   r   r  rs   rr   r   r   r   )
rE   rw   r   r   r   r)   rF   r   r   r   )rz   r   r8   
rect_widthrect_heightr	  r  s          r!   test_rect__draw_line_widthz(DrawRectMixin.test_rect__draw_line_width  s   ..,WS#s+

UFKK1j+F
	
 z" 	AW^^QF3U;W^^Z!^a-?,CDeLW^^Qa!0C,DEuM
Q 2K!Oa4GHI5		 	Z(@A9MNNJ3a7DEy	
 	NNJj(@1(DEF		
 	NNJ3a7z9QTU9UVW	
r'   c           
      r   t        j                  d      }t        j                  d      }dx}}dx}}||f||ff}t        j                  ddd      }|j                         }	|	j	                  |dz  d	z   |dz  d	z         }
t        |	      t        |
      z   D ]  }t        D ]  }|D ]  \  }}t        j                  d
||f      }t        |||       t        d      D ]T  }|j                  |       | j                  ||||      }t        |||j                        }| j                  ||d|        V    y)zEnsures draw rect returns the correct bounding rect.

        Tests rects on and off the surface and a range of width/thickness
        values.
        r   r   r   rQ  rR  r   rS  ru   r   r$   r   r  N)rE   r   rw   r  rT  r*   rU  rF   rV  r   r   rY   rM   r   r   )rz   
rect_colorrG   rW  rX  rY  rZ  r   r   r[  r\  r/   r]  r   r   r)   r  r_  r`  s                      r!   test_rect__bounding_rectz&DrawRectMixin.test_rect__bounding_rect+  sc    \\%(
\\'*
!""	J!""	JZ(9j*AB..1b1$$&	 $$Y]Q%6
Q8JK/
(23 	C
 1 %* ME6!;;vv?DD$,%*1X 	Z0(,#Zy) )=#Z) (())(4		r'   c                 2   dx}t        j                  d      }t        j                  d      }t        j                  |f      }|j                  |       t        j                  dd      }|j                         j                  |_        |j                         }dD ]  }t        |      D ]  }||_        |j                  d       |j                  |       | j                  ||||       t        |||      }	|j                  |       |j                  |       | j                  ||||       |j                          fdt        |      D        D ]-  }
|
|	v r|}n|}| j                  |j                  |
      ||
       / |j!                            y)	zoEnsures draw rect respects a surface's clip area.

        Tests drawing the rect filled and unfilled.
        r   r   r	   r$   r  r   Nc              3   F   K   | ]  }t              D ]  }||f 
  y wr!  r"  rf  s      r!   r%  z8DrawRectMixin.test_rect__surface_clip.<locals>.<genexpr>  rh  r&  )rE   r   rw   r   rF   r  r   r.  r*   ri  rY   r>   r6   r   r   r   r7   )rz   rj  r  r   r   rk  	test_rectr   r   rm  rn  r   rg  s               @r!   test_rect__surface_clipz%DrawRectMixin.test_rect__surface_clipZ  sp   
 \\%(
W-..%0]#KK0	"++-44	NN$	 	!E6yA ! $*	   &]+w
IuE/YO ]+  +w
IuE O5<N MB\))3)6$$W^^B%7LM  9!	!r'   N)rP   rQ   rR   rS   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rU   r'   r!   r  r    sr    
8 8<88 +?*0Cdm7^72<*<.<.72<87"1Cf9,
:-^-!r'   r  c                       e Zd ZdZy)DrawRectTestzTest draw module function rect.

    This class inherits the general tests from DrawRectMixin. It is also the
    class to add any draw.rect specific tests to.
    Nrr  rU   r'   r!   r  r    rs  r'   r  c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)DrawCircleMixinzdMixin tests for drawing circles.

    This class contains all the general circle drawing tests.
    c                     | j                  t        j                  d      dddddddd	      }| j                  |t        j                         y)z-Ensures draw circle accepts the correct args.ro   rq   r$   rp   r   r   Nr]   rE   rw   rx   rF   ry   s     r!   test_circle__argsz!DrawCircleMixin.test_circle__args  sD    &&NN6"NFAq!Q1
 	k6;;7r'   c                     | j                  t        j                  d      ddd      }| j                  |t        j                         y)zKEnsures draw circle accepts the args without a width and
        quadrants.r}   r  r   r   Nr  ry   s     r!   test_circle__args_without_widthz/DrawCircleMixin.test_circle__args_without_width  s8     &&v~~f'=}fVWXk6;;7r'   c           	          | j                  t        j                  d      dddd      }| j                  |t        j                         | j                  |t        j                  dddd             y)z9Ensures draw circle accepts the args with negative width.r}   r  r   r   r,   r   Nr]   rE   rw   rx   rF   r   ry   s     r!   %test_circle__args_with_negative_widthz5DrawCircleMixin.test_circle__args_with_negative_width  s[    &&NN6"M61b
 	k6;;7fkk!Q1&=>r'   c                     | j                  t        j                  d      dddddddd	      }| j                  |t        j                         | j                  |t        j                  dddd             y)z9Ensures draw circle accepts the args with width > radius.r}   r  r   ru   rp   r   Nr  ry   s     r!   &test_circle__args_with_width_gt_radiusz6DrawCircleMixin.test_circle__args_with_width_gt_radius  sc    &&NN6"M61aAq!
 	k6;;7fkk!Q1&=>r'   c           
         t        j                  d      t        j                  d      dddddddd	t        j                  d	      d
dddg}|D ]4  } | j                  di |}| j	                  |t         j
                         6 y)zpEnsures draw circle accepts the correct kwargs
        with and without a width and quadrant arguments.
        r   r   r}   ru   r   TF	r   r8   r   radiusr   draw_top_rightdraw_top_leftdraw_bottom_leftdraw_bottom_rightr   r   r   )r   r8   r   r$  NrU   )rE   rw   r   r]   rx   rF   r   s       r!   test_circle__kwargsz#DrawCircleMixin.test_circle__kwargs  s     ">>&1h/ "&!%$)%)
 ">>&1$ 	
( " 	<F*$**4V4K!!+v{{;	<r'   c                     | j                  ddt        j                  d      dddddd	      }| j                  |t        j                         y	)
z5Ensures draw circle's kwargs are not order dependent.Fr  rt   r   r   ru   T)	r%  r8   r   r   r'  r   r(  r$  r&  Nr  ry   s     r!   %test_circle__kwargs_order_independentz5DrawCircleMixin.test_circle__kwargs_order_independent  sQ    && NN6*"# ' 

 	k6;;7r'   c                 4   t        j                  d      }t        j                  d      }| j                  t              5  | j                  ||d      }ddd       | j                  t              5  | j                  ||      }ddd       | j                  t              5  | j                  |      }ddd       | j                  t              5  | j                         }ddd       y# 1 sw Y   xY w# 1 sw Y   sxY w# 1 sw Y   PxY w# 1 sw Y   yxY w)z6Ensures draw circle detects any missing required args.r   r   r$   NrE   rw   r   r   r   r]   r  s       r!   test_circle__args_missingz)DrawCircleMixin.test_circle__args_missing  r  r  c           
      &   t        j                  d      t        j                  d      dddddddd	}d	D ]N  }t        |      }|j	                  |       | j                  t              5   | j                  di |}d
d
d
       P y
# 1 sw Y   [xY w)z8Ensures draw circle detects any missing required kwargs.r   r   r   ru   r   FTr#  )r$  r   r8   r   NrU   )rE   rw   r   r   r   r   r   r]   r   s        r!   test_circle__kwargs_missingz+DrawCircleMixin.test_circle__kwargs_missing  s     ~~f-\\%(#" %!%

 = 	AD!&\Nt$""9- A.d..@@A A		AA As   )BB	c                    t        j                  d      }t        j                  d      }d}d}| j                  t              5  | j                  ||||ddddd	      }ddd       | j                  t              5  | j                  ||||ddddd	      }ddd       | j                  t              5  | j                  ||||ddddd	      }ddd       | j                  t              5  | j                  ||||ddddd		      }ddd       | j                  t              5  | j                  ||||d
      }ddd       | j                  t              5  | j                  |||d      }ddd       | j                  t              5  | j                  ||d|      }ddd       | j                  t              5  | j                  |d||      }ddd       | j                  t              5  | j                  d|||      }ddd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   WxY w# 1 sw Y   -xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   yxY w)z.Ensures draw circle detects invalid arg types.r}   r   r   r   r  Nr  r  r  r   rn  r   r   r  r-  )rz   r   r8   r   r$  r9   s         r!   test_circle__arg_invalid_typesz.DrawCircleMixin.test_circle__arg_invalid_types  s   ..(V$y) 	**31aK	 y) 	**1c1aK	 y) 	**1aaK	 y) 	**1aCK	 y) 	P**7E663OK	P y) 	H**7E63GK	H y) 	N**7E9fMK	N y) 	I**7CHK	I y) 	P**<OK	P 	PQ	 		 		 		 		P 	P	H 	H	N 	N	I 	I	P 	Psl   H;H2H!)H. H;II7I )I,HH!H+.H8;III I),I5c                    t        j                  d      }t        j                  d      }d}d}d}d}t         j                  ||||ddddd	|d|||ddddd	||d||ddddd	|||d	|ddddd	||||d
ddddd	|||||ddddd	|||||ddddd	|||||ddddd	|||||ddddd	g	}|D ]2  }| j                  t              5   | j
                  di |}	ddd       4 y# 1 sw Y   ?xY w)z0Ensures draw circle detects invalid kwarg types.ro   r	   r   r   Tr#  r   )r   r   r   r   r  TrueQ	@quadrantNrU   r-  )
rz   r   r8   r   r$  r   r6  r   r   r9   s
             r!    test_circle__kwarg_invalid_typesz0DrawCircleMixin.test_circle__kwarg_invalid_typesM  s   ..(W% ">>  "&!%$(%)
 #  "&!%$(%)
 ## "&!%$(%)
 # "&!%$(%)
 #  "&!%$(%)
 #  "(!%$(%)
 #  "&!'$(%)
 #  "&!%$(%)
 #  "&!%$(%/
sd
L " 	9F""9- 9.d..889 9	99 9s    CC'	c                    t        j                  d      }t        j                  d      }d}d}||||ddddddd
||||ddg}|D ]2  }| j                  t              5   | j
                  d
i |}d	d	d	       4 y	# 1 sw Y   ?xY w)z0Ensures draw circle detects invalid kwarg names.r   r   r$   ru   r   T)
r   r8   r   r$  r   r6  r%  r&  r'  r(  )r   r8   r   r$  r   NrU   r-  )rz   r   r8   r   r$  r   r   r9   s           r!   test_circle__kwarg_invalid_namez/DrawCircleMixin.test_circle__kwarg_invalid_name  s    ..(V$ #  "&!%$(%) #  
, " 	9F""9- 9.d..889 9	99 9s   A<<B	c                    t        j                  d      }d}d}d}d}d}d}d}d}	|||||ddddd	}
dD ]3  }|
j                  |       d	|k(  r | j                  |fi |
}nd
|k(  r | j                  ||fi |
}nd|k(  r | j                  |||fi |
}nd|k(  r | j                  ||||fi |
}nd|k(  r | j                  |||||fi |
}nxd|k(  r | j                  ||||||fi |
}nZd|k(  r | j                  |||||||fi |
}n;d|k(  r | j                  ||||||||fi |
}n | j                  |||||||||	f	i |
}| j	                  |t         j
                         6 y)z8Ensures draw circle accepts a combination of args/kwargsr   r   r   ru   r   TFr#  r   r8   r   r$  r   r%  r&  r'  N)rE   rw   r   r]   rx   rF   )rz   r   r8   r   r$  r   r%  r&  r'  r(  r   r   r9   s                r!   test_circle__args_and_kwargsz,DrawCircleMixin.test_circle__args_and_kwargs  s+   ..(   "! $!%



 B	<D JJtD .d..wA&AD.d..wHHT!.d..wvPPT!.d..wvvXQWXD.d..UFFE=C "T).d..UFFE>MS !D(.d.."!	 	 $t+.d.."!$
 
 /d.."!$%  !!+v{{;EB	<r'   c           
         d}d}|d   |z
  |d   f}t        j                  d      }t        j                  d      }d}||||dddddd		}d
D ]t  }|j                  |       ||d<   |dk\  r|n|}	 | j                  di |}
| j                  |j                  |      |	       | j                  |
t         j                         v y)z3Ensures draw circle accepts different width values.r}   r   r   r   r   r   NTr#  r  r   rU   	rE   r   rw   r   r]   r   r   rx   rF   )rz   r   r$  r/   r   r   r8   r   r   r   r9   s              r!   test_circle__valid_width_valuesz/DrawCircleMixin.test_circle__valid_width_values:  s    ay6!6!9-W-..(!"! $!%

 4 	<ELL'#F7O&+qjUmN*$**4V4KW^^C0.A!!+v{{;	<r'   c           
      n   dx}}t        j                  d      }t        j                  d      }d}|||ddddddd	}d	D ]t  }|j                  |       ||d
<   |dkD  r|n|} | j                  di |}	| j                  |j                  |      |       | j                  |	t         j                         v y)z4Ensures draw circle accepts different radius values.r}   r   r   r   Nr   Tr#  )r   r,   r   r   rr   r$  rU   r=  )
rz   r/   r   r   r   r8   r   r$  r   r9   s
             r!    test_circle__valid_radius_valuesz0DrawCircleMixin.test_circle__valid_radius_valuesX  s    fW-..(!"! $!%

 * 	<FLL'%F8&,qjUmN*$**4V4KW^^C0.A!!+v{{;	<r'   c           
         t        j                  d      }t        j                  d      }t        j                  d      }||dddddddd	}d	\  }}||f|d
z   |f||d
z   f|d
z   |d
z   ffD ]  }t        t        t
        fD ]s  }|j                  |        ||      |d<    | j                  di |}	| j                  |j                  ||f      |       | j                  |	t         j                         u  y)z5Ensures draw circle accepts different center formats.r   r   r   Nr   r   Tr#  r}   r  r   rU   )rE   r   rw   r  r  r   r   r]   r   r   rx   rF   )
rz   r   r   r   r   r   r   r   r  r9   s
             r!   !test_circle__valid_center_formatsz1DrawCircleMixin.test_circle__valid_center_formatst  s   e,W-..(#"! $!%

 1 1vC|aS\AGQW;MN 		@F"D'2 @]+#+F#3x .d..88  A!7H%%k6;;?@		@r'   c           
         d}d}|d   |z
  |d   f}t        j                  d      }t        j                  d      }t        j                  d      }|d||dddddd		}d
d|j                  |      |f}|D ]  }	|j	                  |       |	|d<   t        |	t              r|j                  |	      }
n|}
 | j                  di |}| j                  |j                  |      |
       | j                  |t         j                          y)z4Ensures draw circle accepts different color formats.r}   r   r   r	   r   r   NTr#  r   r   r8   rU   )rE   r   rw   r   r   r   r   r   r]   r   r   rx   rF   )rz   r   r$  r/   r   r   r   r   r  r8   r   r9   s               r!    test_circle__valid_color_formatsz0DrawCircleMixin.test_circle__valid_color_formats  s   ay6!6!9-ll7+W-..("! $!%

 OOK(	
  	<ELL'#F7O%%!(!2!25!9!,*$**4V4KW^^C0.A!!+v{{;	<r'   c           
          t        j                  d      ddddddddd	}d| fD ]7  }||d	<   | j                  t              5   | j                  d
i |}ddd       9 y# 1 sw Y   DxY w)z<Ensures draw circle handles invalid color formats correctly.r   Nr   r   r   Tr#  r   r8   rU   )rE   rw   r   r   r]   r  s       r!   "test_circle__invalid_color_formatsz2DrawCircleMixin.test_circle__invalid_color_formats  s     ~~f-"! $!%

  #Dk 	9N,F7O""9- 9.d..889 9	99 9s   AA(	c                 2   t        j                  t        j                  d      dddddddd	       t        j                  t        j                  d      dt	        dd      dddddd	       t        j                  t        j                  d	      d
dd       y)z Ensure that floats are accepted.r   )r   r   r  r  ?r   Tr#  r  r}   r  )rH  rH  r  N)r   r\   rE   rw   r   r^  s    r!   test_circle__floatsz#DrawCircleMixin.test_circle__floats  s    NN6*!!"
	
 	NN6*!3$!"
	
 	FNN6*M:sKr'   c           
      J   t        j                  d      }t        j                  d      }d}t        j                  ddd      }|j                         }|j	                  |dz  dz
  |dz  dz
        }t        |      t        |      z   D ]  }t        |dz         D ]y  }t        |dz         D ]f  }	|j                  |       | j                  |||||	      }
t        |||      }| j                  |||||		      5  | j                  |
|       d
d
d
       h {  y
# 1 sw Y   wxY w)zEnsures draw circle returns the correct bounding rect.

        Tests circles on and off the surface and a range of width/thickness
        values.
        r   r   rp   )r   r   r   rS  ru   r   )r   circle_colorr/   r$  r  N)rE   r   rw   r  rT  r*   r   r   r]   rM   r  r   )rz   rK  rG   
max_radiusr   r[  r\  r/   r$  r  r_  r`  s               r!   test_circle__bounding_rectz*DrawCircleMixin.test_circle__bounding_rect  sQ    ||E*\\'*

..1b1$$&	 $$Z!^a%7a!9KL/
(23 	GC  
Q/ G!&vz!2 GILL,$($4$4sFI%M %9*c$RM  '%1%"+ &  G ((FG GGG		G$G Gs   7D	D"c                     t        j                  d      }d}|j                         dz  |j                         dz  f}| j                  |||dd      }| j	                  |j
                  d       y)	z@Ensures negative radius circles return zero sized bounding rect.r  r  r  ru   r,   r   )r$  r   r$   N)rE   rw   r3   r]   r   rB   )rz   r  r8   r   r_  s        r!   test_circle_negative_radiusz+DrawCircleMixin.test_circle_negative_radius.  sh    ~~j)"a'):a)??((ufRq(Q++V4r'   c           	      F   t        j                  d      }t        j                  d      }t        j                  d      }d}d}d}| j                  |||||      }t	        |||      }| j                  ||       | j                  |t        j                  dddd             y)	zEnsures zero radius circles does not draw a center pixel.

        NOTE: This is backwards incompatible behaviour with 1.9.x.
        rO  r   r   r	  r   r   r  N)rE   rw   r   r]   rM   r   rF   )	rz   r  rK  rG   r   r$  r   r_  r`  s	            r!   test_circle_zero_radiusz'DrawCircleMixin.test_circle_zero_radius7  s    
 ~~j)||E*\\'*
((|VVUS,T:vF6Ca(CDr'   c           	      ,   dx}t        j                  d      }t        j                  d      }t        j                  |f      }|j                  |       t        j                  dd      }|j                         j                  |_        |j                  dz  dz   }dD ]  }t        |      D ]  }|j                  d	       |j                  |       | j                  |||||       t        |||      }	|j                  |       |j                  |       | j                  |||||       |j                          fd
t        |      D        D ]-  }
|
|	v r|}n|}| j                  |j                  |
      ||
       / |j!                            y	)zsEnsures draw circle respects a surface's clip area.

        Tests drawing the circle filled and unfilled.
        r  r   r	   r$   rJ  ru   r   r   Nc              3   F   K   | ]  }t              D ]  }||f 
  y wr!  r"  rf  s      r!   r%  z<DrawCircleMixin.test_circle__surface_clip.<locals>.<genexpr>l  rh  r&  )rE   r   rw   r   rF   r  r   r   r*   ri  r]   r>   r6   r   r   r   r7   )rz   rj  rK  r   r   rk  r$  r   r   rm  rn  r   rg  s               @r!   test_circle__surface_clipz)DrawCircleMixin.test_circle__surface_clipH  sw   
 ||E*W-..%0]#KK1	"++-44	!A% 	!E6yA !   &]+  ,N/yQ ]+  +  ,N O5<N MB\))5)6$$W^^B%7LM  7!	!r'   c                 B   dx}}t        j                  d      }t        j                  d      }t        j                  ||f      }|j                  |       dx\  }}}d}	d}
| j	                  ||||	|
      }t        j                  |      D ]  }|\  }}||z
  dz  ||z
  dz  z   }|	|
z
  dz   dz  |cxk  r|	dz
  dz  k  r$n n!| j                  |j                  |      |       ||	|
z
  dz
  dz  k  s||	dz   dz  kD  sq| j                  |j                  |      |        y	)
zEnsures there are no holes in the circle, and no overdrawing.

        Tests drawing a thick circle.
        Measures the distance of the drawn pixels from the circle center.
        r  r   r	   ry  -   r  ru   r   N)	rE   r   rw   r   r]   r   r  r   r   )rz   rj  rg  rK  r   r   cxcyr   r$  r   	dest_rectrn  r   r   sqr_distances                   r!   test_circle_shapez!DrawCircleMixin.test_circle_shapev  s4    ||E*W-..%0]#$$R6$$WlFFER	**95 		DBDAqFq=AFq=8L"q(<K6A:!:KK  !3\B 2q886A:!"33  !3]C		Dr'   c                 N   t        j                  d      }d}|j                         dz  |j                         dz  f}d}d}t        dd      D ]U  }| j	                  |||||      }| j                  |j                  |dz         | j                  |j                  |dz         W y)z:Ensures draw circle is twice size of radius high and wide.rO  r  ru   r   r-  A   N)rE   rw   r3   r   r]   r   r   r   )rz   r  r8   r   r   r$  r_  s          r!   test_circle__diameterz%DrawCircleMixin.test_circle__diameter  s    ~~j)"a'):a)??Arl 	?F ,,T5&&%PM]00&1*=]116A:>	?r'   c           
      N   t        j                  d      }d}|j                  |       d}d}d}d}| j                  ||||      }| j	                  |t        j
                  d|d   |z
  |d   |z   |d	z               | j	                  |j                  |d   dkD  r|d   nd|d   f      |       | j	                  |j                  |d   |z   dz   |d   f      |       | j	                  |j                  |d   |z   dz
  |d   f      |       |j                  |       d
}| j                  ||||      }| j	                  |t        j
                  |d   |d   dd             | j	                  |j                  d|z   |d   f      |       |j                  |       |j                         |d	z  z   df}| j                  ||||      }| j	                  |t        j
                  |d   |d   dd             | j	                  |j                  d|d   f      |       | j	                  |j                  d|d	z  z   |d   f      |       | j	                  |j                  |j                         dz
  |d   f      |       | j	                  |j                  |j                         |z
  |d   f      |       |j                  |       d}| j                  ||||      }| j	                  |t        j
                  d|d   |z
  |d   |z   |d	z               | j	                  |j                  |d   dkD  r|d   nd|d   f      |       | j	                  |j                  |d   |z   |d   f      |       | j	                  |j                  |d   |z   dz
  |d   f      |       y)zJensures a circle is drawn properly when there is a negative x, or a big x.rO  r%  r  r   rr   )r   r   )r$  r   ru   )gꌠ9Y>)r  r  )r,   r  N)rE   rw   r   r]   r   rF   r   r2   )rz   r  r   r8   r   r$  wherebounding_rect1s           r!   test_x_boundszDrawCircleMixin.test_x_bounds  s    ~~j) 		' ))$uV)LKK58f,eAh.?!L	
 	KKU1X\qq%(CDe	
 	eAh&7!&;U1X%FGQeAh&7!&;U1X%FGO		'))$uV)LU1XuQxA)NOa&j%(%;<gF		'!FQJ.3))$uV)LU1XuQxA)NOaq]3W=a&A+ouQx%@A7Kdnn&6&:E!H%EFPdnn&6&?q%JKWU		'))$uV)LKK58f,eAh.?!L	
 	KKU1X\qq%(CDe	
 	eAh&7q%BCWMeAh&7!&;U1X%FGOr'   N)rP   rQ   rR   rS   r  r  r  r!  r)  r+  r.  r0  r2  r7  r9  r;  r>  r@  rB  rD  rF  rI  rM  rP  rR  rU  r\  r_  rc  rU   r'   r!   r  r    s    
88??<:8 -"A*1Pfp9d9@Y<v<<<8@<&<P9(Lf+GZ5E",!\D:
?0Pr'   r  c                       e Zd ZdZy)DrawCircleTestzTest draw module function circle.

    This class inherits the general tests from DrawCircleMixin. It is also
    the class to add any draw.circle specific tests to.
    Nrr  rU   r'   r!   re  re    rs  r'   re  c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)DrawArcMixinz^Mixin tests for drawing arcs.

    This class contains all the general arc drawing tests.
    c                     | j                  t        j                  d      ddddd      }| j                  |t        j                         y)z*Ensures draw arc accepts the correct args.ro   rq   r   r   ru   ru   r   r   N)ra   rE   rw   rx   rF   ry   s     r!   test_arc__argszDrawArcMixin.test_arc__args  s<    mmNN6"NL!Q
 	k6;;7r'   c                     | j                  t        j                  d      dt        j                  dd      dd      }| j	                  |t        j                         y)z2Ensures draw arc accepts the args without a width.r}   r~   r$   r   r^  Nra   rE   rw   rF   rx   ry   s     r!   test_arc__args_without_widthz)DrawArcMixin.test_arc__args_without_width  sG    mmNN6"M6;;vv3NPSUX
 	k6;;7r'   c           	          | j                  t        j                  d      ddddd      }| j                  |t        j                         | j                  |t        j                  dddd             y)z6Ensures draw arc accepts the args with negative width.ro   rr   rr   rs   rs   ri  r   r   r,   N)ra   rE   rw   rx   rF   r   ry   s     r!   "test_arc__args_with_negative_widthz/DrawArcMixin.test_arc__args_with_negative_width  s\    mmNN6"$4lAq"
 	k6;;7fkk!Q1&=>r'   c           	         t        j                  dd      }| j                  t        j                  d      d|dd|j                  dz  dz         }| j                  |t         j                         | j                  t        j                  d      d|dd|j                  dz  dz         }| j                  |t         j                         y	)
zdEnsures draw arc accepts the args with
        width > rect.w // 2 and width > rect.h // 2.
        r$   r   ro   ro  r   rW  ru   r   N)rE   rF   ra   rw   r   rx   r   r   s      r!   #test_arc__args_with_width_gt_radiusz0DrawArcMixin.test_arc__args_with_width_gt_radius  s     {{66*mmNN6"$4dAr466Q;QR?
 	k6;;7mmNN6"$4dAr466Q;QR?
 	k6;;7r'   c                 2   t        j                  d      t        j                  d      t        j                  dd      ddddt        j                  d	      d
ddddg}|D ]4  } | j                  di |}| j                  |t         j                         6 y)zZEnsures draw arc accepts the correct kwargs
        with and without a width arg.
        r   r   r$   rt   g      ?rp   r   r   r8   r)   start_angle
stop_angler   r   r   )r   r   ru   ru   rz  r   r8   r)   ru  rv  NrU   )rE   rw   r   rF   ra   rx   r   s       r!   test_arc__kwargszDrawArcMixin.test_arc__kwargs  s     ">>&1h/FF3" ">>&1$$ !
$ " 	<F'$--1&1K!!+v{{;	<r'   c                     | j                  dddt        j                  d      dt        j                  dd            }| j	                  |t        j                         y)	z2Ensures draw arc's kwargs are not order dependent.r   r\  r   rt   r   r   )rv  ru  r8   r   r   r)   Nrl  ry   s     r!   "test_arc__kwargs_order_independentz/DrawArcMixin.test_arc__kwargs_order_independent3  sQ    mmNN6*VV, $ 
 	k6;;7r'   c                    t        j                  d      }t        j                  d      }t        j                  dd      }| j	                  t
              5  | j                  |||d      }ddd       | j	                  t
              5  | j                  |||      }ddd       | j	                  t
              5  | j                  ||      }ddd       | j	                  t
              5  | j                  |      }ddd       | j	                  t
              5  | j                         }ddd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   \xY w# 1 sw Y   yxY w)z3Ensures draw arc detects any missing required args.r   r   r$   r}   r  NrE   rw   r   rF   r   r   ra   r   s        r!   test_arc__args_missingz#DrawArcMixin.test_arc__args_missing@  s=   ..(U#{{66*y) 	C--cBK	C y) 	>--=K	> y) 	8--7K	8 y) 	1--0K	1 y) 	*--/K	* 	*	C 	C	> 	>	8 	8	1 	1	* 	*s<   D2D>9E
)EE"2D;>E
EE"E+c                 H   t        j                  d      t        j                  d      t        j                  dd      dddd}d	D ]N  }t	        |      }|j                  |       | j                  t              5   | j                  di |}d
d
d
       P y
# 1 sw Y   [xY w)z5Ensures draw arc detects any missing required kwargs.r   r   r   r}   r  ru   r   rt  )rv  ru  r)   r8   r   NrU   )	rE   rw   r   rF   r   r   r   r   ra   r   s        r!   test_arc__kwargs_missingz%DrawArcMixin.test_arc__kwargs_missingU  s     ~~f-\\%(KK/
 N 	>D!&\Nt$""9- >+dmm=n=> >		>> >rO  c           	         t        j                  d      }t        j                  d      }t        j                  dd      }| j	                  t
              5  | j                  |||ddd      }ddd       | j	                  t
              5  | j                  |||ddd      }ddd       | j	                  t
              5  | j                  |||ddd      }ddd       | j	                  t
              5  | j                  ||d	ddd      }ddd       | j	                  t
              5  | j                  |d
|ddd      }ddd       | j	                  t
              5  | j                  |||ddd      }ddd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   oxY w# 1 sw Y   yxY w)z+Ensures draw arc detects invalid arg types.r}   r   r   ro   r   r   r   Nr   r   r|  r   s        r!   test_arc__arg_invalid_typesz(DrawArcMixin.test_arc__arg_invalid_typesg  s   ..(V${{66*y) 	I--aCHK	I y) 	I--aaHK	I y) 	I--c1aHK	I y) 	R--AqQK	R y) 	E--dAq!DK	E y) 	D--eT1aCK	D 	D)	I 	I	I 	I	I 	I	R 	R	E 	E	D 	DsH   E:
F>F2F&F+F7:FFFF(+F47G c                    t        j                  d      }t        j                  d      }t        j                  dd      }d}d}t         j                  ||||dd|d	|||dd||d
||dd|||d|dd||||ddd|||||ddg}|D ]2  }| j	                  t
              5   | j                  di |}ddd       4 y# 1 sw Y   ?xY w)z-Ensures draw arc detects invalid kwarg types.ro   r	   r   )r   ru   rp   r   r   rt  r   r   r   r   NrU   r|  	rz   r   r8   r)   r  stopr   r   r9   s	            r!   test_arc__kwarg_invalid_typesz*DrawArcMixin.test_arc__kwarg_invalid_types  s'   ..(W%{{66* ">>$" #$" #!$" #"" #$! #$"S1
f " 	6F""9- 6+dmm5f56 6	66 6s   B==C	c                 8   t        j                  d      }t        j                  d      }t        j                  dd      }d}d}|||||ddd|||||dd	g}|D ]2  }| j	                  t
              5   | j                  di |}d
d
d
       4 y
# 1 sw Y   ?xY w)z-Ensures draw arc detects invalid kwarg names.r   r   r   r}   g?r   r   )r   r8   r)   ru  rv  r   r   )r   r8   r)   ru  rv  r   NrU   r|  r  s	            r!   test_arc__kwarg_invalid_namez)DrawArcMixin.test_arc__kwarg_invalid_name  s    ..(V${{66* #$" #$"
( " 	6F""9- 6+dmm5f56 6	66 6s   2BB	c           	      *   t        j                  d      }d}t        j                  dd      }d}d}d}||||||d}d	D ]  }|j                  |       d
|k(  r | j                  |fi |}	nd|k(  r | j                  ||fi |}	nld|k(  r | j                  |||fi |}	nQd|k(  r | j                  ||||fi |}	n5d|k(  r | j                  |||||fi |}	n | j                  ||||||fi |}	| j                  |	t         j                          y)z5Ensures draw arc accepts a combination of args/kwargsr   r   r   r   g333333?ru   r   rt  rw  r   r8   r)   ru  rv  N)rE   rw   rF   r   ra   rx   )
rz   r   r8   r)   r  r  r   r   r   r9   s
             r!   test_arc__args_and_kwargsz&DrawArcMixin.test_arc__args_and_kwargs  sJ   ..( {{66* 
 N 	<DJJtD +dmmG>v>D+dmmGUEfE4+dmmGUDKFK$&+dmmGUD%R6R%+dmmGUD%XQWX+dmmUD%u@F !!+v{{;%	<r'   c                 :   t        j                  d      }t        j                  d      }t        j                  d      }t        j                  dd      }|j	                         j
                  |_        |j                  dz   |j                  dz   f}|||ddd	d
}dD ]{  }d| }|j                  |       ||d<   |dkD  r|n|}	 | j                  di |}
| j                  |j                  |      |	|       | j                  |
t         j                  |       } y	)z0Ensures draw arc accepts different width values.r   r   r  r$   r   r   r   rQ  Nrt  )ir   r"  r  r,   r   r   ru   rp   rr   rs   zwidth=r   rU   rE   r   rw   rF   r  r   r	  r
  r   ra   r   r   rx   )rz   	arc_colorr   r   r)   r/   r   r   r  r   r9   s              r!   test_arc__valid_width_valuesz)DrawArcMixin.test_arc__valid_width_values  s   LL*	W-..({{66*&&(//llQq 00
 @ 		AE5'"CLL'#F7O*/!)YN'$--1&1KW^^C0.#F!!+v{{C@		Ar'   c                 "   t        j                  d      }t        j                  d      }t        j                  d      }t        j                  dd      }|j	                         j
                  |_        |j                  |j                  dz   f}|||dddd	}d
D ]r  }d| }|j                  |       ||d<    | j                  di |}	| j                  |j                  |      ||       | j                  |	t         j                  |       t y)z5Ensures draw arc accepts different stop_angle values.r   r   r  r$   r   r   iNrt  )r         r,   r   r   r  rr   zstop_angle=rv  rU   r  )
rz   r   r   r   r)   r/   r   rv  r  r9   s
             r!   !test_arc__valid_stop_angle_valuesz.DrawArcMixin.test_arc__valid_stop_angle_values#  s    f-W-..({{66*&&(//llDLL1,,#
 9 	AJ
|,CLL'#-F< '$--1&1KW^^C0.#F!!+v{{C@	Ar'   c                 (   t        j                  d      }t        j                  d      }t        j                  d      }t        j                  dd      }|j	                         j
                  |_        |j                  dz   |j                  dz   f}|||dddd	}d
D ]r  }d| }|j                  |       ||d<    | j                  di |}	| j                  |j                  |      ||       | j                  |	t         j                  |       t y)z6Ensures draw arc accepts different start_angle values.r   r   r  r$   r   r   N   rt  )g      $r  r,   r   r   r  g      $@zstart_angle=ru  rU   r  )
rz   r   r   r   r)   r/   r   ru  r  r9   s
             r!   "test_arc__valid_start_angle_valuesz/DrawArcMixin.test_arc__valid_start_angle_values>  s    f-W-..({{66*&&(//llQq 00#
 > 	AK .CLL'$/F=!'$--1&1KW^^C0.#F!!+v{{C@	Ar'   c                    t        j                  d      }t        j                  d      }t        j                  d      }t        j                  dd      }|j	                         j
                  |_        |j                  dz   |j                  dz   f}||ddd	dd
}||j                  |j                  f|j                  |j                  |j                  |j                  ff}|D ]k  }|j                  |       ||d<    | j                  di |}| j!                  |j#                  |      |       | j%                  |t         j                         m y)z0Ensures draw arc accepts different rect formats.r   r   r  r$   r   r   Nr   rQ  rt  r)   rU   )rE   r   rw   rF   r  r   r	  r
  r   rB   r   r   r   r   r   ra   r   r   rx   )	rz   r   r   r   r)   r/   r   r   r9   s	            r!   test_arc__valid_rect_formatsz)DrawArcMixin.test_arc__valid_rect_formatsY  s   e,W-..({{66*&&(//llQq 00#
 dii04664664664662RS 	<DLL'!F6N'$--1&1KW^^C0.A!!+v{{;	<r'   c                    t        j                  d      }t        j                  d      }t        j                  d      }t        j                  dd      }|j	                         j
                  |_        |j                  dz   |j                  dz   f}|d|dd	dd
}dd|j                  |      |f}|D ]  }|j                  |       ||d<   t        |t              r|j                  |      }	n|}	 | j                  di |}
| j                  |j                  |      |	       | j!                  |
t         j                          y)z1Ensures draw arc accepts different color formats.r	   r   r  r$   r   r   Nr   rQ  rt  r   r   r8   rU   )rE   r   rw   rF   r  r   r	  r
  r   r   r   r   r   ra   r   r   rx   )rz   r   r   r   r)   r/   r   r  r8   r   r9   s              r!   test_arc__valid_color_formatsz*DrawArcMixin.test_arc__valid_color_formatst  s*   ll7+W-..({{66*&&(//llQq 00
 OOK(	
  	<ELL'#F7O%%!(!2!25!9!,'$--1&1KW^^C0.A!!+v{{;	<r'   c                     d}t        j                  d      }|dt        j                  |d      dddd}d	| fD ]7  }||d
<   | j                  t              5   | j
                  di |}ddd       9 y# 1 sw Y   DxY w)z9Ensures draw arc handles invalid color formats correctly.r   r   Nr}   r   gffffff@r   rt  r   r8   rU   )rE   rw   rF   r   r   ra   r   s         r!   test_arc__invalid_color_formatsz,DrawArcMixin.test_arc__invalid_color_formats  s    ..(KKV,
  #Dk 	6N,F7O""9- 6+dmm5f56 6	66 6rv  c                    t        j                  d      }t        j                  d      }t        j                  d      }|j                  |       d}d}d}d}t         j                  j                  ||||||       t         j                  j                  |d       d	}t        d
d      D ]%  }	| j                  |j                  ||	f      |       ' | j                  |j                  d      |       y)z Ensure draw arc works correctly.r   r   )r  r  )r   r   r  r  g        r5  rp   zarc.pngr   ru   r   r$   N)rE   r   rw   r   r   r`   imagesaver   r   r   )
rz   r   r   r   r)   ru  rv  r   r   r   s
             r!   test_arczDrawArcMixin.test_arc  s    W%ll5! ..,U
  
  	dKUK 	'9- q! 	:AW^^QF3S9	: 	/7r'   c                    t        j                  d      }t        j                  d      }dx}}dx}}||f||ff}t        j                  ddd      }|j                         }	|	j	                  |dz  d	z   |dz  d	z         }
d}ddd
dt        j                  dt
        j                  z        f}t        |	      t        |
      z   D ]  }t        D ]  }|D ]  \  }}t        j                  d||f      }t        |||       dd	dd
t        ||      fD ]]  }|D ]V  }|j                  |       | j                  ||||||      }t        |||j                         }| j#                  ||d|        X _    y)zEnsures draw arc returns the correct bounding rect.

        Tests arcs on and off the surface and a range of width/thickness
        values.
        r   r   r   rQ  rR  r   rS  ru   r   rp   r$   r  N)rE   r   rw   r  rT  mathceilpir*   rU  rF   rV  rC   r   ra   rM   r   r   )rz   r  rG   rW  rX  rY  rZ  r   r   r[  r\  ru  stop_anglesr/   r]  r   r   arc_rectr  rv  r_  r`  s                         r!   test_arc__bounding_rectz$DrawArcMixin.test_arc__bounding_rect  s    LL'	\\'*
!""	J!""	JZ(9j*AB..1b1$$&	 $$Y]Q%6
Q8JK !Q499Q[#9:/
(23 #	C
 1  &+ ME6%{{6E6?CHHdC0&'Aq#eV2D%E 	*5 J#LL4,0MM ' ) ( + * )-M -A 'X5E5E-M !,, - -",YK 8%	#	r'   c           
      B   dx}d}d}t        j                  d      }t        j                  d      }t        j                  |f      }|j                  |       t        j                  dd      }|j                         j                  |_        |j                         }dD ]  }	t        |      D ]  }
|
|_        |j                  d	       |j                  |       | j                  ||||||	       t        |||      }|j                  |       |j                  |       | j                  ||||||	       |j                          fd
t        |      D        D ]-  }||v r|}n|}| j                  |j                  |      ||       / |j!                            y	)z0Ensures draw arc respects a surface's clip area.r   r  r   r   r	   r$   rc  r   Nc              3   F   K   | ]  }t              D ]  }||f 
  y wr!  r"  rf  s      r!   r%  z6DrawArcMixin.test_arc__surface_clip.<locals>.<genexpr>-  rh  r&  )rE   r   rw   r   rF   r  r   r.  r*   ri  ra   r>   r6   r   r   r   r7   )rz   rj  r  r  r  r   r   rk  rl  r  r   rm  rn  r   rg  s                 @r!   test_arc__surface_clipz#DrawArcMixin.test_arc__surface_clip	  s   LL'	W-..%0]#KK1	"++-44	>># 	!I6yA ! #)  &]+gy(E3	R/IN ]+  +gy(E3	R O5<N MB\))2)6$$W^^B%7LM  9!	!r'   N)rP   rQ   rR   rS   rj  rm  rp  rr  rx  rz  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rU   r'   r!   rg  rg    sy    
88?8"<68**>$D<<6|6>#<JA8A6A6<6#<J6&!8F8t,!r'   rg  c                       e Zd ZdZy)DrawArcTestzTest draw module function arc.

    This class inherits the general tests from DrawArcMixin. It is also the
    class to add any draw.arc specific tests to.
    Nrr  rU   r'   r!   r  r  8  rs  r'   r  c                       e Zd ZdZd Zd Zy)DrawModuleTestzGeneral draw module tests.c           
      "   t        j                  d      t        j                  dddd      }dddt               d f}t	        |      dd	gz   }|j                  d
 |D               g d}t        d      D cg c]  }t        d      D ]  }||f  }}}t        j                  dft        j                  dft        j                  dffD ]"  \  }}	|D ]  }
t        j                  t        |d       | j                  t              5  |	r |t        |
g|z   d       n |t        d|
g|z          ddd       | j!                  t#        fd|D                     t        j                  t        |d       | j                  t              5  |dd |
gz   |dd z   }|	r |t        |d       n |t        d|       ddd       | j!                  t#        fd|D                      % yc c}}w # 1 sw Y   xY w# 1 sw Y   ExY w)zNTest validation of multi-point drawing methods.

        See bug #521
        r   r   r   texts   bytesy      ?      ?c                     | S r!  rU   )r   s    r!   r  z:DrawModuleTest.test_path_data_validation.<locals>.<lambda>]  s    q r'   r  r   c              3   $   K   | ]  }d |f 
 yw)r   NrU   )r#  vs     r!   r%  z;DrawModuleTest.test_path_data_validation.<locals>.<genexpr>`  s     5Q1a&5s   )r   r   ro   r   r   TNc              3   N   K   | ]  }j                  |      t        k(    y wr!  r   r  r#  rn  r  s     r!   r%  z;DrawModuleTest.test_path_data_validation.<locals>.<genexpr>t       #OrDKKOs$:#O   "%ru   c              3   N   K   | ]  }j                  |      t        k(    y wr!  r  r  s     r!   r%  z;DrawModuleTest.test_path_data_validation.<locals>.<genexpr>  r  r  )rE   rw   rF   objectr  extendr   r   rd   rh   rZ   r)   r  r   r   r  r   all)rz   r)   
bad_values
bad_points	good_pathr   r   	check_ptsmethod	is_polgonvalpathr  s               @r!   test_path_data_validationz(DrawModuleTest.test_path_data_validationQ  s   
 ~~f%{{1aA&H

 *%y(99
5*554	%*1X@uQx@!aV@V@	@ ZZO\\1\\1"
 	QFI
 " Q		$T1-&&y1 E tUSEI,=qAtUD3%)2CD	E #OY#O OP 		$T1-&&y1 8$Ra=C509QR=@D tUD!4tUD$78 #OY#O OP-Q	Q AE E8 8s   9G3
*G91H9HHc                    t        j                  d      }ddt        ddf}d}|D ]  }t        j                  ||dd       t        j
                  ||dd       t        j                  ||d	|       t        j                  ||d	|       t        j                  ||t        j                  d
d
dd      dd       t        j                  ||t        j                  d
d
dd      d       t        j                  ||dd       t        j                  |||d
        dt               d fD ]  }| j                  t              5  t        j                  ||dd       d d d        | j                  t              5  t        j
                  ||dd       d d d        | j                  t              5  t        j                  ||d	|       d d d        | j                  t              5  t        j                  ||d	|       d d d        | j                  t              5  t        j                  ||t        j                  d
d
dd      dd       d d d        | j                  t              5  t        j                  ||t        j                  d
d
dd      d       d d d        | j                  t              5  t        j                  ||dd       d d d        | j                  t              5  t        j                  |||d
       d d d         y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   cxY w# 1 sw Y   :xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   GxY w)NrJ  i@ )r   rr   r  z#ab12dfr   )r$   r   r   r$   r   Tr   rp   r  r  r-  r   r  ru   gjt?)rE   rw   r  r   rb   rf   rh   rd   r`   rF   r^   r\   rZ   r  r   r   )rz   r  colorsr8  cols        r!   test_color_validationz$DrawModuleTest.test_color_validation  s   ~~h'sIu<)  	/CIIdC0KKc662LLsD&1JJtS$/HHT3Aq!Q 7SALLsFKK1a$;Q?KKc61-LLsFA.	/ 68T* 	3C""9- 5		$VV45 ""9- 7D#vv67 ""9- 6T3f56 ""9- 4

4dF34 ""9- FsFKK1a$;REF ""9- DT3Aq!Q(?CD ""9- 2D#vq12 ""9- 3T323 3-	35 57 76 64 4F FD D2 23 3s`   =L	3L)L#L00L="/M	.M$M!	L	L 	#L-	0L:	=M		M	M	!M+	N)rP   rQ   rR   rS   r  r  rU   r'   r!   r  r  N  s    $/Qb(3r'   r  __main__)NT)6r  unittestsysr  rE   r   r   pygame.localsr   pygame.testsr   pygame.mathr   r   r  r  r  r  rU  r"   r&   r*   r0   r>   rM   rO   TestCaserW   rk   rm   rq  ru  r  r  r-  r  r  r  r(  rY  r  r  r  r\  r  r  r  r  re  rg  r  r  rP   mainrU   r'   r!   <module>r     sh     
     " #  v||E" "f6<<( (
 	BN$'@8I: .8$$ .6** 6$W! W!t& ,'% '%Zk! k!rM/9l M/fw% w%HJ S- S@ML[, MLfW!= W!HlL  a&1a&1a&1a&	)
*FFFFFFFFFFFF	 M
 M
`& ,q	! q	!h=, ,oP oPd_l ,M	! M	!`, ,\3X&& \3D zHMMO r'   