Split a region into 4 from given x and y offsets (cuts). ``` cut_x ↓ ┌────────┐ ┌───┐ │ │ │ │ │ 0 │ │ 1 │ │ │ │ │ cut_y → └────────┘ └───┘ ┌────────┐ ┌───┐
(self, cut_x: int, cut_y: int)
| 861 | |
| 862 | @lru_cache(maxsize=1024) |
| 863 | def split(self, cut_x: int, cut_y: int) -> tuple[Region, Region, Region, Region]: |
| 864 | """Split a region into 4 from given x and y offsets (cuts). |
| 865 | |
| 866 | ``` |
| 867 | cut_x ↓ |
| 868 | ┌────────┐ ┌───┐ |
| 869 | │ │ │ │ |
| 870 | │ 0 │ │ 1 │ |
| 871 | │ │ │ │ |
| 872 | cut_y → └────────┘ └───┘ |
| 873 | ┌────────┐ ┌───┐ |
| 874 | │ 2 │ │ 3 │ |
| 875 | └────────┘ └───┘ |
| 876 | ``` |
| 877 | |
| 878 | Args: |
| 879 | cut_x: Offset from self.x where the cut should be made. If negative, the cut |
| 880 | is taken from the right edge. |
| 881 | cut_y: Offset from self.y where the cut should be made. If negative, the cut |
| 882 | is taken from the lower edge. |
| 883 | |
| 884 | Returns: |
| 885 | Four new regions which add up to the original (self). |
| 886 | """ |
| 887 | |
| 888 | x, y, width, height = self |
| 889 | if cut_x < 0: |
| 890 | cut_x = width + cut_x |
| 891 | if cut_y < 0: |
| 892 | cut_y = height + cut_y |
| 893 | |
| 894 | _Region = Region |
| 895 | return ( |
| 896 | _Region(x, y, cut_x, cut_y), |
| 897 | _Region(x + cut_x, y, width - cut_x, cut_y), |
| 898 | _Region(x, y + cut_y, cut_x, height - cut_y), |
| 899 | _Region(x + cut_x, y + cut_y, width - cut_x, height - cut_y), |
| 900 | ) |
| 901 | |
| 902 | @lru_cache(maxsize=1024) |
| 903 | def split_vertical(self, cut: int) -> tuple[Region, Region]: |
no outgoing calls