@@ -300,45 +300,45 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_fill_region_obj, 0, bitmaptools_obj_fill_
300
300
//| def boundary_fill(
301
301
//| dest_bitmap: displayio.Bitmap,
302
302
//| x: int, y: int,
303
- //| value : int, background_value : int) -> None:
303
+ //| fill_color_value : int, replaced_color_value : int) -> None:
304
304
//| """Draws the color value into the destination bitmap enclosed
305
305
//| area of pixels of the background_value color. Like "Paint Bucket"
306
306
//| fill tool.
307
307
//|
308
308
//| :param bitmap dest_bitmap: Destination bitmap that will be written into
309
309
//| :param int x: x-pixel position of the first pixel to check and fill if needed
310
310
//| :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
312
312
//| 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
314
314
//| value color in the enclosed area in the destination bitmap"""
315
315
//| ...
316
316
//|
317
317
STATIC 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 };
319
319
320
320
static const mp_arg_t allowed_args [] = {
321
321
{MP_QSTR_dest_bitmap , MP_ARG_REQUIRED | MP_ARG_OBJ },
322
322
{MP_QSTR_x , MP_ARG_REQUIRED | MP_ARG_INT },
323
323
{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 } },
326
326
};
327
327
mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
328
328
mp_arg_parse_all (n_args , pos_args , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
329
329
330
330
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
331
331
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 ;
334
334
color_depth = (1 << destination -> bits_per_value );
335
- if (color_depth <= value ) {
335
+ if (color_depth <= fill_color_value ) {
336
336
mp_raise_ValueError (translate ("value out of range of target" ));
337
337
}
338
338
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 ) {
342
342
mp_raise_ValueError (translate ("background value out of range of target" ));
343
343
}
344
344
@@ -352,7 +352,7 @@ STATIC mp_obj_t bitmaptools_obj_boundary_fill(size_t n_args, const mp_obj_t *pos
352
352
mp_raise_ValueError (translate ("out of range of target" ));
353
353
}
354
354
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 );
356
356
357
357
return mp_const_none ;
358
358
}
0 commit comments