
    ^h                     n   S SK r S SKrSrSrSrSrSrSrSrS	r	S
r
SrSrSrSrSrSrSrSrSrSrSrSrSr\R0                  " SS5      r\R0                  " SS5      r\R0                  " SS5      r " S S\5      rS  rS! rS" r S# r!S$ r"S% r#   " S& S'\$5      r%\&S(:X  a  \'" \ RP                  " 5       5        gg))    Nz0.2.0topbottomleftrighttoplefttopright
bottomleftbottomrightmidtopmidrightmidleft	midbottomcentercenterxcenterywidthheightsizeboxarea	perimeterBoxzleft top width heightPointzx ySizezwidth heightc                       \ rS rSrSrSrg)PyRectException'   z
This class exists for PyRect exceptions. If the PyRect module raises any
non-PyRectException exceptions, this indicates there's a bug in PyRect.
 N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       A/var/www/html/env/lib/python3.13/site-packages/pyrect/__init__.pyr   r   '   s    
 	r%   r   c                 ~    [        U [        [        45      (       d"  [        SU R                  R
                  -  5      eg)zGRaises an exception if arg is not an int or float. Always returns None.%argument must be int or float, not %sN)
isinstanceintfloatr   	__class__r   args    r&   _checkForIntOrFloatr/   0   s7    cC<((3s}}7M7MN
 	
 )r%   c                 r    [        U [        5      (       d"  [        SU R                  R                  -  5      eg)z>Raises an exception if arg is not an int. Always returns None.r(   N)r)   r*   r   r,   r   r-   s    r&   _checkForIntr1   8   s3    c33s}}7M7MN
 	
  r%   c                      [        U S   [        [        45      (       a  [        U S   [        [        45      (       d  [        S5      eg !   [        S5      e= f)Nr      z@argument must be a two-item tuple containing int or float valuesr)   r*   r+   r   r-   s    r&   _checkForTwoIntOrFloatTupler5   @   s^    
#a&3,//z#a&3PU,7W7W!R  8X
N
 	
s   AA
 
Ac                 ,    [        U S   [        [        45      (       aZ  [        U S   [        [        45      (       a<  [        U S   [        [        45      (       a  [        U S   [        [        45      (       d  [        S5      eg !   [        S5      e= f)Nr   r3         zAargument must be a four-item tuple containing int or float valuesr4   r-   s    r&   _checkForFourIntOrFloatTupler9   L   s    
3q6C<00c!fsEl33c!fsEl33c!fsEl33!S  4

O
 	
s   BB Bc                     g)zFReturns True if rectOrPoint1 and rectOrPoint2 collide with each other.Nr   )rectOrPoint1rectOrPoint2s     r&   	_collidesr=   ]   s    r%   c                     / n/ nU  H   n [        U5        UR                  U5        M"     X!4$ ! [         a2     [        U5        O!   [        S5      e= fUR                  U5         Mb  f = f)Nz'argument is not a point or a rect tuple)r5   appendr   r9   )rectsOrPointspointsrectsrectOrPoints       r&   _getRectsAndPointsrD   a   sx    FE$	&'4MM+& % ?  	&Q,[9Q%&OPPLL%	&s&   .
A*AA*AA*)A*c                      \ rS rSr        S?S jrS rS rS r\S 5       r	\	R                  S 5       r	\S	 5       r\R                  S
 5       r\r\S 5       r\R                  S 5       r\r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       r\S 5       r\R                  S 5       r\S 5       r\R                  S  5       r\S! 5       r\R                  S" 5       r\S# 5       r\R                  S$ 5       r\S% 5       r\R                  S& 5       r\S' 5       r\R                  S( 5       r\S) 5       r\R                  S* 5       r\r\S+ 5       r\R                  S, 5       r\r \S- 5       r!\S. 5       r"\S/ 5       r#\#R                  S0 5       r#S1 r$S2 r%S3 r&S4 r'S@S5 jr(S6 r) S7 r*S8 r+ S9 r,S: r-S; r.   S< r/S= r0S>r1g)ARect   Nc	                 <   [        U5        [        U5        [        U5        [        U5        [        U5      U l        [        U5      U l        Ub  [	        U5      (       d  [        S5      eXpl        Ub  [	        U5      (       d  [        S5      eXl        U(       aA  [        U5      U l	        [        U5      U l
        [        U5      U l        [        U5      U l        g [        U5      U l	        [        U5      U l
        [        U5      U l        [        U5      U l        g )NzConChange argument must be None or callable (function, method, etc.)zAonRead argument must be None or callable (function, method, etc.))r/   bool_enableFloat	_readOnlycallabler   onChangeonReadr+   _width_height_left_topr*   )	selfr   r   r   r   enableFloatreadOnlyrM   rN   s	            r&   __init__Rect.__init__   s     	E"F#D!C  -h(:(:!U  !hv&6&6!S  ,DK =DLtDJc
DIe*DKv;DLTDJCDIr%   c           
          U R                   R                  < SU R                  < SU R                  < SU R                  < SU R
                  < S3
$ )zLReturn a string of the constructor function call to create this Rect object.z(left=z, top=z, width=z	, height=))r,   r   rQ   rR   rO   rP   rS   s    r&   __repr__Rect.__repr__   s7     NN##JJIIKKLL
 	
r%   c           	      x    SU R                   < SU R                  < SU R                  < SU R                  < S3	$ )z3Return a string representation of this Rect object.z(x=z, y=z, w=z, h=rY   )rQ   rR   rO   rP   rZ   s    r&   __str__Rect.__str__   s*     JJIIKKLL	
 	
r%   c           	          U R                   bQ  U R                  [        XX45      [        U R                  U R                  U R                  U R
                  5      5        g g )N)rM   r   rQ   rR   rO   rP   )rS   oldLeftoldTopoldWidth	oldHeights        r&   callOnChangeRect.callOnChange   sG     ==$MMGX9DJJ		4;;E %r%   c                     U R                   $ )a  
A Boolean attribute that determines if this rectangle uses floating point
numbers for its position and size. False, by default.

>>> r = Rect(0, 0, 10, 20)
>>> r.enableFloat
False
>>> r.enableFloat = True
>>> r.top = 3.14
>>> r
Rect(left=0.0, top=3.14, width=10.0, height=20.0)
)rJ   rZ   s    r&   rT   Rect.enableFloat   s        r%   c                    [        U[        5      (       d  [        S5      eXl        U R                  (       ai  [	        U R
                  5      U l        [	        U R                  5      U l        [	        U R                  5      U l        [	        U R                  5      U l        g [        U R
                  5      U l        [        U R                  5      U l        [        U R                  5      U l        [        U R                  5      U l        g )Nz'enableFloat must be set to a bool value)
r)   rI   r   rJ   r+   rQ   rR   rO   rP   r*   )rS   values     r&   rT   rh   	  s    %&&!"KLL!tzz*DJdii(DI,DK .DLTZZDJDIIDIdkk*DKt||,DLr%   c                 ^    U R                   b  U R                  [        5        U R                  $ )z
The x coordinate for the left edge of the rectangle. `x` is an alias for `left`.

>>> r = Rect(0, 0, 10, 20)
>>> r.left
0
>>> r.left = 50
>>> r
Rect(left=50, top=0, width=10, height=20)
)rN   LEFTrQ   rZ   s    r&   r   	Rect.left  s$     ;;"KKzzr%   c                 <   U R                   (       a  [        S5      e[        U5        XR                  :w  af  U R                  nU R                  (       a  Xl        O[        U5      U l        U R                  X R                  U R                  U R                  5        g g NRect object is read-only)
rK   r   r/   rQ   rJ   r*   re   rR   rO   rP   )rS   newLeftoriginalLefts      r&   r   rm   +  sl    >>!"<==G$zz!::L  $
 \
lIIt{{DLLQ "r%   c                 ^    U R                   b  U R                  [        5        U R                  $ )z
The y coordinate for the top edge of the rectangle. `y` is an alias for `top`.

>>> r = Rect(0, 0, 10, 20)
>>> r.top
0
>>> r.top = 50
>>> r
Rect(left=0, top=50, width=10, height=20)
)rN   TOPrR   rZ   s    r&   r   Rect.top>  s$     ;;"KKyyr%   c                 <   U R                   (       a  [        S5      e[        U5        XR                  :w  af  U R                  nU R                  (       a  Xl        O[        U5      U l        U R                  U R                  X R                  U R                  5        g g ro   )
rK   r   r/   rR   rJ   r*   re   rQ   rO   rP   )rS   newToporiginalTops      r&   r   ru   N  sl    >>!"<==F#YY))K  "	K	djj+{{DLLQ r%   c                 x    U R                   b  U R                  [        5        U R                  U R                  -   $ )z
The x coordinate for the right edge of the rectangle.

>>> r = Rect(0, 0, 10, 20)
>>> r.right
10
>>> r.right = 50
>>> r
Rect(left=40, top=0, width=10, height=20)
)rN   RIGHTrQ   rO   rZ   s    r&   r   
Rect.right_  s-     ;;"KKzzDKK''r%   c                    U R                   (       a  [        S5      e[        U5        XR                  U R                  -   :w  a  U R                  nU R
                  (       a  XR                  -
  U l        O[        U5      U R                  -
  U l        U R                  X R                  U R                  U R                  5        g g ro   )
rK   r   r/   rQ   rO   rJ   r*   re   rR   rP   )rS   newRightrr   s      r&   r   r{   o  s    >>!"<==H%

T[[00::L  %3
 ]T[[8
lIIt{{DLLQ 1r%   c                 x    U R                   b  U R                  [        5        U R                  U R                  -   $ )zThe y coordinate for the bottom edge of the rectangle.

>>> r = Rect(0, 0, 10, 20)
>>> r.bottom
20
>>> r.bottom = 30
>>> r
Rect(left=0, top=10, width=10, height=20)
)rN   BOTTOMrR   rP   rZ   s    r&   r   Rect.bottom  s-     ;;"KKyy4<<''r%   c                    U R                   (       a  [        S5      e[        U5        XR                  U R                  -   :w  a  U R                  nU R
                  (       a  XR                  -
  U l        O[        U5      U R                  -
  U l        U R                  U R                  X R                  U R                  5        g g ro   )
rK   r   r/   rR   rP   rJ   r*   re   rQ   rO   )rS   	newBottomrx   s      r&   r   r     s    >>!"<==I&T\\11))K  %4		NT\\9	djj+{{DLLQ 2r%   c                     U R                   b  U R                  [        5        [        U R                  U R                  S9$ )z
The x and y coordinates for the top right corner of the rectangle, as a tuple.

>>> r = Rect(0, 0, 10, 20)
>>> r.topleft
(0, 0)
>>> r.topleft = (30, 30)
>>> r
Rect(left=30, top=30, width=10, height=20)
xy)rN   TOPLEFTr   rQ   rR   rZ   s    r&   r   Rect.topleft  s/     ;;"KK tzzTYY//r%   c                    U R                   (       a  [        S5      e[        U5        Uu  p#X R                  :w  d  X0R                  :w  a~  U R                  nU R                  nU R
                  (       a  X l        X0l        O [        U5      U l        [        U5      U l        U R                  XEU R                  U R                  5        g g ro   )
rK   r   r5   rQ   rR   rJ   r*   re   rO   rP   )rS   rj   rq   rw   rr   rx   s         r&   r   r     s    >>!"<==#E*zz!ii::L))K  $
"	 \
K	ldllS  r%   c                     U R                   b  U R                  [        5        [        U R                  U R                  U R
                  -   S9$ )z
The x and y coordinates for the bottom right corner of the rectangle, as a tuple.

>>> r = Rect(0, 0, 10, 20)
>>> r.bottomleft
(0, 20)
>>> r.bottomleft = (30, 30)
>>> r
Rect(left=30, top=10, width=10, height=20)
r   )rN   
BOTTOMLEFTr   rQ   rR   rP   rZ   s    r&   r	   Rect.bottomleft  s8     ;;"KK
#tzzTYY%=>>r%   c                    U R                   (       a  [        S5      e[        U5        Uu  p#X R                  :w  d  X0R                  U R
                  -   :w  a  U R                  nU R                  nU R                  (       a  X l        X0R
                  -
  U l        O-[        U5      U l        [        U5      U R
                  -
  U l        U R                  XEU R                  U R
                  5        g g ro   )
rK   r   r5   rQ   rR   rP   rJ   r*   re   rO   )rS   rj   rq   r   rr   rx   s         r&   r	   r     s    >>!"<==#E*"zz!T\\11::L))K  $
%4	 \
	NT\\9	ldllS 2r%   c                     U R                   b  U R                  [        5        [        U R                  U R                  -   U R
                  S9$ )z
The x and y coordinates for the top right corner of the rectangle, as a tuple.

>>> r = Rect(0, 0, 10, 20)
>>> r.topright
(10, 0)
>>> r.topright = (30, 30)
>>> r
Rect(left=20, top=30, width=10, height=20)
r   )rN   TOPRIGHTr   rQ   rO   rR   rZ   s    r&   r   Rect.topright  s8     ;;"KK!tzzDKK/499==r%   c                    U R                   (       a  [        S5      e[        U5        Uu  p#X R                  U R                  -   :w  d  X0R
                  :w  a  U R                  nU R
                  nU R                  (       a  X R                  -
  U l        X0l        O-[        U5      U R                  -
  U l        [        U5      U l        U R                  XEU R                  U R                  5        g g ro   )
rK   r   r5   rQ   rO   rR   rJ   r*   re   rP   )rS   rj   r}   rw   rr   rx   s         r&   r   r     s    >>!"<==#E* 

T[[00ii::L))K  %3
"	 ]T[[8
K	ldllS  r%   c                     U R                   b  U R                  [        5        [        U R                  U R                  -   U R
                  U R                  -   S9$ )z
The x and y coordinates for the bottom right corner of the rectangle, as a tuple.

>>> r = Rect(0, 0, 10, 20)
>>> r.bottomright
(10, 20)
>>> r.bottomright = (30, 30)
>>> r
Rect(left=20, top=10, width=10, height=20)
r   )rN   BOTTOMRIGHTr   rQ   rO   rR   rP   rZ   s    r&   r
   Rect.bottomright  sA     ;;"KK$tzzDKK/499t||3KLLr%   c                 .   U R                   (       a  [        S5      e[        U5        Uu  p#X0R                  U R                  -   :w  d  X R
                  U R                  -   :w  a  U R
                  nU R                  nU R                  (       a'  X R                  -
  U l        X0R                  -
  U l        O:[        U5      U R                  -
  U l        [        U5      U R                  -
  U l        U R                  XEU R                  U R                  5        g g ro   )
rK   r   r5   rR   rP   rQ   rO   rJ   r*   re   )rS   rj   r}   r   rr   rx   s         r&   r
   r     s    >>!"<==#E*#T\\11

T[[00::L))K  %3
%4	 ]T[[8
	NT\\9	ldllS 1r%   c                     U R                   b  U R                  [        5        U R                  (       a.  [        U R                  U R
                  S-  -   U R                  S9$ [        U R                  U R
                  S-  -   U R                  S9$ )z
The x and y coordinates for the midpoint of the top edge of the rectangle, as a tuple.

>>> r = Rect(0, 0, 10, 20)
>>> r.midtop
(5, 0)
>>> r.midtop = (40, 50)
>>> r
Rect(left=35, top=50, width=10, height=20)
       @r   r7   )rN   MIDTOPrJ   r   rQ   rO   rR   rZ   s    r&   r   Rect.midtop4  si     ;;"KK4::s):;tyyII4::)9:diiHHr%   c                    U R                   (       a  [        S5      e[        U5        Uu  p#U R                  nU R                  nU R
                  (       as  X R                  U R                  S-  -   :w  d  X0R                  :w  aD  X R                  S-  -
  U l        X0l        U R                  XEU R                  U R                  5        g g X R                  U R                  S-  -   :w  d  X0R                  :w  aX  [        U5      U R                  S-  -
  U l        [        U5      U l        U R                  XEU R                  U R                  5        g g Nrp   r   r7   )
rK   r   r5   rQ   rR   rJ   rO   re   rP   r*   )rS   rj   	newMidToprw   rr   rx   s         r&   r   r   G  s    >>!"<==#E*!	zziiZZ$++*;;;))#&++*;<
"	!!,T[[$,,W	 $ ZZ$++*:::))# ^t{{a/?@
K	!!,T[[$,,W	 $r%   c                 T   U R                   b  U R                  [        5        U R                  (       a;  [        U R                  U R
                  S-  -   U R                  U R                  -   S9$ [        U R                  U R
                  S-  -   U R                  U R                  -   S9$ )z
The x and y coordinates for the midpoint of the bottom edge of the rectangle, as a tuple.

>>> r = Rect(0, 0, 10, 20)
>>> r.midbottom
(5, 20)
>>> r.midbottom = (40, 50)
>>> r
Rect(left=35, top=30, width=10, height=20)
r   r   r7   )rN   	MIDBOTTOMrJ   r   rQ   rO   rR   rP   rZ   s    r&   r   Rect.midbottom`  s{     ;;"KK	"4::s):;tyy4<<?WXX4::)9:dii$,,>VWWr%   c                    U R                   (       a  [        S5      e[        U5        Uu  p#U R                  nU R                  nU R
                  (       a  X R                  U R                  S-  -   :w  d  X0R                  U R                  -   :w  aQ  X R                  S-  -
  U l        X0R                  -
  U l        U R                  XEU R                  U R                  5        g g X R                  U R                  S-  -   :w  d  X0R                  U R                  -   :w  ae  [        U5      U R                  S-  -
  U l        [        U5      U R                  -
  U l        U R                  XEU R                  U R                  5        g g r   
rK   r   r5   rQ   rR   rJ   rO   rP   re   r*   )rS   rj   newMidBottomr   rr   rx   s         r&   r   r   s  s%   >>!"<==#E*"'zzii

T[[3-> >>YY55)[[3->?
%4	!!,T[[$,,W	 6 

T[[A-= ==YY55 .$++2BC
	NT\\9	!!,T[[$,,W	 6r%   c                     U R                   b  U R                  [        5        U R                  (       a.  [        U R                  U R
                  U R                  S-  -   S9$ [        U R                  U R
                  U R                  S-  -   S9$ )z
The x and y coordinates for the midpoint of the left edge of the rectangle, as a tuple.

>>> r = Rect(0, 0, 10, 20)
>>> r.midleft
(0, 10)
>>> r.midleft = (40, 50)
>>> r
Rect(left=40, top=40, width=10, height=20)
r   r   r7   )rN   MIDLEFTrJ   r   rQ   rR   rP   rZ   s    r&   r   Rect.midleft  si     ;;"KK 4::dllS6H)IJJ4::dlla6G)HIIr%   c                    U R                   (       a  [        S5      e[        U5        Uu  p#U R                  nU R                  nU R
                  (       as  X R                  :w  d  X0R                  U R                  S-  -   :w  aD  X l        X0R                  S-  -
  U l        U R                  XEU R                  U R                  5        g g X R                  :w  d  X0R                  U R                  S-  -   :w  aX  [        U5      U l        [        U5      U R                  S-  -
  U l        U R                  XEU R                  U R                  5        g g r   )
rK   r   r5   rQ   rR   rJ   rP   re   rO   r*   )rS   rj   rq   
newMidLeftrr   rx   s         r&   r   r     s    >>!"<==#E*#zzii::%ii4<<#+=>>$
&,,*<=	!!,T[[$,,W	 ? ::%ii4<<1+<== \

Ot||q/@A	!!,T[[$,,W	 >r%   c                 T   U R                   b  U R                  [        5        U R                  (       a;  [        U R                  U R
                  -   U R                  U R                  S-  -   S9$ [        U R                  U R
                  -   U R                  U R                  S-  -   S9$ )z
The x and y coordinates for the midpoint of the right edge of the rectangle, as a tuple.

>>> r = Rect(0, 0, 10, 20)
>>> r.midright
(10, 10)
>>> r.midright = (40, 50)
>>> r
Rect(left=30, top=40, width=10, height=20)
r   r   r7   )rN   MIDRIGHTrJ   r   rQ   rO   rR   rP   rZ   s    r&   r   Rect.midright  s}     ;;"KK!4::3tyyDLLSVDV7WXX4::3tyyDLLTUDU7VWWr%   c                    U R                   (       a  [        S5      e[        U5        Uu  p#U R                  nU R                  nU R
                  (       a  X R                  U R                  -   :w  d  X0R                  U R                  S-  -   :w  aQ  X R                  -
  U l        X0R                  S-  -
  U l        U R                  XEU R                  U R                  5        g g X R                  U R                  -   :w  d  X0R                  U R                  S-  -   :w  ae  [        U5      U R                  -
  U l        [        U5      U R                  S-  -
  U l        U R                  XEU R                  U R                  5        g g r   r   )rS   rj   r}   newMidRightrr   rx   s         r&   r   r     s%   >>!"<==#E* %zziiJJ44yy4<<#+===%3
'<<#+=>	!!,T[[$,,W	 > JJ44yy4<<1+<<< ]T[[8
,0AB	!!,T[[$,,W	 =r%   c                 `   U R                   b  U R                  [        5        U R                  (       a>  [        U R                  U R
                  S-  -   U R                  U R                  S-  -   S9$ [        U R                  U R
                  S-  -   U R                  U R                  S-  -   S9$ )z
The x and y coordinates for the center of the rectangle, as a tuple.

>>> r = Rect(0, 0, 10, 20)
>>> r.center
(5, 10)
>>> r.center = (40, 50)
>>> r
Rect(left=35, top=40, width=10, height=20)
r   r   r7   )rN   CENTERrJ   r   rQ   rO   rR   rP   rZ   s    r&   r   Rect.center  s     ;;"KK**c 12dii4<<RUCU6V  **q 01TYY$,,RSBS5T r%   c                    U R                   (       a  [        S5      e[        U5        Uu  p#U R                  nU R                  nU R
                  (       a  X R                  U R                  S-  -   :w  d  X0R                  U R                  S-  -   :w  aT  X R                  S-  -
  U l        X0R                  S-  -
  U l        U R                  XEU R                  U R                  5        g g X R                  U R                  S-  -   :w  d  X0R                  U R                  S-  -   :w  ah  [        U5      U R                  S-  -
  U l        [        U5      U R                  S-  -
  U l        U R                  XEU R                  U R                  5        g g r   r   )rS   rj   
newCenterx
newCenteryrr   rx   s         r&   r   r     s8   >>!"<==#E*!&
zziijj4;;+<<<ii$,,*<<<';;+<=
&,,*<=	!!,T[[$,,W	 = jj4;;!+;;;ii$,,!*;;; _q0@A

Ot||q/@A	!!,T[[$,,W	 <r%   c                     U R                   b  U R                  [        5        U R                  (       a  U R                  U R                  S-  -   $ U R                  U R                  S-  -   $ )z
The x coordinate for the center of the rectangle, as a tuple.

>>> r = Rect(0, 0, 10, 20)
>>> r.centerx
5
>>> r.centerx = 50
>>> r
Rect(left=45, top=0, width=10, height=20)
r   r7   )rN   CENTERXrJ   rQ   rO   rZ   s    r&   r   Rect.centerx  sS     ;;"KK ::s!233::!122r%   c                 >   U R                   (       a  [        S5      e[        U5        U R                  nU R                  (       ah  XR                  U R
                  S-  -   :w  aH  XR
                  S-  -
  U l        U R                  X R                  U R
                  U R                  5        g g XR                  U R
                  S-  -   :w  aR  [        U5      U R
                  S-  -
  U l        U R                  X R                  U R
                  U R                  5        g g r   )
rK   r   r/   rQ   rJ   rO   re   rR   rP   r*   )rS   r   rr   s      r&   r   r   '  s    >>!"<==J'zzjj4;;+<<<';;+<=
!!,		4;;U = jj4;;!+;;; _q0@A
!!,		4;;U <r%   c                     U R                   b  U R                  [        5        U R                  (       a  U R                  U R                  S-  -   $ U R                  U R                  S-  -   $ )z
The y coordinate for the center of the rectangle, as a tuple.

>>> r = Rect(0, 0, 10, 20)
>>> r.centery
10
>>> r.centery = 50
>>> r
Rect(left=0, top=40, width=10, height=20)
r   r7   )rN   CENTERYrJ   rR   rP   rZ   s    r&   r   Rect.centery<  sS     ;;"KK 99s 23399 122r%   c                 >   U R                   (       a  [        S5      e[        U5        U R                  nU R                  (       ah  XR                  U R
                  S-  -   :w  aH  XR
                  S-  -
  U l        U R                  U R                  X R                  U R
                  5        g g XR                  U R
                  S-  -   :w  aR  [        U5      U R
                  S-  -
  U l        U R                  U R                  X R                  U R
                  5        g g r   )
rK   r   r/   rR   rJ   rP   re   rQ   rO   r*   )rS   r   rx   s      r&   r   r   O  s    >>!"<==J'iiii$,,*<<<&,,*<=	!!$**k;;U = ii$,,!*;;;
Ot||q/@A	!!$**k;;U <r%   c                     U R                   b  U R                  [        5        [        U R                  U R                  S9$ )z
The width and height of the rectangle, as a tuple.

>>> r = Rect(0, 0, 10, 20)
>>> r.size
(10, 20)
>>> r.size = (40, 50)
>>> r
Rect(left=0, top=0, width=40, height=50)
)r   r   )rN   SIZEr   rO   rP   rZ   s    r&   r   	Rect.sized  s/     ;;"KK$++dll;;r%   c                    U R                   (       a  [        S5      e[        U5        Uu  p#X R                  :w  d  X0R                  :w  a~  U R                  nU R                  nU R
                  (       a  X l        X0l        O [        U5      U l        [        U5      U l        U R                  U R                  U R                  XE5        g g ro   )
rK   r   r5   rO   rP   rJ   r*   re   rQ   rR   )rS   rj   newWidth	newHeightoriginalWidthoriginalHeights         r&   r   r   t  s    >>!"<==#E*#{{"i<<&? KKM!\\N  &(!(m"9~djj$))]S '@r%   c                 ^    U R                   b  U R                  [        5        U R                  $ )z
The width of the rectangle. `w` is an alias for `width`.

>>> r = Rect(0, 0, 10, 20)
>>> r.width
10
>>> r.width = 50
>>> r
Rect(left=0, top=0, width=50, height=20)
)rN   WIDTHrO   rZ   s    r&   r   
Rect.width  s$     ;;"KK{{r%   c                 <   U R                   (       a  [        S5      e[        U5        XR                  :w  af  U R                  nU R                  (       a  Xl        O[        U5      U l        U R                  U R                  U R                  X R                  5        g g ro   )
rK   r   r/   rO   rJ   r*   re   rQ   rR   rP   )rS   r   r   s      r&   r   r     sl    >>!"<==H%# KKM  &!(mdjj$))]LLQ $r%   c                 ^    U R                   b  U R                  [        5        U R                  $ )z
The height of the rectangle. `h` is an alias for `height`

>>> r = Rect(0, 0, 10, 20)
>>> r.height
20
>>> r.height = 50
>>> r
Rect(left=0, top=0, width=10, height=50)
)rN   HEIGHTrP   rZ   s    r&   r   Rect.height  s$     ;;"KK||r%   c                 >   U R                   (       a  [        S5      e[        U5        XR                  :w  ag  U R                  nU R                  (       a  Xl        O[        U5      U l        U R                  U R                  U R                  U R                  U5        g g ro   )
rK   r   r/   rP   rJ   r*   re   rQ   rR   rO   )rS   r   r   s      r&   r   r     sn    >>!"<==I&%!\\N  ("9~djj$))T[[.Q &r%   c                 x    U R                   b  U R                  [        5        U R                  U R                  -  $ )zThe area of the `Rect`, which is simply the width times the height.
This is a read-only attribute.

>>> r = Rect(0, 0, 10, 20)
>>> r.area
200
rN   AREArO   rP   rZ   s    r&   r   	Rect.area  s-     ;;"KK{{T\\))r%   c                 ~    U R                   b  U R                  [        5        U R                  U R                  -   S-  $ )zThe perimeter of the `Rect`, which is simply the (width + height) * 2.
This is a read-only attribute.

>>> r = Rect(0, 0, 10, 20)
>>> r.area
200
r7   r   rZ   s    r&   r   Rect.perimeter  s2     ;;"KKdll*a//r%   c                     U R                   b  U R                  [        5        [        U R                  U R                  U R
                  U R                  S9$ )zA tuple of four integers: (left, top, width, height).

>>> r = Rect(0, 0, 10, 20)
>>> r.box
(0, 0, 10, 20)
>>> r.box = (5, 15, 100, 200)
>>> r.box
(5, 15, 100, 200))r   r   r   r   )rN   BOXr   rQ   rR   rO   rP   rZ   s    r&   r   Rect.box  s@     ;;"KK$++dll
 	
r%   c                 ~   U R                   (       a  [        S5      e[        U5        Uu  p#pEX R                  :w  d-  X0R                  :w  d  X@R
                  :w  d  XPR                  :w  a  U R                  nU R                  nU R
                  nU R                  n	U R                  (       aA  [        U5      U l        [        U5      U l        [        U5      U l        [        U5      U l        O@[        U5      U l        [        U5      U l        [        U5      U l        [        U5      U l        U R                  XgX5        g g ro   )rK   r   r9   rQ   rR   rO   rP   rJ   r+   r*   re   )
rS   rj   rq   rw   r   r   rr   rx   r   r   s
             r&   r   r     s    >>!"<==$U+/4,

"))#KK'\\)::L))K KKM!\\N  "7^
!&M	#Ho$Y/ \
K	!(m"9~lW! *r%   c                    U[         :X  a  U R                  $ U[        :X  a  U R                  $ U[        :X  a  U R
                  $ U[        :X  a  U R                  $ U[        :X  a  U R                  $ U[        :X  a  U R                  $ U[        :X  a  U R                  $ U[        :X  a  U R                  $ U[         :X  a  U R"                  $ U[$        :X  a  U R&                  $ U[(        :X  a  U R*                  $ U[,        :X  a  U R.                  $ U[0        :X  a  U R2                  $ U[4        :X  a  U R6                  $ U[8        :X  a  U R:                  $ U[<        :X  a  U R>                  $ U[@        :X  a  U RB                  $ U[D        :X  a  U RF                  $ U[H        :X  a  U RJ                  $ U[L        :X  a  U RN                  $ [Q        SU-  5      e)N"'%s' is not a valid attribute name))rt   r   r   r   rl   r   rz   r   r   r   r   r   r   r	   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )rS   rectAttrNames     r&   getRect.get  s{   388OV#;;T!99U"::W$<<X%== Z'??"[(###V#;;Y&>>!W$<<X%== V#;;W$<<W$<<U"::V#;;T!99T!99S 88O!"F,"WXXr%   c                    U[         :X  a  X l        g U[        :X  a  X l        g U[        :X  a  X l        g U[        :X  a  X l        g U[        :X  a  X l	        g U[        :X  a  X l        g U[        :X  a  X l        g U[        :X  a  X l        g U[         :X  a  X l        g U[$        :X  a  X l        g U[(        :X  a  X l        g U[,        :X  a  X l        g U[0        :X  a  X l        g U[4        :X  a  X l        g U[8        :X  a  X l        g U[<        :X  a  X l        g U[@        :X  a  X l!        g U[D        :X  a  X l#        g U[H        :X  a  [K        S5      eU[L        :X  a  X l'        g [K        SU-  5      e)Nzarea is a read-only attributer   )(rt   r   r   r   rl   r   rz   r   r   r   r   r   r   r	   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )rS   r   rj   s      r&   setRect.setE  s   3HV#KT!IU"JW$ LX%!MZ'#O[($V#KY&"NW$ LX%!MV#KW$ LW$ LU"JV#KT!IT!!"ABBS H!"F,"WXXr%   c                 X   U R                   (       a  [        S5      e[        U5        [        U5        U R                  (       a+  U =R                  U-  sl        U =R
                  U-  sl        gU =R                  [        U5      -  sl        U =R
                  [        U5      -  sl        g)zMoves this Rect object by the given offsets. The xOffset and yOffset
arguments can be any integer value, positive or negative.
>>> r = Rect(0, 0, 100, 100)
>>> r.move(10, 20)
>>> r
Rect(left=10, top=20, width=100, height=100)
rp   N)rK   r   r/   rJ   rQ   rR   r*   )rS   xOffsetyOffsets      r&   move	Rect.mover  sp     >>!"<==G$G$JJ'!JII IJJ#g,&JIIW%Ir%   c                     [        U R                  U R                  U R                  U R                  U R
                  U R                  5      $ )zReturn a copied `Rect` object with the same position and size as this
`Rect` object.

>>> r1 = Rect(0, 0, 100, 150)
>>> r2 = r1.copy()
>>> r1 == r2
True
>>> r2
Rect(left=0, top=0, width=100, height=150)
)rF   rQ   rR   rO   rP   rJ   rK   rZ   s    r&   copy	Rect.copy  s=     JJIIKKLLNN
 	
r%   c                     U R                   (       a  [        S5      eU R                  nU =R                  U-  sl        U =R                  U-  sl        X0l        g)zIncreases the size of this Rect object by the given offsets. The
rectangle's center doesn't move. Negative values will shrink the
rectangle.

>>> r = Rect(0, 0, 100, 150)
>>> r.inflate(20, 40)
>>> r
Rect(left=-10, top=-20, width=120, height=190)
rp   N)rK   r   r   r   r   )rS   widthChangeheightChangeoriginalCenters       r&   inflateRect.inflate  sA     >>!"<==

k!
|#$r%   c                 ^    U R                   (       a  [        S5      eUR                  U l        g)zCenters this Rect object at the center of otherRect.

>>> r1 =Rect(0, 0, 100, 100)
>>> r2 = Rect(-20, -90, 50, 50)
>>> r2.clamp(r1)
>>> r2
Rect(left=25, top=25, width=50, height=50)
>>> r1.center == r2.center
True
rp   N)rK   r   r   )rS   	otherRects     r&   clamp
Rect.clamp  s$     >>!"<==&&r%   c                 @   [        U R                  UR                  5      n[        U R                  UR                  5      n[        U R                  UR                  5      n[        U R
                  UR
                  5      nX l        X0l        XB-
  U l        XS-
  U l        g)zAdjusts the width and height to also cover the area of `otherRect`.

>>> r1 = Rect(0, 0, 100, 100)
>>> r2 = Rect(-10, -10, 100, 100)
>>> r1.union(r2)
>>> r1
Rect(left=-10, top=-10, width=110, height=110)
N)minrQ   rR   maxr   r   rO   rP   )rS   r   	unionLeftunionTop
unionRightunionBottoms         r&   union
Rect.union  st     

IOO4	tyy)..1Y__5
$++y'7'78
	 ,"-r%   c                    [        U5      nUR                  U 5        [        U Vs/ s H  o"R                  PM     sn5      n[        U Vs/ s H  o"R                  PM     sn5      n[        U Vs/ s H  o"R                  PM     sn5      n[        U Vs/ s H  o"R                  PM     sn5      nX0l        X@l        XS-
  U l        Xd-
  U l	        gs  snf s  snf s  snf s  snf )a  Adjusts the width and height to also cover all the `Rect` objects in
the `otherRects` sequence.

>>> r = Rect(0, 0, 100, 100)
>>> r1 = Rect(0, 0, 150, 100)
>>> r2 = Rect(-10, -10, 100, 100)
>>> r.unionAll([r1, r2])
>>> r
Rect(left=-10, top=-10, width=160, height=110)
N)
listr?   r   rQ   rR   r   r   r   rO   rP   )rS   
otherRectsrr   r   r   r   s          r&   unionAllRect.unionAll  s     *%
$*5*Q*56	
3
1
34:6:a'':67
Z8Z88Z89
	 ,"- 6368s   CC0CCc                 B   U R                   (       a  [        S5      eU R                  S:  a1  U R                  * U l        U =R                  U R                  -  sl        U R                  S:  a2  U R                  * U l        U =R
                  U R                  -  sl        gg)a  Rect objects with a negative width or height cover a region where the
right/bottom edge is to the left/above of the left/top edge, respectively.
The `normalize()` method sets the `width` and `height` to positive if they
were negative.

The Rect stays in the same place, though with the `top` and `left`
attributes representing the true top and left side.

>>> r = Rect(0, 0, -10, -20)
>>> r.normalize()
>>> r
Rect(left=-10, top=-20, width=10, height=20)
rp   r   N)rK   r   rO   rQ   rP   rR   rZ   s    r&   	normalizeRect.normalize  sq     >>!"<==;;?;;,DKJJ$++%J<<! LL=DLII%I r%   c                 H   [        U[        5      (       aQ  UR                  U ;   =(       a;    UR                  U ;   =(       a%    UR                  U ;   =(       a    UR
                  U ;   $  [        U5        [        U5      S:X  a  [        U5        Uu  p#U R                  Us=:  =(       a    U R                  U R                  -   :  Os  =(       a6    U R                  Us=:  =(       a    U R                  U R                  -   :  $ s  $ [        U5      S:X  aH  [        U5        Uu  pEpgXE4U ;   =(       a+    XF-   U4U ;   =(       a    XEU-   4U ;   =(       a    XF-   XW-   4U ;   $ [        SUR                  R                  -  5      e!   [        SUR                  R                  -  5      e= f)Npin <Rect> requires an (x, y) tuple, a (left, top, width, height) tuple, or a Rect object as left operand, not %sr7      )r)   rF   r   r   r	   r
   lenr   r,   r   r5   rQ   rO   rR   rP   r9   rS   rj   r   r   r   r   r   r   s           r&   __contains__Rect.__contains__  s    eT""% .NNd*.$$,. %%-		J u:?'.DA

Q99dkk!99 =II<<DII$<<<
 Z1_(/',$Dut# 9\3'4/9<(D09 \3<0D8	 " C??++- 5	! C??++- s   (E= =$F!c                 2   [        U[        5      (       aQ  UR                  U ;   =(       d;    UR                  U ;   =(       d%    UR                  U ;   =(       d    UR
                  U ;   $  [        U5        [        U5      S:X  a  [        U5        Uu  p#U R                  Us=:  =(       a    U R                  U R                  -   :  Os  =(       a6    U R                  Us=:  =(       a    U R                  U R                  -   :  $ s  $ [        U5      S:X  a=  Uu  pEpgXE4U ;   =(       d+    XF-   U4U ;   =(       d    XEU-   4U ;   =(       d    XF-   XW-   4U ;   $ [        SUR                  R                  -  5      e!   [        SUR                  R                  -  5      e= f)a@  Returns `True` if value collides with this `Rect` object, where value can
be an (x, y) tuple, a (left, top, width, height) box tuple, or another `Rect`
object. If value represents a rectangular area, any part of that area
can collide with this `Rect` object to make `collide()` return `True`.
Otherwise, returns `False`.r  r7   r  )r)   rF   r   r   r	   r
   r  r   r,   r   r5   rQ   rO   rR   rP   r  s           r&   collideRect.collideD  s    eT""% ->>T)-##t+- $$,		J u:?'.DA

Q99dkk!99 =II<<DII$<<<
 Z1_',$Dut# 8L#&$.8,'4/8 L#,/47	 " C??++- 3	! C??++- s   (E2 2$Fc                 t    [        U[        5      (       a  UR                  U R                  :H  $ [        S5      eNz9Rect objects can only be compared with other Rect objectsr)   rF   r   r   rS   others     r&   __eq__Rect.__eq__  2    eT""99((!K r%   c                 t    [        U[        5      (       a  UR                  U R                  :g  $ [        S5      er  r  r  s     r&   __ne__Rect.__ne__  r  r%   )rJ   rP   rQ   rK   rR   rO   r   r	   r
   r   r   r   r   r   r   r   r   r   r   rM   rN   r   r   r   r   r   r   )r   r   r   r   FFNN)r   r   )2r   r    r!   r"   rV   r[   r^   re   propertyrT   setterr   r   r   r   r   r   r   r	   r   r
   r   r   r   r   r   r   r   r   r   wr   hr   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r  r$   r   r%   r&   rF   rF      s}    (!V

 ! ! - -"   
[[R R 	A   	ZZR R 	A ( ( \\R R  ( ( ]]R R  0 0 ^^T T( ? ? T T( > > __T T( M M T T( I I$ ]]X X0 X X$ X X0 J J$ ^^X X0 X X$ __X X0  , ]]X X0 3 3$ ^^V V( 3 3$ ^^V V( < < 
[[T T$   \\R R 	A   ]]R R 	A 
* 
* 
0 
0 
 
 	ZZX X8+YZ+YZ&(
(%$' 
.,.6
&2+Z1f*
r%   rF   __main__))doctestcollections__version__rt   r   rl   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	PERIMETER
namedtupler   r   r   	Exceptionr   r/   r1   r5   r9   r=   rD   objectrF   r   printtestmodr   r%   r&   <module>r$     s      	

	
		

		U$;<w.fn5	i 	

	

"Q <DA6 AH( z	'//
 r%   