bitmaptools.replace_color() function#10732
Conversation
dhalbert
left a comment
There was a problem hiding this comment.
Nice addition!
Suggestions:
- Arg name change simplification.
- Validate arg.
- Reuse an existing error message.
- Remove superfluous default args.
| //| dest_bitmap: displayio.Bitmap, old_color: int, new_color: int | ||
| //| ) -> None: | ||
| //| """Replace any pixels of old_color with new_color in the dest_bitmap | ||
| //| | ||
| //| :param bitmap dest_bitmap: Destination bitmap that will be written into |
There was a problem hiding this comment.
| //| dest_bitmap: displayio.Bitmap, old_color: int, new_color: int | |
| //| ) -> None: | |
| //| """Replace any pixels of old_color with new_color in the dest_bitmap | |
| //| | |
| //| :param bitmap dest_bitmap: Destination bitmap that will be written into | |
| //| bitmap: displayio.Bitmap, old_color: int, new_color: int | |
| //| ) -> None: | |
| //| """Replace any pixels of ``old_color`` with ``new_color`` in the ``bitmap`` | |
| //| | |
| //| :param displayio.Bitmap bitmap: bitmap that will be change |
…nneeded required arg default values.
|
Thank you! I've made those changes in the latest commit. I went ahead and removed |
|
The This is because There are missing initializers in quite a few places, such as in The gcc documentation for
So I think we should just add |
|
(Adding ) |
|
I added |
dhalbert
left a comment
There was a problem hiding this comment.
Thanks for re-testing after the build issues.
New
bitmaptoolsfunction to replace all pixels of a given color with a different color.Most directly I want to use this inside of an "AccentableLabel" class that I am working on that allows certain passages of text within the label to use a different foreground/background color scheme from the rest of the text.
Having this replace_color() function makes that easy and quick because it can blit from the glyph bitmap and then replace the
1s with a different color from the palette afterward.