o
    @@£iW  ã                   @   s"   d Z ddlmZ G dd„ dƒZdS )zU
In Euclidean plane geometry, a rectangle is a quadrilateral with four right angles.
é    )ÚDecimalc                   @   sÌ   e Zd ZdZdedededefdd„Zdd	„ Zd
ededefdd„Zd
ededefdd„Z	defdd„Z
defdd„Zdefdd„Zdefdd„Zdedd fdd„Zdd defdd„Zdedd fdd „Zd!S )"Ú	Rectangleu²  
    In Euclidean plane geometry, a rectangle is a quadrilateral with four right angles.
    It can also be defined as an equiangular quadrilateral, since equiangular means that all of its angles are equal (360Â°/4 = 90Â°).
    It can also be defined as a parallelogram containing a right angle. A rectangle with four sides of equal length is a square.
    The term oblong is occasionally used to refer to a non-square rectangle.
    Úlower_left_xÚlower_left_yÚwidthÚheightc                 C   s<   |dksJ dƒ‚|dksJ dƒ‚|| _ || _|| _|| _d S )Nr   z+A Rectangle must have a non-negative width.z,A Rectangle must have a non-negative height.)ÚxÚyr   r   )Úselfr   r   r   r   © r   ú`/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/borb/pdf/canvas/geometry/rectangle.pyÚ__init__   s   
zRectangle.__init__c                 C   sZ   d}t | jƒt | jƒt | jƒt | jƒfD ]}t|ƒ}|||d> A dA d N }q|d d S )NiMïèré   i³M[l   ×4~2 iÍ iãÃ6)Úintr   r	   r   r   Úhash)r
   Úattr_hash_for_layoutÚaÚhr   r   r   Ú__hash__)   s
   (zRectangle.__hash__r   r	   Úreturnc                 C   s,   || j | j | j fv o|| j| j| j fv S )z„
        This function returns True if the circumference of this Rectangle contains the given point
        False otherwise
        ©r   r   r	   r   ©r
   r   r	   r   r   r   Úcircumference_contains4   s   
þz Rectangle.circumference_containsc                 C   sD   | j |  ko| j | j kn  o!| j|  ko| j| j kS   S )zo
        This function returns True if this Rectangle contains the given point
        False otherwise
        r   r   r   r   r   Úcontains>   s   0

ÿzRectangle.containsc                 C   ó   | j S )zD
        This function returns the height of this Rectangle
        )r   ©r
   r   r   r   Ú
get_heightG   ó   zRectangle.get_heightc                 C   r   )zC
        This function returns the width of this Rectangle
        )r   r   r   r   r   Ú	get_widthM   r   zRectangle.get_widthc                 C   r   )z\
        This function returns the x-coordinate of the lower-left of this Rectangle
        )r   r   r   r   r   Úget_xS   r   zRectangle.get_xc                 C   r   )z\
        This function returns the y-coordinate of the lower-left of this Rectangle
        )r	   r   r   r   r   Úget_yY   r   zRectangle.get_yÚamountc                 C   sB   |dksJ ‚t | j| | j| | jtdƒ|  | jtdƒ|  ƒS )zh
        This function returns a (slightly) larger Rectangle,
        grown by the given amount
        r   é   ©r   r   r	   r   r   r   ©r
   r!   r   r   r   Úgrow_   ó   üzRectangle.growÚother_rectanglec                 C   s    |j | j   ko|j |j kn  }|p%| j |j   ko#| j | j kn  }|j| j  ko5|j|j kn  }|pK| j|j  koI| j| j kn  }|oO|S )z{
        This function returns True if this Rectangle intersects with the given Rectangle,
        False otherwise
        r   )r
   r'   Úx_intersectÚy_intersectr   r   r   Ú
intersectsl   s
   $($(zRectangle.intersectsc                 C   sB   |dksJ ‚t | j| | j| | jtdƒ|  | jtdƒ|  ƒS )zj
        This function returns a (slightly) smaller Rectangle,
        shrunk by the given amount
        r   r"   r#   r$   r   r   r   Úshrinky   r&   zRectangle.shrinkN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Úboolr   r   r   r   r   r    r%   r*   r+   r   r   r   r   r   
   s*    þýü
û
	r   N)r/   Údecimalr   r   r   r   r   r   Ú<module>   s   