mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
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>
This commit is contained in:
committed by
Damien George
parent
154d141965
commit
e70048cf59
@@ -536,6 +536,10 @@ static mp_obj_t framebuf_ellipse(size_t n_args, const mp_obj_t *args_in) {
|
||||
} else {
|
||||
mask |= ELLIPSE_MASK_ALL;
|
||||
}
|
||||
if (args[2] == 0 && args[3] == 0) {
|
||||
setpixel_checked(self, args[0], args[1], args[4], mask & ELLIPSE_MASK_ALL);
|
||||
return mp_const_none;
|
||||
}
|
||||
mp_int_t two_asquare = 2 * args[2] * args[2];
|
||||
mp_int_t two_bsquare = 2 * args[3] * args[3];
|
||||
mp_int_t x = args[2];
|
||||
|
||||
Reference in New Issue
Block a user