Convert to Stroke instance based on width criterion. Args: max_border_width (float): Stroke width must less than this value. Returns: Stroke: Stroke instance. .. note:: A Fill from shape point of view may be a Stroke from content
(self, max_border_width:float)
| 271 | ''' |
| 272 | |
| 273 | def to_stroke(self, max_border_width:float): |
| 274 | '''Convert to Stroke instance based on width criterion. |
| 275 | |
| 276 | Args: |
| 277 | max_border_width (float): Stroke width must less than this value. |
| 278 | |
| 279 | Returns: |
| 280 | Stroke: Stroke instance. |
| 281 | |
| 282 | .. note:: |
| 283 | A Fill from shape point of view may be a Stroke from content point of view. |
| 284 | The criterion here is whether the width is smaller than defined ``max_border_width``. |
| 285 | ''' |
| 286 | w = min(self.bbox.width, self.bbox.height) |
| 287 | |
| 288 | # not a stroke if exceed max border width |
| 289 | if w > max_border_width: |
| 290 | return None |
| 291 | else: |
| 292 | return Stroke({'width': w, 'color': self.color}).update_bbox(self.bbox) |
| 293 | |
| 294 | |
| 295 | @property |
no test coverage detected