|
487 | 487 | .. ## Circle.copy ## |
488 | 488 |
|
489 | 489 | .. ## pygame.Circle ## |
| 490 | +
|
| 491 | +
|
| 492 | +.. class:: Line |
| 493 | + |
| 494 | + | :sl:`pygame object for representing a line` |
| 495 | + | :sg:`Line((ax, ay), (bx, by)) -> Line` |
| 496 | + | :sg:`Line(ax, ay, bx, by) -> Line` |
| 497 | +
|
| 498 | + .. versionadded:: 2.5.2 |
| 499 | + |
| 500 | + The `Line` class provides many useful methods for collision testing, transformation and intersection. |
| 501 | + A `Line` can be created from a combination of two pairs of coordinates that represent the start and end points. |
| 502 | + Lines can also be created from python objects that are already a `Line` (effectively copying the line) or have an attribute named "line". |
| 503 | + |
| 504 | + Specifically, to construct a `Line` you can pass the ax, ay, bx, and by values as separate |
| 505 | + arguments or inside a sequence(list or tuple). |
| 506 | + |
| 507 | + As a special case you can also pass in `pygame.Rect` / `pygame.FRect`, in which case the |
| 508 | + line will be created with (x, y, width, height) as the start and end points. |
| 509 | + |
| 510 | + You can create lines with the same start and end points, but beware that some methods may |
| 511 | + not work as expected or error out. |
| 512 | + |
| 513 | + Functions that require a `Line` argument may also accept these values as Lines: |
| 514 | + |
| 515 | + :: |
| 516 | + |
| 517 | + ((ax, ay), (bx, by)) |
| 518 | + (ax, ay, bx, by) |
| 519 | + (vector2, vector2) |
| 520 | + |
| 521 | + The `Line` class only stores the ax, ay, bx, and by attributes, everything else is calculated |
| 522 | + on the fly based on them. |
| 523 | + |
| 524 | + **Line Attributes** |
| 525 | + |
| 526 | + ---- |
| 527 | + |
| 528 | + .. attribute:: ax |
| 529 | + |
| 530 | + | :sl:`x coordinate of the start point of the line` |
| 531 | + | :sg:`ax -> float` |
| 532 | +
|
| 533 | + The horizontal coordinate of the start point of the line. Reassigning it moves the line. |
| 534 | + |
| 535 | + .. versionadded:: 2.5.2 |
| 536 | + |
| 537 | + .. ## Line.ax ## |
| 538 | +
|
| 539 | + .. attribute:: ay |
| 540 | + |
| 541 | + | :sl:`y coordinate of the start point of the line` |
| 542 | + | :sg:`ay -> float` |
| 543 | +
|
| 544 | + The vertical coordinate of the start point of the line. Reassigning it moves the line. |
| 545 | + |
| 546 | + .. versionadded:: 2.5.2 |
| 547 | + |
| 548 | + .. ## Line.ay ## |
| 549 | +
|
| 550 | + .. attribute:: bx |
| 551 | + |
| 552 | + | :sl:`x coordinate of the end point of the line` |
| 553 | + | :sg:`bx -> float` |
| 554 | +
|
| 555 | + The horizontal coordinate of the end point of the line. Reassigning it moves the line. |
| 556 | + |
| 557 | + .. versionadded:: 2.5.2 |
| 558 | + |
| 559 | + .. ## Line.bx ## |
| 560 | +
|
| 561 | + .. attribute:: by |
| 562 | + |
| 563 | + | :sl:`y coordinate of the end point of the line` |
| 564 | + | :sg:`by -> float` |
| 565 | +
|
| 566 | + The vertical coordinate of the end point of the line. Reassigning it moves the line. |
| 567 | + |
| 568 | + .. versionadded:: 2.5.2 |
| 569 | + |
| 570 | + .. ## Line.by ## |
| 571 | +
|
| 572 | + .. attribute:: a |
| 573 | + |
| 574 | + | :sl:`the first point of the line` |
| 575 | + | :sg:`a -> (float, float)` |
| 576 | +
|
| 577 | + It's a tuple containing the `ax` and `ay` attributes representing the line's first point. |
| 578 | + It can be reassigned to move the `Line`. If reassigned the `ax` and `ay` attributes |
| 579 | + will be changed to produce a `Line` with matching first point position. |
| 580 | + The `bx` and `by` attributes will not be affected. |
| 581 | + |
| 582 | + .. versionadded:: 2.5.2 |
| 583 | + |
| 584 | + .. ## Line.a ## |
| 585 | +
|
| 586 | + .. attribute:: b |
| 587 | + |
| 588 | + | :sl:`the second point of the line` |
| 589 | + | :sg:`b -> (float, float)` |
| 590 | +
|
| 591 | + It's a tuple containing `bx` and `by` attributes representing the line's second point. |
| 592 | + It can be reassigned to move the `Line`. If reassigned the `bx` and `by` attributes |
| 593 | + will be changed to produce a `Line` with matching second point position. |
| 594 | + The `ax` and `ay` attributes will not be affected. |
| 595 | + |
| 596 | + .. versionadded:: 2.5.2 |
| 597 | + |
| 598 | + .. ## Line.b ## |
| 599 | +
|
| 600 | + **Line Methods** |
| 601 | + |
| 602 | + ---- |
| 603 | + |
| 604 | + .. method:: copy |
| 605 | + |
| 606 | + | :sl:`copies the line` |
| 607 | + | :sg:`copy() -> Line` |
| 608 | +
|
| 609 | + Returns a copy of this `Line`. |
| 610 | + |
| 611 | + .. versionadded:: 2.5.2 |
| 612 | + |
| 613 | + .. ## Line.copy ## |
0 commit comments