This class describes the coordinate system of an axial rectangle box using two points as indicated below:: (x_1, y_1) ---- | | | | | | ---- (x_2, y_2) Args: x_1 (:obj:`numeric`):
| 465 | |
| 466 | @inherit_docstrings |
| 467 | class Rectangle(BaseCoordElement): |
| 468 | """ |
| 469 | This class describes the coordinate system of an axial rectangle box using two points as indicated below:: |
| 470 | |
| 471 | (x_1, y_1) ---- |
| 472 | | | |
| 473 | | | |
| 474 | | | |
| 475 | ---- (x_2, y_2) |
| 476 | |
| 477 | Args: |
| 478 | x_1 (:obj:`numeric`): |
| 479 | x coordinate on the horizontal axis of the upper left corner of the rectangle. |
| 480 | y_1 (:obj:`numeric`): |
| 481 | y coordinate on the vertical axis of the upper left corner of the rectangle. |
| 482 | x_2 (:obj:`numeric`): |
| 483 | x coordinate on the horizontal axis of the lower right corner of the rectangle. |
| 484 | y_2 (:obj:`numeric`): |
| 485 | y coordinate on the vertical axis of the lower right corner of the rectangle. |
| 486 | """ |
| 487 | |
| 488 | _name = "rectangle" |
| 489 | _features = ["x_1", "y_1", "x_2", "y_2"] |
| 490 | |
| 491 | def __init__(self, x_1, y_1, x_2, y_2): |
| 492 | |
| 493 | self.x_1 = x_1 |
| 494 | self.y_1 = y_1 |
| 495 | self.x_2 = x_2 |
| 496 | self.y_2 = y_2 |
| 497 | |
| 498 | @property |
| 499 | def height(self): |
| 500 | """ |
| 501 | Calculate the height of the rectangle. |
| 502 | |
| 503 | Returns: |
| 504 | :obj:`numeric`: Output the numeric value of the height. |
| 505 | """ |
| 506 | |
| 507 | return self.y_2 - self.y_1 |
| 508 | |
| 509 | @property |
| 510 | def width(self): |
| 511 | """ |
| 512 | Calculate the width of the rectangle. |
| 513 | |
| 514 | Returns: |
| 515 | :obj:`numeric`: Output the numeric value of the width. |
| 516 | """ |
| 517 | |
| 518 | return self.x_2 - self.x_1 |
| 519 | |
| 520 | @property |
| 521 | def coordinates(self): |
| 522 | """ |
| 523 | Return the coordinates of the two points that define the rectangle. |
| 524 |
no outgoing calls