`BboxTransformTo` is a transformation that linearly transforms points from the unit bounding box to a given `Bbox`.
| 2625 | |
| 2626 | |
| 2627 | class BboxTransformTo(Affine2DBase): |
| 2628 | """ |
| 2629 | `BboxTransformTo` is a transformation that linearly transforms points from |
| 2630 | the unit bounding box to a given `Bbox`. |
| 2631 | """ |
| 2632 | |
| 2633 | is_separable = True |
| 2634 | |
| 2635 | def __init__(self, boxout, **kwargs): |
| 2636 | """ |
| 2637 | Create a new `BboxTransformTo` that linearly transforms |
| 2638 | points from the unit bounding box to *boxout*. |
| 2639 | """ |
| 2640 | _api.check_isinstance(BboxBase, boxout=boxout) |
| 2641 | |
| 2642 | super().__init__(**kwargs) |
| 2643 | self._boxout = boxout |
| 2644 | self.set_children(boxout) |
| 2645 | self._mtx = None |
| 2646 | self._inverted = None |
| 2647 | |
| 2648 | __str__ = _make_str_method("_boxout") |
| 2649 | |
| 2650 | def get_matrix(self): |
| 2651 | # docstring inherited |
| 2652 | if self._invalid: |
| 2653 | outl, outb, outw, outh = self._boxout.bounds |
| 2654 | if DEBUG and (outw == 0 or outh == 0): |
| 2655 | raise ValueError("Transforming to a singular bounding box.") |
| 2656 | self._mtx = np.array([[outw, 0.0, outl], |
| 2657 | [ 0.0, outh, outb], |
| 2658 | [ 0.0, 0.0, 1.0]], |
| 2659 | float) |
| 2660 | self._inverted = None |
| 2661 | self._invalid = 0 |
| 2662 | return self._mtx |
| 2663 | |
| 2664 | |
| 2665 | class BboxTransformFrom(Affine2DBase): |
no test coverage detected
searching dependent graphs…