Resolved: Paint bucket getting “Maximum Call Stack Size Exceeded” error


This is the code of the paint bucket tool in my drawing app using the p5.js library. The function self.floodFill always get “Maximum Call Stack Size Exceeded” because of recursion and I want to know the way to fix it. I am thinking if changing the function to a no recursion function would help or not. Any help would be appreciated.

Shameless plug, but relevant: I’ve created a blog comparing the different flood fill algorithms using p5.js.

If you have better answer, please add a comment about this, thank you!