Repository navigation
Make vectorio subclassable and add round rects - #11898
Conversation
vectorio rounded rectangles save a bunch of memory over the bitmap based solution.
1856ceb to
7380850
Compare
There was a problem hiding this comment.
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):
Circleoutline_widthhas no upper bound.Rectangledoes 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_shapesRoundRect(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.
|
Test patch file here: |
|
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. |
dhalbert
left a comment
There was a problem hiding this comment.
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.
vectorio rounded rectangles save a bunch of memory over the bitmap based solution.