feat: add draw.rotated_rectangle primitive#184
Merged
Conversation
859acd7 to
f9c2853
Compare
f9c2853 to
3828c8d
Compare
Match the rectangle and rounded_rectangle signatures, which already accept tuple[float, float] | NDArray[np.floating].
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
imgviz.draw.rotated_rectangle(image, center, size, angle, fill=None, outline=None, width=1)and its in-place pairrotated_rectangle_, for oriented bounding boxes.centeris(cy, cx),sizeis(height, width)before rotation,angleis in degrees (positive rotates clockwise, since the image y-axis points down).draw.polygon_, so fill/outline/width semantics and validation live in one place. Callsrequire_fill_or_outlineat its own entry, matching the other_primitives.widthdefaults to1(not0likerectangle/rounded_rectangle): it wrapspolygon_, where PIL treatswidth=0as a no-op outline, so1is the meaningful default here.Test plan
tests/unit/draw/_rotated_rectangle_test.py— axis-aligned atangle=0, extent-swap atangle=90, clockwise rotation-direction check, area preservation under rotation, outline-only path, fill+outline together, the fill/outline guard, and in-place mutationuv run pytest tests/unit/draw/uv run ruff check/uv run ruff format --check/uv run ty checkclean on touched filesCloses #153