classes.c20_box
1from typing import Literal, Union 2from loguru import logger 3import drawBot 4 5from lib import layout, helpers, color 6 7 8class KBox: 9 "A layout primitive with coordinates, dimensions and spatial utilities." 10 11 def __init__(self, coords: tuple) -> None: 12 """ 13 Initialize a KBox with given coordinates. 14 15 See `lib.layout.parsePageSize` for possible coordinate types. 16 17 Args: 18 coords: A tuple of (x, y, width, height) coordinates. 19 20 Example: 21 ```python 22 # Create a new box with coordinates 23 box = KBox((10, 10, 100, 50)) # x, y, width, height 24 25 # Move the box 26 box.move(x=20, y=10) 27 28 # Grow the box by adding margin 29 box.grow((5, 5, 5, 5)) # left, bottom, right, top margins 30 ``` 31 """ 32 self.x, self.y, self.width, self.height = layout.toCoords(coords) 33 34 @property 35 def position(self) -> tuple[int, int]: 36 """ 37 Returns the x and y coordinates of the bottom-left corner. 38 """ 39 return self.x, self.y 40 41 @position.setter 42 def position(self, value: tuple[int, int]) -> None: 43 """ 44 Set the position (x, y) of the box. 45 """ 46 try: 47 self.x, self.y = value 48 except: 49 logger.warning("Unable to set KBox position: {}", value) 50 51 @property 52 def dimensions(self) -> tuple[int, int]: 53 """ 54 Returns the dimensions (width, height) of the box. 55 """ 56 return self.width, self.height 57 58 @dimensions.setter 59 def dimensions(self, value: tuple[int, int]) -> None: 60 """ 61 Set the dimensions (width, height) of the box. 62 """ 63 try: 64 self.width, self.height = value 65 except: 66 logger.warning("Unable to set KBox dimensions: {}", value) 67 68 @property 69 def coords(self) -> tuple[int, int, int, int]: 70 """ 71 Returns the complete coordinates (x, y, width, height) of the box. 72 """ 73 return self.x, self.y, self.width, self.height 74 75 @coords.setter 76 def coords(self, value: tuple[int, int, int, int]) -> None: 77 """ 78 Set the complete coordinates (x, y, width, height) of the box. 79 """ 80 try: 81 self.x, self.y, self.width, self.height = value 82 except: 83 logger.warning("Unable to set KBox coords: {}", value) 84 85 @property 86 def left(self) -> int: 87 """ 88 Returns the x-coordinate of the left edge of the box. 89 """ 90 return self.x 91 92 @property 93 def right(self) -> int: 94 """ 95 Returns the x-coordinate of the right edge of the box. 96 """ 97 return self.x + self.width 98 99 @property 100 def top(self) -> int: 101 """ 102 Returns the y-coordinate of the top edge of the box. 103 """ 104 return self.y + self.height 105 106 @property 107 def bottom(self) -> int: 108 """ 109 Returns the y-coordinate of the bottom edge of the box. 110 """ 111 return self.y 112 113 def xray(self) -> "KBox": 114 """ 115 Visualize the box using `lib.layout.xray` function. 116 """ 117 layout.xray(self.coords) 118 return self 119 120 def move(self, x=0, y=0, mode: layout.UnitMode = "mm") -> "KBox": 121 """ 122 Move the box by the specified amounts in x and y directions. 123 124 Args: 125 x: Amount to move in the x direction. Defaults to 0. 126 y: Amount to move in the y direction. Defaults to 0. 127 mode: The unit mode ("mm", "pt", etc.). Defaults to "mm". 128 """ 129 self.coords = layout.move(self.coords, x=x, y=y, mode=mode) 130 return self 131 132 def grow(self, margin: tuple[int], mode: layout.UnitMode = "mm") -> "KBox": 133 """ 134 Grow the box by adding margins on all sides. 135 136 Args: 137 margin: A tuple of (left, bottom, right, top) margins to add. 138 mode: The unit mode ("mm", "pt", etc.). Defaults to "mm". 139 """ 140 self.coords = layout.grow(self.coords, margin=margin, mode=mode) 141 return self 142 143 def shrink(self, margin: tuple[int], mode: layout.UnitMode = "mm") -> "KBox": 144 """ 145 Shrink the box by adding internal margins on all sides. 146 147 Args: 148 margin: A tuple of (left, bottom, right, top) margins to subtract. 149 mode: The unit mode ("mm", "pt", etc.). Defaults to "mm". 150 """ 151 self.coords = layout.shrink(self.coords, margin=margin, mode=mode) 152 return self 153 154 def shrinkWidth( 155 self, 156 amount: int, 157 origin: Literal["left", "right"] = "left", 158 mode: layout.UnitMode = "relative", 159 ) -> "KBox": 160 """ 161 Shrink the width of the box by a specified amount. 162 163 Args: 164 amount: The amount to shrink the width by. 165 origin: The side from which to shrink. Defaults to "left". 166 mode: The unit mode ("relative", "mm", "pt", etc.). Defaults to "relative". 167 """ 168 self.coords = layout.shrinkWidth( 169 self.coords, amount=amount, origin=origin, mode=mode 170 ) 171 return self 172 173 def shrinkHeight( 174 self, 175 amount: int, 176 origin: Literal["top", "bottom"] = "top", 177 mode: layout.UnitMode = "relative", 178 ) -> "KBox": 179 """ 180 Shrink the height of the box by a specified amount. 181 182 Args: 183 amount: The amount to shrink the height by. 184 origin: The side from which to shrink. Defaults to "top". 185 mode: The unit mode ("relative", "mm", "pt", etc.). Defaults to "relative". 186 """ 187 self.coords = layout.shrinkHeight( 188 self.coords, amount=amount, origin=origin, mode=mode 189 ) 190 return self 191 192 def split( 193 self, 194 formula: str = "1/1", 195 gap: int = 0, 196 mode: layout.LayoutDirection = "columns", 197 ) -> list["KBox"]: 198 """Split into child boxes by specified ratio. See `layout.split`.""" 199 return map(KBox, layout.split(self.coords, formula, gap, mode)) 200 201 def alignInside( 202 self, 203 container: Union["KBox", tuple], 204 position: tuple[layout.AlignX, layout.AlignY] = ("center", "center"), 205 mode: layout.AlignMode = "visual", 206 ) -> "KBox": 207 """ 208 Align this box inside a container box. 209 210 Args: 211 container: The container `KBox` or `tuple` of coordinates. 212 position: The alignment position (x, y). Defaults to ("center", "center"). 213 mode: The alignment mode. Defaults to "visual". See `lib.layout.AlignMode`. 214 """ 215 self.coords = layout.align( 216 container.coords if isinstance(container, KBox) else container, 217 self.coords, 218 position=position, 219 mode=mode, 220 ) 221 return self 222 223 def addCropMarks( 224 self, 225 edges: list[layout.BoxEdge] = ["top", "right", "bottom", "left"], 226 length: float = 1.5, 227 offset: float = 0.5, 228 ) -> "KBox": 229 """ 230 Add crop marks to the box. 231 232 Args: 233 edges: The edges to add crop marks to. Defaults to all four edges. 234 length: The length of crop marks in mm. Defaults to 1.5. 235 offset: The offset of crop marks in mm. Defaults to 0.5. 236 """ 237 length, offset = layout.mm(length), layout.mm(offset) 238 239 def _setLineAttrs(): 240 drawBot.fill(None) 241 drawBot.cmykStroke(*color.CMYK(k=100).values) 242 drawBot.strokeWidth(0.5) 243 244 def _drawVertical(x: int): 245 drawBot.line((x, self.bottom - offset - length), (x, self.bottom - offset)) 246 drawBot.line((x, self.top + offset), (x, self.top + offset + length)) 247 248 def _drawHorizontal(y: int): 249 drawBot.line((self.left - offset - length, y), (self.left - offset, y)) 250 drawBot.line((self.right + offset, y), (self.right + offset + length, y)) 251 252 with drawBot.savedState(): 253 _setLineAttrs() 254 255 for edge in helpers.coerceList(edges): 256 func = _drawHorizontal if edge in ["top", "bottom"] else _drawVertical 257 coordinate: int = self.__getattribute__(edge) # self.top => 123 258 func(coordinate) 259 260 return self
9class KBox: 10 "A layout primitive with coordinates, dimensions and spatial utilities." 11 12 def __init__(self, coords: tuple) -> None: 13 """ 14 Initialize a KBox with given coordinates. 15 16 See `lib.layout.parsePageSize` for possible coordinate types. 17 18 Args: 19 coords: A tuple of (x, y, width, height) coordinates. 20 21 Example: 22 ```python 23 # Create a new box with coordinates 24 box = KBox((10, 10, 100, 50)) # x, y, width, height 25 26 # Move the box 27 box.move(x=20, y=10) 28 29 # Grow the box by adding margin 30 box.grow((5, 5, 5, 5)) # left, bottom, right, top margins 31 ``` 32 """ 33 self.x, self.y, self.width, self.height = layout.toCoords(coords) 34 35 @property 36 def position(self) -> tuple[int, int]: 37 """ 38 Returns the x and y coordinates of the bottom-left corner. 39 """ 40 return self.x, self.y 41 42 @position.setter 43 def position(self, value: tuple[int, int]) -> None: 44 """ 45 Set the position (x, y) of the box. 46 """ 47 try: 48 self.x, self.y = value 49 except: 50 logger.warning("Unable to set KBox position: {}", value) 51 52 @property 53 def dimensions(self) -> tuple[int, int]: 54 """ 55 Returns the dimensions (width, height) of the box. 56 """ 57 return self.width, self.height 58 59 @dimensions.setter 60 def dimensions(self, value: tuple[int, int]) -> None: 61 """ 62 Set the dimensions (width, height) of the box. 63 """ 64 try: 65 self.width, self.height = value 66 except: 67 logger.warning("Unable to set KBox dimensions: {}", value) 68 69 @property 70 def coords(self) -> tuple[int, int, int, int]: 71 """ 72 Returns the complete coordinates (x, y, width, height) of the box. 73 """ 74 return self.x, self.y, self.width, self.height 75 76 @coords.setter 77 def coords(self, value: tuple[int, int, int, int]) -> None: 78 """ 79 Set the complete coordinates (x, y, width, height) of the box. 80 """ 81 try: 82 self.x, self.y, self.width, self.height = value 83 except: 84 logger.warning("Unable to set KBox coords: {}", value) 85 86 @property 87 def left(self) -> int: 88 """ 89 Returns the x-coordinate of the left edge of the box. 90 """ 91 return self.x 92 93 @property 94 def right(self) -> int: 95 """ 96 Returns the x-coordinate of the right edge of the box. 97 """ 98 return self.x + self.width 99 100 @property 101 def top(self) -> int: 102 """ 103 Returns the y-coordinate of the top edge of the box. 104 """ 105 return self.y + self.height 106 107 @property 108 def bottom(self) -> int: 109 """ 110 Returns the y-coordinate of the bottom edge of the box. 111 """ 112 return self.y 113 114 def xray(self) -> "KBox": 115 """ 116 Visualize the box using `lib.layout.xray` function. 117 """ 118 layout.xray(self.coords) 119 return self 120 121 def move(self, x=0, y=0, mode: layout.UnitMode = "mm") -> "KBox": 122 """ 123 Move the box by the specified amounts in x and y directions. 124 125 Args: 126 x: Amount to move in the x direction. Defaults to 0. 127 y: Amount to move in the y direction. Defaults to 0. 128 mode: The unit mode ("mm", "pt", etc.). Defaults to "mm". 129 """ 130 self.coords = layout.move(self.coords, x=x, y=y, mode=mode) 131 return self 132 133 def grow(self, margin: tuple[int], mode: layout.UnitMode = "mm") -> "KBox": 134 """ 135 Grow the box by adding margins on all sides. 136 137 Args: 138 margin: A tuple of (left, bottom, right, top) margins to add. 139 mode: The unit mode ("mm", "pt", etc.). Defaults to "mm". 140 """ 141 self.coords = layout.grow(self.coords, margin=margin, mode=mode) 142 return self 143 144 def shrink(self, margin: tuple[int], mode: layout.UnitMode = "mm") -> "KBox": 145 """ 146 Shrink the box by adding internal margins on all sides. 147 148 Args: 149 margin: A tuple of (left, bottom, right, top) margins to subtract. 150 mode: The unit mode ("mm", "pt", etc.). Defaults to "mm". 151 """ 152 self.coords = layout.shrink(self.coords, margin=margin, mode=mode) 153 return self 154 155 def shrinkWidth( 156 self, 157 amount: int, 158 origin: Literal["left", "right"] = "left", 159 mode: layout.UnitMode = "relative", 160 ) -> "KBox": 161 """ 162 Shrink the width of the box by a specified amount. 163 164 Args: 165 amount: The amount to shrink the width by. 166 origin: The side from which to shrink. Defaults to "left". 167 mode: The unit mode ("relative", "mm", "pt", etc.). Defaults to "relative". 168 """ 169 self.coords = layout.shrinkWidth( 170 self.coords, amount=amount, origin=origin, mode=mode 171 ) 172 return self 173 174 def shrinkHeight( 175 self, 176 amount: int, 177 origin: Literal["top", "bottom"] = "top", 178 mode: layout.UnitMode = "relative", 179 ) -> "KBox": 180 """ 181 Shrink the height of the box by a specified amount. 182 183 Args: 184 amount: The amount to shrink the height by. 185 origin: The side from which to shrink. Defaults to "top". 186 mode: The unit mode ("relative", "mm", "pt", etc.). Defaults to "relative". 187 """ 188 self.coords = layout.shrinkHeight( 189 self.coords, amount=amount, origin=origin, mode=mode 190 ) 191 return self 192 193 def split( 194 self, 195 formula: str = "1/1", 196 gap: int = 0, 197 mode: layout.LayoutDirection = "columns", 198 ) -> list["KBox"]: 199 """Split into child boxes by specified ratio. See `layout.split`.""" 200 return map(KBox, layout.split(self.coords, formula, gap, mode)) 201 202 def alignInside( 203 self, 204 container: Union["KBox", tuple], 205 position: tuple[layout.AlignX, layout.AlignY] = ("center", "center"), 206 mode: layout.AlignMode = "visual", 207 ) -> "KBox": 208 """ 209 Align this box inside a container box. 210 211 Args: 212 container: The container `KBox` or `tuple` of coordinates. 213 position: The alignment position (x, y). Defaults to ("center", "center"). 214 mode: The alignment mode. Defaults to "visual". See `lib.layout.AlignMode`. 215 """ 216 self.coords = layout.align( 217 container.coords if isinstance(container, KBox) else container, 218 self.coords, 219 position=position, 220 mode=mode, 221 ) 222 return self 223 224 def addCropMarks( 225 self, 226 edges: list[layout.BoxEdge] = ["top", "right", "bottom", "left"], 227 length: float = 1.5, 228 offset: float = 0.5, 229 ) -> "KBox": 230 """ 231 Add crop marks to the box. 232 233 Args: 234 edges: The edges to add crop marks to. Defaults to all four edges. 235 length: The length of crop marks in mm. Defaults to 1.5. 236 offset: The offset of crop marks in mm. Defaults to 0.5. 237 """ 238 length, offset = layout.mm(length), layout.mm(offset) 239 240 def _setLineAttrs(): 241 drawBot.fill(None) 242 drawBot.cmykStroke(*color.CMYK(k=100).values) 243 drawBot.strokeWidth(0.5) 244 245 def _drawVertical(x: int): 246 drawBot.line((x, self.bottom - offset - length), (x, self.bottom - offset)) 247 drawBot.line((x, self.top + offset), (x, self.top + offset + length)) 248 249 def _drawHorizontal(y: int): 250 drawBot.line((self.left - offset - length, y), (self.left - offset, y)) 251 drawBot.line((self.right + offset, y), (self.right + offset + length, y)) 252 253 with drawBot.savedState(): 254 _setLineAttrs() 255 256 for edge in helpers.coerceList(edges): 257 func = _drawHorizontal if edge in ["top", "bottom"] else _drawVertical 258 coordinate: int = self.__getattribute__(edge) # self.top => 123 259 func(coordinate) 260 261 return self
A layout primitive with coordinates, dimensions and spatial utilities.
12 def __init__(self, coords: tuple) -> None: 13 """ 14 Initialize a KBox with given coordinates. 15 16 See `lib.layout.parsePageSize` for possible coordinate types. 17 18 Args: 19 coords: A tuple of (x, y, width, height) coordinates. 20 21 Example: 22 ```python 23 # Create a new box with coordinates 24 box = KBox((10, 10, 100, 50)) # x, y, width, height 25 26 # Move the box 27 box.move(x=20, y=10) 28 29 # Grow the box by adding margin 30 box.grow((5, 5, 5, 5)) # left, bottom, right, top margins 31 ``` 32 """ 33 self.x, self.y, self.width, self.height = layout.toCoords(coords)
Initialize a KBox with given coordinates.
See lib.layout.parsePageSize for possible coordinate types.
Arguments:
- coords: A tuple of (x, y, width, height) coordinates.
Example:
# Create a new box with coordinates
box = KBox((10, 10, 100, 50)) # x, y, width, height
# Move the box
box.move(x=20, y=10)
# Grow the box by adding margin
box.grow((5, 5, 5, 5)) # left, bottom, right, top margins
35 @property 36 def position(self) -> tuple[int, int]: 37 """ 38 Returns the x and y coordinates of the bottom-left corner. 39 """ 40 return self.x, self.y
Returns the x and y coordinates of the bottom-left corner.
52 @property 53 def dimensions(self) -> tuple[int, int]: 54 """ 55 Returns the dimensions (width, height) of the box. 56 """ 57 return self.width, self.height
Returns the dimensions (width, height) of the box.
69 @property 70 def coords(self) -> tuple[int, int, int, int]: 71 """ 72 Returns the complete coordinates (x, y, width, height) of the box. 73 """ 74 return self.x, self.y, self.width, self.height
Returns the complete coordinates (x, y, width, height) of the box.
86 @property 87 def left(self) -> int: 88 """ 89 Returns the x-coordinate of the left edge of the box. 90 """ 91 return self.x
Returns the x-coordinate of the left edge of the box.
93 @property 94 def right(self) -> int: 95 """ 96 Returns the x-coordinate of the right edge of the box. 97 """ 98 return self.x + self.width
Returns the x-coordinate of the right edge of the box.
100 @property 101 def top(self) -> int: 102 """ 103 Returns the y-coordinate of the top edge of the box. 104 """ 105 return self.y + self.height
Returns the y-coordinate of the top edge of the box.
107 @property 108 def bottom(self) -> int: 109 """ 110 Returns the y-coordinate of the bottom edge of the box. 111 """ 112 return self.y
Returns the y-coordinate of the bottom edge of the box.
114 def xray(self) -> "KBox": 115 """ 116 Visualize the box using `lib.layout.xray` function. 117 """ 118 layout.xray(self.coords) 119 return self
Visualize the box using lib.layout.xray function.
121 def move(self, x=0, y=0, mode: layout.UnitMode = "mm") -> "KBox": 122 """ 123 Move the box by the specified amounts in x and y directions. 124 125 Args: 126 x: Amount to move in the x direction. Defaults to 0. 127 y: Amount to move in the y direction. Defaults to 0. 128 mode: The unit mode ("mm", "pt", etc.). Defaults to "mm". 129 """ 130 self.coords = layout.move(self.coords, x=x, y=y, mode=mode) 131 return self
Move the box by the specified amounts in x and y directions.
Arguments:
- x: Amount to move in the x direction. Defaults to 0.
- y: Amount to move in the y direction. Defaults to 0.
- mode: The unit mode ("mm", "pt", etc.). Defaults to "mm".
133 def grow(self, margin: tuple[int], mode: layout.UnitMode = "mm") -> "KBox": 134 """ 135 Grow the box by adding margins on all sides. 136 137 Args: 138 margin: A tuple of (left, bottom, right, top) margins to add. 139 mode: The unit mode ("mm", "pt", etc.). Defaults to "mm". 140 """ 141 self.coords = layout.grow(self.coords, margin=margin, mode=mode) 142 return self
Grow the box by adding margins on all sides.
Arguments:
- margin: A tuple of (left, bottom, right, top) margins to add.
- mode: The unit mode ("mm", "pt", etc.). Defaults to "mm".
144 def shrink(self, margin: tuple[int], mode: layout.UnitMode = "mm") -> "KBox": 145 """ 146 Shrink the box by adding internal margins on all sides. 147 148 Args: 149 margin: A tuple of (left, bottom, right, top) margins to subtract. 150 mode: The unit mode ("mm", "pt", etc.). Defaults to "mm". 151 """ 152 self.coords = layout.shrink(self.coords, margin=margin, mode=mode) 153 return self
Shrink the box by adding internal margins on all sides.
Arguments:
- margin: A tuple of (left, bottom, right, top) margins to subtract.
- mode: The unit mode ("mm", "pt", etc.). Defaults to "mm".
155 def shrinkWidth( 156 self, 157 amount: int, 158 origin: Literal["left", "right"] = "left", 159 mode: layout.UnitMode = "relative", 160 ) -> "KBox": 161 """ 162 Shrink the width of the box by a specified amount. 163 164 Args: 165 amount: The amount to shrink the width by. 166 origin: The side from which to shrink. Defaults to "left". 167 mode: The unit mode ("relative", "mm", "pt", etc.). Defaults to "relative". 168 """ 169 self.coords = layout.shrinkWidth( 170 self.coords, amount=amount, origin=origin, mode=mode 171 ) 172 return self
Shrink the width of the box by a specified amount.
Arguments:
- amount: The amount to shrink the width by.
- origin: The side from which to shrink. Defaults to "left".
- mode: The unit mode ("relative", "mm", "pt", etc.). Defaults to "relative".
174 def shrinkHeight( 175 self, 176 amount: int, 177 origin: Literal["top", "bottom"] = "top", 178 mode: layout.UnitMode = "relative", 179 ) -> "KBox": 180 """ 181 Shrink the height of the box by a specified amount. 182 183 Args: 184 amount: The amount to shrink the height by. 185 origin: The side from which to shrink. Defaults to "top". 186 mode: The unit mode ("relative", "mm", "pt", etc.). Defaults to "relative". 187 """ 188 self.coords = layout.shrinkHeight( 189 self.coords, amount=amount, origin=origin, mode=mode 190 ) 191 return self
Shrink the height of the box by a specified amount.
Arguments:
- amount: The amount to shrink the height by.
- origin: The side from which to shrink. Defaults to "top".
- mode: The unit mode ("relative", "mm", "pt", etc.). Defaults to "relative".
193 def split( 194 self, 195 formula: str = "1/1", 196 gap: int = 0, 197 mode: layout.LayoutDirection = "columns", 198 ) -> list["KBox"]: 199 """Split into child boxes by specified ratio. See `layout.split`.""" 200 return map(KBox, layout.split(self.coords, formula, gap, mode))
Split into child boxes by specified ratio. See layout.split.
202 def alignInside( 203 self, 204 container: Union["KBox", tuple], 205 position: tuple[layout.AlignX, layout.AlignY] = ("center", "center"), 206 mode: layout.AlignMode = "visual", 207 ) -> "KBox": 208 """ 209 Align this box inside a container box. 210 211 Args: 212 container: The container `KBox` or `tuple` of coordinates. 213 position: The alignment position (x, y). Defaults to ("center", "center"). 214 mode: The alignment mode. Defaults to "visual". See `lib.layout.AlignMode`. 215 """ 216 self.coords = layout.align( 217 container.coords if isinstance(container, KBox) else container, 218 self.coords, 219 position=position, 220 mode=mode, 221 ) 222 return self
Align this box inside a container box.
Arguments:
- container: The container
KBoxortupleof coordinates. - position: The alignment position (x, y). Defaults to ("center", "center").
- mode: The alignment mode. Defaults to "visual". See
lib.layout.AlignMode.
224 def addCropMarks( 225 self, 226 edges: list[layout.BoxEdge] = ["top", "right", "bottom", "left"], 227 length: float = 1.5, 228 offset: float = 0.5, 229 ) -> "KBox": 230 """ 231 Add crop marks to the box. 232 233 Args: 234 edges: The edges to add crop marks to. Defaults to all four edges. 235 length: The length of crop marks in mm. Defaults to 1.5. 236 offset: The offset of crop marks in mm. Defaults to 0.5. 237 """ 238 length, offset = layout.mm(length), layout.mm(offset) 239 240 def _setLineAttrs(): 241 drawBot.fill(None) 242 drawBot.cmykStroke(*color.CMYK(k=100).values) 243 drawBot.strokeWidth(0.5) 244 245 def _drawVertical(x: int): 246 drawBot.line((x, self.bottom - offset - length), (x, self.bottom - offset)) 247 drawBot.line((x, self.top + offset), (x, self.top + offset + length)) 248 249 def _drawHorizontal(y: int): 250 drawBot.line((self.left - offset - length, y), (self.left - offset, y)) 251 drawBot.line((self.right + offset, y), (self.right + offset + length, y)) 252 253 with drawBot.savedState(): 254 _setLineAttrs() 255 256 for edge in helpers.coerceList(edges): 257 func = _drawHorizontal if edge in ["top", "bottom"] else _drawVertical 258 coordinate: int = self.__getattribute__(edge) # self.top => 123 259 func(coordinate) 260 261 return self
Add crop marks to the box.
Arguments:
- edges: The edges to add crop marks to. Defaults to all four edges.
- length: The length of crop marks in mm. Defaults to 1.5.
- offset: The offset of crop marks in mm. Defaults to 0.5.