39 lines
932 B
Python
39 lines
932 B
Python
from classes.science.side import Side
|
|
from gettext import gettext as _
|
|
|
|
class Border:
|
|
"""
|
|
Define a rectangle with coordinate as edge
|
|
"""
|
|
|
|
def __init__( self , x = Side() , y = Side() ):
|
|
if not isinstance( x , Side ) or not isinstance( y , Side ):
|
|
raise TypeError( _( 'x and y should be sides' ) )
|
|
self.x = x
|
|
self.y = y
|
|
|
|
def scale( self , factor ):
|
|
"""
|
|
Update coordinate to adapt from compression
|
|
"""
|
|
self.x.scale( factor )
|
|
self.y.scale( factor )
|
|
def slice( self ):
|
|
"""
|
|
Return rectangular slice
|
|
"""
|
|
return (
|
|
slice(
|
|
self.y.min , self.y.max
|
|
),
|
|
slice(
|
|
self.x.min , self.x.max,
|
|
),
|
|
)
|
|
def __str__( self ):
|
|
return '\
|
|
border [\
|
|
\n x: ' + str( self.x ) + ',\
|
|
\n y: ' + str( self.y ) + ',\
|
|
\n]\
|
|
'
|