`Margin` class has the properties to set margins for all sides of the rectangle.
| 8 | |
| 9 | @value |
| 10 | class Margin: |
| 11 | """ |
| 12 | `Margin` class has the properties to set margins for all sides of the rectangle. |
| 13 | """ |
| 14 | |
| 15 | left: Number = 0 |
| 16 | """ |
| 17 | The margin applied to the left. |
| 18 | """ |
| 19 | |
| 20 | top: Number = 0 |
| 21 | """ |
| 22 | The margin applied to the top. |
| 23 | """ |
| 24 | |
| 25 | right: Number = 0 |
| 26 | """ |
| 27 | The margin applied to the right. |
| 28 | """ |
| 29 | |
| 30 | bottom: Number = 0 |
| 31 | """ |
| 32 | The margin applied to the bottom. |
| 33 | """ |
| 34 | |
| 35 | @classmethod |
| 36 | def all(cls, value: Number) -> "Margin": |
| 37 | """ |
| 38 | Applies the same margin to all sides. |
| 39 | """ |
| 40 | return Margin(left=value, top=value, right=value, bottom=value) |
| 41 | |
| 42 | @classmethod |
| 43 | def symmetric(cls, *, vertical: Number = 0, horizontal: Number = 0) -> "Margin": |
| 44 | """ |
| 45 | Applies `vertical` margin to top and bottom sides and `horizontal` margin to \ |
| 46 | left and right sides. |
| 47 | """ |
| 48 | return Margin(left=horizontal, top=vertical, right=horizontal, bottom=vertical) |
| 49 | |
| 50 | @classmethod |
| 51 | def only( |
| 52 | cls, *, left: Number = 0, top: Number = 0, right: Number = 0, bottom: Number = 0 |
| 53 | ) -> "Margin": |
| 54 | """ |
| 55 | Applies margin to the specified sides. |
| 56 | """ |
| 57 | return Margin(left=left, top=top, right=right, bottom=bottom) |
| 58 | |
| 59 | |
| 60 | MarginValue = Union[Number, Margin] |