Skip to content

Commit c1b19b1

Browse files
committed
Improve relcenter docs
1 parent a47a9f9 commit c1b19b1

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

docs/reST/ref/rect.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
top, left, bottom, right
4848
topleft, bottomleft, topright, bottomright
4949
midtop, midleft, midbottom, midright
50-
center, relcenter, centerx, centery
51-
size, width, height
50+
center, centerx, centery
51+
size, width, height, relcenter
5252
w,h
5353

5454
All of these attributes can be assigned to:
@@ -58,7 +58,7 @@
5858
rect1.right = 10
5959
rect2.center = (20,30)
6060

61-
Assigning to size, width or height changes the dimensions of the rectangle;
61+
Assigning to size, width, height, or relcenter changes the dimensions of the rectangle;
6262
all other assignments move the rectangle without resizing it. Notice that
6363
some attributes are integers and others are pairs of integers.
6464

@@ -94,22 +94,22 @@
9494
overridden if any extra attributes need to be copied.
9595

9696
.. versionadded:: 2.5.6
97-
``relcenter`` added to Rect / FRect. This will return you a ``Point`` of
98-
the center relative to the topleft of the Rect. Setting a ``Point`` to it will
99-
modify the size of the rect to 2 times the ``Point`` used. Below you can find a
100-
code example of how it should work :
97+
``relcenter`` added to Rect / FRect. This will return a tuple containing half
98+
the Rect's size; the center relative to the topleft of the Rect.
99+
Setting it to a ``Point`` will modify the size of the rect to 2 times
100+
the ``Point`` given. Below you can find a code example of how it should work:
101101

102102
.. code-block:: python
103103
104-
> my_rect = pygame.Rect(0, 0, 2, 2)
105-
> my_rect.relcenter
106-
> (1, 1)
107-
> my_rect.relcenter = (128, 128)
108-
> my_rect.relcenter, my_rect.size
109-
> ((128, 128), (256, 256))
104+
>>> my_rect = pygame.Rect(0, 0, 2, 2)
105+
>>> my_rect.relcenter
106+
(1, 1)
107+
>>> my_rect.relcenter = (128, 128)
108+
>>> my_rect.size
109+
(256, 256)
110110
111-
Beware of non integer relative centers ! Using a Rect instead of FRect will round down
112-
the values of the returned ``Point``.
111+
Beware of non-integer relative centers! For Rects (but not FRects), ``relcenter``
112+
will truncate the numbers in the returned tuple.
113113

114114

115115
.. method:: copy

0 commit comments

Comments
 (0)