Comments on: An HTML5 canvas Flood Fill that doesn’t kill the browser https://ben.akrin.com/an-html5-canvas-flood-fill-that-doesnt-kill-the-browser/ Fri, 05 Sep 2025 06:14:05 +0000 hourly 1 https://wordpress.org/?v=7.1 By: devland https://ben.akrin.com/an-html5-canvas-flood-fill-that-doesnt-kill-the-browser/#comment-769 Fri, 05 Sep 2025 06:14:05 +0000 http://ben.akrin.com/?p=7888#comment-769 I’ve made an open source library for this which has a round advancing front and is optimized via web workers so you can get a good framerate out of it.
https://github.com/devland/waveFiller

]]>
By: ben https://ben.akrin.com/an-html5-canvas-flood-fill-that-doesnt-kill-the-browser/#comment-768 Mon, 29 May 2023 13:14:28 +0000 http://ben.akrin.com/?p=7888#comment-768 In reply to Ron Besdansky.

Thank you 🙂 always good to know it’s helpful to others.

]]>
By: Ron Besdansky https://ben.akrin.com/an-html5-canvas-flood-fill-that-doesnt-kill-the-browser/#comment-767 Mon, 29 May 2023 12:49:42 +0000 http://ben.akrin.com/?p=7888#comment-767 Using your code, I have been able to create an animated map to track my travels. Something I’ve wanted to do for a long time. Thank you!

]]>
By: ben https://ben.akrin.com/an-html5-canvas-flood-fill-that-doesnt-kill-the-browser/#comment-766 Thu, 06 Feb 2020 14:28:38 +0000 http://ben.akrin.com/?p=7888#comment-766 In reply to devland.

I never considered it even though it’s painfully obvious :). I’ve actually done work with web workers so they’re not foreign in the least. Thank you for pointing it out :).

Regardless, I think it’s still worth trying to find something computationally efficient, which yields quick feedback to a user.

May I ask what cool project you’re working on?

]]>
By: devland https://ben.akrin.com/an-html5-canvas-flood-fill-that-doesnt-kill-the-browser/#comment-765 Thu, 06 Feb 2020 08:19:39 +0000 http://ben.akrin.com/?p=7888#comment-765 Have you considered trying web-workers to offload the pixel filling computations to a separate thread?
https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers

I’m about to create my own version of the bucket fill effect and, since pixel manipulation in the canvas revolves around manipulating a pixel array, you can offload the compuationally intensive workload to a web-worker so that the main JS thread doesn’t hang. I’ve tried this before with various other image manipulation algorithms and it works very well. 🙂

]]>
By: ben https://ben.akrin.com/an-html5-canvas-flood-fill-that-doesnt-kill-the-browser/#comment-764 Fri, 05 Jul 2019 15:39:05 +0000 http://ben.akrin.com/?p=7888#comment-764 In reply to Marcel Schramm.

You’re right, it’s a known issue having to do with transparency on the edges of drawn paths. The issue is that when you draw a path, it comes with some transparency on the edges (for smoothing), and this builds up the more you do it because the color matching is thus made inexact at these locations.

This algorithm also has a few pathfinding quirks :). It’s super specific and I don’t recommend using it unless you specifically need to fill using canvas paths. In my implementation on Mandalagaba, I keep track of path borders separately so I don’t have the build up issue. Here I distilled the algorithm to its simplest form and so it doesn’t have the extra complexity needed to avoid this build-up issue.

Thanks for taking the time to let me and other readers know about it. What are you working on? 🙂

]]>
By: Marcel Schramm https://ben.akrin.com/an-html5-canvas-flood-fill-that-doesnt-kill-the-browser/#comment-763 Fri, 05 Jul 2019 14:12:46 +0000 http://ben.akrin.com/?p=7888#comment-763 Hey, thanks for the post.

Just wanted to tell you that approach 5 is broken. It leaves the outlines behind every time that you fill again. So the area that actually gets filled becomes smaller and smaller.

]]>