correcting feedback

This commit is contained in:
jposada202020 2023-03-30 08:51:52 -04:00
parent f3d85d6932
commit 6ad053e403
3 changed files with 59 additions and 22 deletions

View File

@ -122,6 +122,7 @@ msgid "%q in %q must be of type %q, not %q"
msgstr "" msgstr ""
#: ports/espressif/common-hal/espulp/ULP.c #: ports/espressif/common-hal/espulp/ULP.c
#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/digitalio/DigitalInOut.c
#: shared-bindings/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c
@ -1217,6 +1218,7 @@ msgstr ""
msgid "Interrupt error." msgid "Interrupt error."
msgstr "" msgstr ""
#: ports/mimxrt10xx/common-hal/audiobusio/__init__.c
#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c #: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c py/argcheck.c
#: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/digitalio/DigitalInOut.c
#: shared-bindings/displayio/EPaperDisplay.c #: shared-bindings/displayio/EPaperDisplay.c
@ -1224,6 +1226,7 @@ msgid "Invalid %q"
msgstr "" msgstr ""
#: ports/atmel-samd/common-hal/microcontroller/Pin.c #: ports/atmel-samd/common-hal/microcontroller/Pin.c
#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c
#: shared-bindings/microcontroller/Pin.c #: shared-bindings/microcontroller/Pin.c
msgid "Invalid %q pin" msgid "Invalid %q pin"
msgstr "" msgstr ""
@ -3827,11 +3830,7 @@ msgstr ""
msgid "out must be a float dense array" msgid "out must be a float dense array"
msgstr "" msgstr ""
#: shared-bindings/displayio/Bitmap.c #: shared-bindings/bitmaptools/__init__.c
msgid "out of range of source"
msgstr ""
#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c
msgid "out of range of target" msgid "out of range of target"
msgstr "" msgstr ""
@ -3856,14 +3855,10 @@ msgstr ""
msgid "parameters must be registers in sequence r0 to r3" msgid "parameters must be registers in sequence r0 to r3"
msgstr "" msgstr ""
#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c #: shared-bindings/bitmaptools/__init__.c
msgid "pixel coordinates out of bounds" msgid "pixel coordinates out of bounds"
msgstr "" msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "pixel value requires too many bits"
msgstr ""
#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c
msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter"
msgstr "" msgstr ""
@ -3905,6 +3900,10 @@ msgstr ""
msgid "queue overflow" msgid "queue overflow"
msgstr "" msgstr ""
#: shared-bindings/bitmaptools/__init__.c
msgid "radius must be greater than zero"
msgstr ""
#: py/parse.c #: py/parse.c
msgid "raw f-strings are not supported" msgid "raw f-strings are not supported"
msgstr "" msgstr ""
@ -4276,10 +4275,6 @@ msgstr ""
msgid "value out of range of target" msgid "value out of range of target"
msgstr "" msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
msgstr ""
#: ports/espressif/common-hal/watchdog/WatchDogTimer.c #: ports/espressif/common-hal/watchdog/WatchDogTimer.c
msgid "watchdog not initialized" msgid "watchdog not initialized"
msgstr "" msgstr ""

View File

@ -871,20 +871,48 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_dither_obj, 0, bitmaptools_dither);
// requires all 5 arguments // requires all 5 arguments
//| def draw_circle( //| def draw_circle(
//| dest_bitmap: displayio.Bitmap, x0: int, y0: int, radius: int, value: int //| dest_bitmap: displayio.Bitmap, x: int, y: int, radius: int, value: int
//| ) -> None: //| ) -> None:
//| """Draws a circle into a bitmap specified using a center (x0,y0) and radius r. //| """Draws a circle into a bitmap specified using a center (x0,y0) and radius r.
//| //|
//| :param bitmap dest_bitmap: Destination bitmap that will be written into //| :param bitmap dest_bitmap: Destination bitmap that will be written into
//| :param int x0: x-pixel position of the circle's center //| :param int x: x-pixel position of the circle's center
//| :param int y0: y-pixel position of the circle's center //| :param int y: y-pixel position of the circle's center
//| :param int radius: circle's radius //| :param int radius: circle's radius
//| :param int value: Bitmap palette index that will be written into the //| :param int value: Bitmap palette index that will be written into the
//| circle in the destination bitmap""" //| circle in the destination bitmap
//|
//| .. code-block:: Python
//|
//| import board
//| import displayio
//| import bitmaptools
//|
//| display = board.DISPLAY
//| main_group = displayio.Group()
//| display.root_group = main_group
//|
//| palette = displayio.Palette(2)
//| palette[0] = 0xffffff
//| palette[1] = 0x440044
//|
//| bmp = displayio.Bitmap(128,128, 2)
//| bmp.fill(0)
//|
//| bitmaptools.circle(64,64, 32, 1)
//|
//| tilegrid = displayio.TileGrid(bitmap=bmp, pixel_shader=palette)
//| main_group.append(tilegrid)
//|
//| while True:
//| pass
//|
//| """
//|
//| ... //| ...
//| //|
STATIC mp_obj_t bitmaptools_obj_draw_circle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { STATIC mp_obj_t bitmaptools_obj_draw_circle(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum {ARG_dest_bitmap, ARG_x0, ARG_y0, ARG_radius, ARG_value}; enum {ARG_dest_bitmap, ARG_x, ARG_y, ARG_radius, ARG_value};
static const mp_arg_t allowed_args[] = { static const mp_arg_t allowed_args[] = {
{MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}},
@ -906,12 +934,21 @@ STATIC mp_obj_t bitmaptools_obj_draw_circle(size_t n_args, const mp_obj_t *pos_a
} }
int16_t x0 = args[ARG_x0].u_int; int16_t x = args[ARG_x].u_int;
int16_t y0 = args[ARG_y0].u_int; int16_t y = args[ARG_y].u_int;
int16_t radius = args[ARG_radius].u_int; int16_t radius = args[ARG_radius].u_int;
if (x < 0 || x >= destination->width) {
mp_raise_ValueError(translate("out of range of target"));
}
if (y < 0 || y >= destination->height) {
mp_raise_ValueError(translate("out of range of target"));
}
if (radius < 0) {
mp_raise_ValueError(translate("radius must be greater than zero"));
}
common_hal_bitmaptools_draw_circle(destination, x0, y0, radius, value); common_hal_bitmaptools_draw_circle(destination, x, y, radius, value);
return mp_const_none; return mp_const_none;
} }

View File

@ -931,6 +931,11 @@ STATIC void draw_circle(displayio_bitmap_t *destination,
mp_arg_validate_int_range(x0, SHRT_MIN, SHRT_MAX, MP_QSTR_x0); mp_arg_validate_int_range(x0, SHRT_MIN, SHRT_MAX, MP_QSTR_x0);
mp_arg_validate_int_range(y0, SHRT_MIN, SHRT_MAX, MP_QSTR_y0); mp_arg_validate_int_range(y0, SHRT_MIN, SHRT_MAX, MP_QSTR_y0);
x0 = MIN(x0, destination->width);
x0 = MAX(0, x0);
y0 = MIN(y0, destination->height);
y0 = MIN(0, y0);
BITMAP_DEBUG("x, y, radius (%4d, %4d, %4d)\n", x0, y0, radius); BITMAP_DEBUG("x, y, radius (%4d, %4d, %4d)\n", x0, y0, radius);
y = radius; y = radius;