@@ -300,45 +300,45 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_fill_region_obj, 0, bitmaptools_obj_fill_
300300//| def boundary_fill(
301301//| dest_bitmap: displayio.Bitmap,
302302//| x: int, y: int,
303- //| value : int, background_value : int) -> None:
303+ //| fill_color_value : int, replaced_color_value : int) -> None:
304304//| """Draws the color value into the destination bitmap enclosed
305305//| area of pixels of the background_value color. Like "Paint Bucket"
306306//| fill tool.
307307//|
308308//| :param bitmap dest_bitmap: Destination bitmap that will be written into
309309//| :param int x: x-pixel position of the first pixel to check and fill if needed
310310//| :param int y: y-pixel position of the first pixel to check and fill if needed
311- //| :param int value : Bitmap palette index that will be written into the
311+ //| :param int fill_color_value : Bitmap palette index that will be written into the
312312//| enclosed area in the destination bitmap
313- //| :param int background_value : Bitmap palette index that will filled with the
313+ //| :param int replaced_color_value : Bitmap palette index that will filled with the
314314//| value color in the enclosed area in the destination bitmap"""
315315//| ...
316316//|
317317STATIC mp_obj_t bitmaptools_obj_boundary_fill (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
318- enum {ARG_dest_bitmap , ARG_x , ARG_y , ARG_value , ARG_background_value };
318+ enum {ARG_dest_bitmap , ARG_x , ARG_y , ARG_fill_color_value , ARG_replaced_color_value };
319319
320320 static const mp_arg_t allowed_args [] = {
321321 {MP_QSTR_dest_bitmap , MP_ARG_REQUIRED | MP_ARG_OBJ },
322322 {MP_QSTR_x , MP_ARG_REQUIRED | MP_ARG_INT },
323323 {MP_QSTR_y , MP_ARG_REQUIRED | MP_ARG_INT },
324- {MP_QSTR_value , MP_ARG_REQUIRED | MP_ARG_INT },
325- {MP_QSTR_background_value , MP_ARG_REQUIRED | MP_ARG_INT },
324+ {MP_QSTR_fill_color_value , MP_ARG_REQUIRED | MP_ARG_INT },
325+ {MP_QSTR_replaced_color_value , MP_ARG_INT , {. u_int = INT_MAX } },
326326 };
327327 mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
328328 mp_arg_parse_all (n_args , pos_args , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
329329
330330 displayio_bitmap_t * destination = MP_OBJ_TO_PTR (mp_arg_validate_type (args [ARG_dest_bitmap ].u_obj , & displayio_bitmap_type , MP_QSTR_dest_bitmap )); // the destination bitmap
331331
332- uint32_t value , color_depth ;
333- value = args [ARG_value ].u_int ;
332+ uint32_t fill_color_value , color_depth ;
333+ fill_color_value = args [ARG_fill_color_value ].u_int ;
334334 color_depth = (1 << destination -> bits_per_value );
335- if (color_depth <= value ) {
335+ if (color_depth <= fill_color_value ) {
336336 mp_raise_ValueError (translate ("value out of range of target" ));
337337 }
338338
339- uint32_t background_value ;
340- background_value = args [ARG_background_value ].u_int ;
341- if (color_depth <= background_value ) {
339+ uint32_t replaced_color_value ;
340+ replaced_color_value = args [ARG_replaced_color_value ].u_int ;
341+ if (replaced_color_value != INT_MAX && color_depth <= replaced_color_value ) {
342342 mp_raise_ValueError (translate ("background value out of range of target" ));
343343 }
344344
@@ -352,7 +352,7 @@ STATIC mp_obj_t bitmaptools_obj_boundary_fill(size_t n_args, const mp_obj_t *pos
352352 mp_raise_ValueError (translate ("out of range of target" ));
353353 }
354354
355- common_hal_bitmaptools_boundary_fill (destination , x , y , value , background_value );
355+ common_hal_bitmaptools_boundary_fill (destination , x , y , fill_color_value , replaced_color_value );
356356
357357 return mp_const_none ;
358358}
0 commit comments