o
    h                     @   s(   d dl Z G dd dZG dd dZdS )    Nc                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )Vectorc                 C   s   || _ || _d S Nxy)selfr   r    r   S/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/images/rect.py__init__   s   
zVector.__init__c                 C   s   t | j| jfS r   )iterr   r   r   r   r   r	   __iter__	      zVector.__iter__c                 C   s   | j | jf| S r   r   r   keyr   r   r	   __getitem__   r   zVector.__getitem__c                 C      t | t |kS r   tupler   otherr   r   r	   __eq__   r   zVector.__eq__c                 C   s   d| j | jf S )NzVector(x: %d, y: %d)r   r   r   r   r	   __repr__   r   zVector.__repr__N)__name__
__module____qualname__r
   r   r   r   r   r   r   r   r	   r      s    r   c                   @   s   e Zd Zdd Zdd Zdd ZeeeZedd Zed	d
 Z	dd Z
dd Zee
eZedd Zedd Zedd Zedd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zed+d, Zd-S ).Rectc                 C   s   || _ || _|| _|| _d S r   lefttoprightbottom)r   r   r   r    r!   r   r   r	   r
      s   
zRect.__init__c                 C   s   t | j| j | j| j S r   )r   r    r   r!   r   r   r   r   r	   	_get_size      zRect._get_sizec                 C   sb   | j }|d |d d  | _|d |d d  | _|d |d d  | _|d |d d  | _d S Nr         )centroidr   r    r   r!   )r   new_sizer'   r   r   r	   	_set_size    
   zRect._set_sizec                 C      | j jS r   )sizer   r   r   r   r	   width)      z
Rect.widthc                 C   r+   r   )r,   r   r   r   r   r	   height-   r.   zRect.heightc                 C   s"   t | j| j d | j| j d S Nr%   )r   r   r    r   r!   r   r   r   r	   _get_centroid1   s   "zRect._get_centroidc                 C   sb   | j }|d |d d  | _|d |d d  | _|d |d d  | _|d |d d  | _d S r$   )r,   r   r    r   r!   )r   new_centroidr,   r   r   r	   _set_centroid4   r*   zRect._set_centroidc                 C   r+   r   r'   r   r   r   r   r	   r   =   r.   zRect.xc                 C   r+   r   r'   r   r   r   r   r	   r   A   r.   zRect.yc                 C   r+   r   r4   r   r   r   r	   
centroid_xE      zRect.centroid_xc                 C   r+   r   r5   r   r   r   r	   
centroid_yJ   r7   zRect.centroid_yc                 C   s   | j | j| j| jfS r   r   r   r   r   r	   as_tupleO   s   zRect.as_tuplec                 C   s   t | | j| j| j| jS r   )typer   r   r    r!   r   r   r   r	   cloneT   r#   z
Rect.clonec                 C   sT   |   }tt|j|_tt|j|_tt|j|_tt|j|_|S )zL
        Returns a new rect with all attributes rounded to integers
        )	r;   intmathfloorr   r   ceilr    r!   )r   r;   r   r   r	   roundW   s   z
Rect.roundc                 C   s   t | }|  }|j|jk r| j|j|j 8  _|j|_|j|jk r2| j|j|j 8  _|j|_|j|jkrG| j|j|j 8  _|j|_|j|jkr\| j|j|j 8  _|j|_|S )z}
        Moves this rect so it is completely covered by the rect in "other" and
        returns a new Rect instance.
        r   r;   r   r    r   r!   r   r   r;   r   r   r	   move_to_clampg      zRect.move_to_clampc                 C   s   t | }|  }|j|jkr| j|j|j 8  _|j|_|j|jkr2| j|j|j 8  _|j|_|j|jk rG| j|j|j 7  _|j|_|j|jk r\| j|j|j 7  _|j|_|S )z
        Moves this rect so it completely covers the rect specified in the
        "other" parameter and returns a new Rect instance.
        rA   rB   r   r   r	   move_to_cover   rD   zRect.move_to_coverc           
      C   s   | t| j| j}| t| j| j}| t| j| j}| t| j| j}t|j|j|j|jg}t|j|j|j|jg}t|j	|j	|j	|j	g}t|j	|j	|j	|j	g}	t
||||	S r   )transform_vectorr   r   r   r    r!   minr   maxr   r   )
r   	transformtl_transformedtr_transformedbl_transformedbr_transformedr   r    r   r!   r   r   r	   rI      s"   zRect.transformc                 C   s   t | j| j| j| jfS r   )r   r   r   r    r!   r   r   r   r	   r         zRect.__iter__c                 C   s   | j | j| j| jf| S r   r   r   r   r   r	   r      rN   zRect.__getitem__c                 C   r   r   r   r   r   r   r	   r      r   zRect.__eq__c                 C   s   d| j | j| j| jf S )Nz.Rect(left: %d, top: %d, right: %d, bottom: %d)r   r   r   r   r	   r      s   zRect.__repr__c                 C   s.   | ||d  ||d  ||d  ||d  S r0   r   )clsr   r   r-   r/   r   r   r	   
from_point   s   



zRect.from_pointN)r   r   r   r
   r"   r)   propertyr,   r-   r/   r1   r3   r'   r   r   r6   r8   r9   r;   r@   rC   rE   rI   r   r   r   r   classmethodrP   r   r   r   r	   r      s@    







r   )r=   r   r   r   r   r   r	   <module>   s    