This module defines the
Size tuple and give some classic use cases.
- class benker.size.Size(width, height)¶
Size of a cell: width is the number of columns and height is the number of row.
>>> from benker.size import Size
>>> size = Size(2, 1) >>> size Size(width=2, height=1) >>> size.width 2 >>> size.height 1 >>> str(size) '(2 x 1)'
You can use the “+” or “-” operators to increase or decrease the size:
>>> Size(2, 1) + Size(3, 3) Size(width=5, height=4) >>> Size(5, 4) - Size(3, 3) Size(width=2, height=1)
You can expand the width and height to a given factor using the “*” operator:
>>> Size(2, 1) * 2 Size(width=4, height=2)
You can have negative or positive sizes using the unary operators “-” and “+”:
>>> +Size(3, 2) Size(width=3, height=2) >>> -Size(3, 2) Size(width=-3, height=-2)
Cellobject cannot have a negative or nul sizes, but you can need this values for calculation, for instance when you want to reduce the cell size.