24
24
* THE SOFTWARE.
25
25
*/
26
26
27
- #include <string.h>
28
-
29
27
#include "shared-bindings/bitmaptools/__init__.h"
30
28
#include "shared-bindings/displayio/Bitmap.h"
31
29
#include "shared-module/displayio/Bitmap.h"
@@ -262,6 +260,9 @@ void common_hal_bitmaptools_boundary_fill(displayio_bitmap_t *destination,
262
260
return ;
263
261
}
264
262
263
+
264
+
265
+
265
266
uint32_t current_point_color_value ;
266
267
267
268
// the list of points that we'll check
@@ -274,6 +275,11 @@ void common_hal_bitmaptools_boundary_fill(displayio_bitmap_t *destination,
274
275
mp_obj_new_tuple (2 , point )
275
276
);
276
277
278
+ int16_t minx = x ;
279
+ int16_t miny = x ;
280
+ int16_t maxx = y ;
281
+ int16_t maxy = y ;
282
+
277
283
if (replaced_color_value == INT_MAX ) {
278
284
current_point_color_value = common_hal_displayio_bitmap_get_pixel (
279
285
destination ,
@@ -288,10 +294,11 @@ void common_hal_bitmaptools_boundary_fill(displayio_bitmap_t *destination,
288
294
289
295
mp_obj_t current_point ;
290
296
291
-
292
297
size_t tuple_len = 0 ;
293
298
mp_obj_t * tuple_items ;
294
299
300
+ int cur_x , cur_y ;
301
+
295
302
// while there are still points to check
296
303
while (list_length > 0 ) {
297
304
mp_obj_list_get (fill_area , & list_length , & fill_points );
@@ -308,6 +315,22 @@ void common_hal_bitmaptools_boundary_fill(displayio_bitmap_t *destination,
308
315
continue ;
309
316
}
310
317
318
+ cur_x = mp_obj_int_get_checked (tuple_items [0 ]);
319
+ cur_y = mp_obj_int_get_checked (tuple_items [1 ]);
320
+
321
+ if (cur_x < minx ) {
322
+ minx = (int16_t )cur_x ;
323
+ }
324
+ if (cur_x > maxx ) {
325
+ maxx = (int16_t )cur_x ;
326
+ }
327
+ if (cur_y < miny ) {
328
+ miny = (int16_t )cur_y ;
329
+ }
330
+ if (cur_y > maxy ) {
331
+ maxy = (int16_t )cur_y ;
332
+ }
333
+
311
334
// fill the current point with fill color
312
335
displayio_bitmap_write_pixel (
313
336
destination ,
@@ -365,7 +388,7 @@ void common_hal_bitmaptools_boundary_fill(displayio_bitmap_t *destination,
365
388
}
366
389
367
390
// set dirty the area so displayio will draw
368
- displayio_area_t area = { 0 , 0 , destination -> width , destination -> height };
391
+ displayio_area_t area = { minx , miny , maxx + 1 , maxy + 1 };
369
392
displayio_bitmap_set_dirty_area (destination , & area );
370
393
371
394
}
0 commit comments