checkout @DavidBraun 's flood fill tool: glsl subtract background - #2 by DavidBraun
this could get you started for some basic paint bucket functionality, but the missing thing is undo functionality, and being able to have multiple colors (but you could string multiple together if you need this).