Creates a rectangle polygon. >>> e = Polygon() >>> e.rect(10, 10, 220, 330) >>> e.points [(10pt, 10pt), (10pt, 340pt), (230pt, 340pt), (230pt, 10pt)] >>> e.block (220pt, 330pt)
(self, x, y, w, h)
| 168 | box = property(_get_box) |
| 169 | |
| 170 | def rect(self, x, y, w, h): |
| 171 | """Creates a rectangle polygon. |
| 172 | |
| 173 | >>> e = Polygon() |
| 174 | >>> e.rect(10, 10, 220, 330) |
| 175 | >>> e.points |
| 176 | [(10pt, 10pt), (10pt, 340pt), (230pt, 340pt), (230pt, 10pt)] |
| 177 | >>> e.block |
| 178 | (220pt, 330pt) |
| 179 | """ |
| 180 | self.points = [] |
| 181 | # Relative offset to (self.x, self.y). |
| 182 | self.append((x, y)) |
| 183 | self.append((x, y+h)) |
| 184 | self.append((x+w, y+h)) |
| 185 | self.append((x+w, y)) |
| 186 | self.closePath = True |
| 187 | |
| 188 | def _get_block(self): |
| 189 | """Answers the bounding box of the contained points, |
no test coverage detected