From 4a7b371e600a0ff847a867679e14750cb6f2c5b9 Mon Sep 17 00:00:00 2001 From: pushfoo <36696816+pushfoo@users.noreply.github.com> Date: Tue, 21 May 2024 22:41:53 -0500 Subject: [PATCH] Example ruff fix + local access shorthand --- arcade/types/rect.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/arcade/types/rect.py b/arcade/types/rect.py index cfdfcfed7..3aba9557c 100644 --- a/arcade/types/rect.py +++ b/arcade/types/rect.py @@ -258,9 +258,20 @@ def clamp_height(self, min_height: Optional[AsFloat] = None, max_height: Optiona def clamp_width(self, min_width: Optional[AsFloat] = None, max_width: Optional[AsFloat] = None, anchor: Vec2 = AnchorPoint.CENTER) -> Rect: - """ - Return a :py:class:`~arcade.types.rect.Rect` that is has a width between `min_width` and `max_width`, positioned at - the current position and anchored to a point (default center.) + """Return a :py:class:`.Rect` constrained to the passed dimension. + + It will be created as follows: + + * Its :py:attr:`.width` will be between any provided ``min_width`` + and ``max_width`` + * It will be positioned at the current position using the passed + ``anchor`` + + :param min_width: An optional minimum width. + :param max_width: An optional maximum width. + :param anchor: A :py:class:`~pyglet.math.Vec2` of the fractional + percentage of the rectangle's total :py:attr:`.size` along + both axes. It defaults to the center. """ width = min(max_width or float("inf"), max(min_width or 0.0, self.width)) return self.resize(width, self.height, anchor)