>>> pn = Polygon(x=33, y=44) >>> pn.rect(10, 10, 200, 360) >>> pn.x, pn.left (33pt, 33pt) >>> # Element position + point positions. >>> pn.box (43pt, 54pt, 200pt, 360pt) >>> pn._set_scale(0.6) >>> pn.x, pn.left (33pt, 3
(self, sx, sy=None)
| 111 | self.points = points |
| 112 | |
| 113 | def _set_scale(self, sx, sy=None): |
| 114 | """ |
| 115 | >>> pn = Polygon(x=33, y=44) |
| 116 | >>> pn.rect(10, 10, 200, 360) |
| 117 | >>> pn.x, pn.left |
| 118 | (33pt, 33pt) |
| 119 | >>> # Element position + point positions. |
| 120 | >>> pn.box |
| 121 | (43pt, 54pt, 200pt, 360pt) |
| 122 | >>> pn._set_scale(0.6) |
| 123 | >>> pn.x, pn.left |
| 124 | (33pt, 33pt) |
| 125 | >>> pn.box |
| 126 | (39pt, 50pt, 120pt, 216pt) |
| 127 | """ |
| 128 | points = [] |
| 129 | |
| 130 | if sy is None: |
| 131 | sy = sx |
| 132 | |
| 133 | for point in self.points: |
| 134 | # Scale relative to (self.x, self.y) origin. |
| 135 | px = point[0] * sx |
| 136 | py = point[1] * sy |
| 137 | points.append((px, py)) |
| 138 | |
| 139 | self.points = points |
| 140 | |
| 141 | def _get_box(self): |
| 142 | """ Get the (x, y, w, h) box of all points. |