Update stroke bbox (related to real page CS). * Update start/end points if ``rect.area==0``. * Ppdate bbox directly if ``rect.area!=0``. Args: rect (fitz.Rect, tuple): ``(x0, y0, x1, y1)`` like data. Returns: Stroke: self
(self, rect)
| 178 | |
| 179 | |
| 180 | def update_bbox(self, rect): |
| 181 | '''Update stroke bbox (related to real page CS). |
| 182 | |
| 183 | * Update start/end points if ``rect.area==0``. |
| 184 | * Ppdate bbox directly if ``rect.area!=0``. |
| 185 | |
| 186 | Args: |
| 187 | rect (fitz.Rect, tuple): ``(x0, y0, x1, y1)`` like data. |
| 188 | |
| 189 | Returns: |
| 190 | Stroke: self |
| 191 | ''' |
| 192 | rect = fitz.Rect(rect) |
| 193 | |
| 194 | # an empty area line |
| 195 | if rect.get_area()==0.0: |
| 196 | self._start = fitz.Point(rect[0:2]) |
| 197 | self._end = fitz.Point(rect[2:]) |
| 198 | super().update_bbox(self._to_rect()) |
| 199 | |
| 200 | # a rect |
| 201 | else: |
| 202 | super().update_bbox(rect) |
| 203 | |
| 204 | # horizontal stroke |
| 205 | if rect.width >= rect.height: |
| 206 | y = (rect.y0+rect.y1)/2.0 |
| 207 | self._start = fitz.Point(rect.x0, y) |
| 208 | self._end = fitz.Point(rect.x1, y) |
| 209 | |
| 210 | # vertical stroke |
| 211 | else: |
| 212 | x = (rect.x0+rect.x1)/2.0 |
| 213 | self._start = fitz.Point(x, rect.y0) |
| 214 | self._end = fitz.Point(x, rect.y1) |
| 215 | |
| 216 | return self |
| 217 | |
| 218 | @property |
| 219 | def default_type(self): |
no test coverage detected