diff options
author | Corran Webster <cwebster@unital.dev> | 2024-11-14 10:15:10 +0000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-11-28 22:56:44 +1100 |
commit | e70048cf5934bf3db65ec7a1b6490635716282f5 (patch) | |
tree | 64cd862fb6c94c129b603c995ac2e4be9e502f93 /tests/extmod/framebuf_ellipse.py | |
parent | 154d1419659795aa6785778e4ddd6f23f09f2861 (diff) |
extmod/modframebuf: Fix 0 radius bug in FrameBuffer.ellipse.
This fixes a bug in FrameBuffer.ellipse where it goes into an infinite loop
if both radii are 0.
This fixes the bug with a simple pre-check to see if both radii are 0, and
in that case sets a single pixel at the center. This is consistent with the
behaviour of the method when called with just one of the radii set to 0,
where it will draw a horizontal or vertical line of 1 pixel width.
The pixel is set with setpixel_checked so it should handle out-of-bounds
drawing correctly.
This fix also includes three new tests: one for the default behaviour, one
for drawing out-of-bounds, and one for when the sector mask is 0.
Fixes issue #16053.
Signed-off-by: Corran Webster <cwebster@unital.dev>
Diffstat (limited to 'tests/extmod/framebuf_ellipse.py')
-rw-r--r-- | tests/extmod/framebuf_ellipse.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/extmod/framebuf_ellipse.py b/tests/extmod/framebuf_ellipse.py index a4c784aff..ec0461e66 100644 --- a/tests/extmod/framebuf_ellipse.py +++ b/tests/extmod/framebuf_ellipse.py @@ -63,3 +63,18 @@ for x, y in ( fbuf.fill(0) fbuf.ellipse(x, y, 6, 12, 0xAA, True) printbuf() + +# Draw an ellipse with both radius 0 +fbuf.fill(0) +fbuf.ellipse(15, 15, 0, 0, 0xFF, True) +printbuf() + +# Draw an ellipse with both radius 0 out of bounds +fbuf.fill(0) +fbuf.ellipse(45, 45, 0, 0, 0xFF, True) +printbuf() + +# Draw an ellipse with radius 0 and all sectors masked out +fbuf.fill(0) +fbuf.ellipse(15, 15, 0, 0, 0xFF, True, 0) +printbuf() |