Skip to content

Make vectorio subclassable and add round rects - #11898

Merged
dhalbert merged 2 commits into
adafruit:mainfrom
tannewt:vectorio_round_rectangle
Nov 18, 2026
Merged

dhalbert merged 2 commits into
adafruit:mainfrom
tannewt:vectorio_round_rectangle

Conversation

@tannewt

@tannewt tannewt commented Nov 17, 2026

Copy link
Copy Markdown
Member

vectorio rounded rectangles save a bunch of memory over the bitmap based solution.

vectorio rounded rectangles save a bunch of memory over the bitmap based
solution.
@tannewt
tannewt force-pushed the vectorio_round_rectangle branch from 1856ceb to 7380850 Compare November 17, 2026 21:57
@tannewt
tannewt requested a review from dhalbert November 17, 2026 22:33
@tannewt
tannewt marked this pull request as ready for review November 17, 2026 22:33

@dhalbert dhalbert left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I did a Claude review and had it write a test program I ran on the PyPortal. Looks nice.

It came up with some interesting things (my words, not its words):

  • Circle outline_width has no upper bound. Rectangle does better validation: it limits the width to half of the shortest side.
  • Radius 1 doesn't do anything. At radius 1 the distance check is 0.71. Says check whether display_shapes RoundRect(r=1) does the same thing. Maybe your computation is better.

There is also a more complicated pre-existing bug that can cause a crash or bad behavior with mixin subclasses, like class F(Mixin, vectorio.Rectangle). The protocol lookup fails and _wrapper_shape() returns NULL. An easy fix is to have _wrapper_shape() raise TypeError when it gets NULL. The bigger fix is to search all the base classes for the protocol (code in objtype.c).

Also in the next comment is a patch file with some extra tests for test_vectorio.py. It checks some additional subclassing cases that Claude suggested.

@dhalbert

dhalbert commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Test patch file here:
0001-test-vectorio-subclass-early-init.patch

@tannewt

tannewt commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

Ok, @dhalbert I integrated your patch and added a circle outline check. I'm not really concerned about radius=1. I don't expect the two implementations to be pixel identical because I expect LVGL to be more correct.

@tannewt
tannewt requested a review from dhalbert November 18, 2026 19:14

@dhalbert dhalbert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the updates. The _wrapper_shape() mixin problem has other manifestations that are somewhat different in other native-subclassing routines. I'll open a separate issue about that later.

@dhalbert
dhalbert merged commit b1f635a into adafruit:main Nov 18, 2026
1218 of 1220 checks passed
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.

2 participants