Skip to content

Commit

Permalink
Example ruff fix + local access shorthand
Browse files Browse the repository at this point in the history
  • Loading branch information
pushfoo committed May 22, 2024
1 parent 77085d3 commit 4a7b371
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions arcade/types/rect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4a7b371

Please sign in to comment.