Skip to content

Add rotated rectangle draw and fill methods - #489

Closed
BillMerryman wants to merge 17 commits into
adafruit:masterfrom
BillMerryman:Add_rotated_rectangle_methods
Closed

Add rotated rectangle draw and fill methods#489
BillMerryman wants to merge 17 commits into
adafruit:masterfrom
BillMerryman:Add_rotated_rectangle_methods

Conversation

@BillMerryman

Copy link
Copy Markdown
Contributor

These methods implement the ability to draw and fill rectangles rotated by a given angle in degrees.

@BillMerryman

Copy link
Copy Markdown
Contributor Author

@ladyada for review.

@ladyada
ladyada requested a review from Copilot November 7, 2025 18:29
@ladyada

ladyada commented Nov 7, 2025

Copy link
Copy Markdown
Member

thanks! please also add some example to test this code, maybe displaying rotating rectangles - so we can easily verify functionality on platforms/displays :)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for drawing rotated rectangles to the Adafruit GFX library. The implementation includes functions to draw outlined rotated rectangles, filled rotated rectangles, and a helper function to rotate points around an origin.

  • Adds drawRotatedRectangle and fillRotatedRectangle methods for rendering rotated rectangles
  • Implements a rotatePoint helper function for coordinate rotation
  • Uses trigonometric functions to rotate rectangle corners and existing drawing primitives (lines and triangles) for rendering

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
Adafruit_GFX.h Adds method declarations for the three new rotated rectangle functions
Adafruit_GFX.cpp Implements the rotated rectangle drawing logic with supporting rotation math

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Adafruit_GFX.cpp Outdated
Comment thread Adafruit_GFX.cpp Outdated
Comment thread Adafruit_GFX.cpp Outdated
@BillMerryman

BillMerryman commented Nov 7, 2025

Copy link
Copy Markdown
Contributor Author

Wasn't sure where you wanted an example, so I placed one in the 'examples' directory in a directory called 'RotatedRectangleTest'. Commented the display-specific code.

@BillMerryman

Copy link
Copy Markdown
Contributor Author

@ladyada for review.

@BillMerryman BillMerryman closed this by deleting the head repository Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants