Repository navigation
all: draw with FillRectangle when the display has it - #23
Open
hervenicol wants to merge 1 commit into
Open
hervenicol wants to merge 1 commit into
hervenicol wants to merge 1 commit into
Conversation
Most display drivers have a FillRectangle method. tinydraw used only SetPixel, so it drew all shapes one pixel at a time. Line now draws horizontal and vertical lines with one FillRectangle call when the display has it. FilledRectangle uses one FillRectangle call. The shapes that use these lines also get faster. tinydraw clips the rectangle to the display, because the drivers reject rectangles that are partly outside it. Run the tests of filled shapes on a display with and without FillRectangle. Add tests for filled rectangles, filled circles, rectangles and shapes partly outside the display.
hervenicol
marked this pull request as ready for review
October 18, 2026 12:56
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.
This PR improves performance of a few drawing primitives with drivers that support "FillRectangle".
Most display drivers have a
FillRectanglemethod that fills a rectangle in one operation. tinydraw used onlySetPixel, so it drew all shapes one pixel at a time. For example, on an st7735, eachSetPixelcall sets a 1x1 window and sends one pixel over SPI.This change uses
FillRectanglewhen the display has it:Linedraws horizontal and vertical lines with oneFillRectanglecall.FilledRectangleuses oneFillRectanglecall.Rectangle,FilledTriangleandFilledCircleuse these lines, so they also get faster.The drivers reject rectangles that are partly outside the display, so tinydraw clips the rectangle to the display first. Displays without
FillRectanglekeep theSetPixelpath.The output is the same, pixel for pixel. The tests now run each filled shape on a display with and without
FillRectangle. New tests cover filled rectangles, filled circles, rectangles, and shapes partly outside the display. I made the new reference images with the code before this change.I tested it on a PyBadge (st7735) with gobadge. The menu triangles and the badge's rounded corners draw correctly, and faster.
Known driver bug:
ssd1306anduc8151clear the whole display whenFillRectanglegets a black rectangle that ends at the bottom-right corner. tinydraw now callsFillRectanglemuch more often, so this bug is more likely to show. tinygo-org/drivers#920 fixes it.