Rajsekhar
Rajsekhar

Reputation: 1

how to implement floodfill algorithm using fabricjs?

I have an algorithm for Floodfilling a canvas. Im trying to incorporate this with fabricJS. So here is the dilemna.... I create a fabric.Canvas(). Which creates a wrapper canvas and also an upper-canvas canvas. I click on the canvas to apply my Floodfill(). This works fine and applies my color. But as soon as i go to drag my canvas objects around, or add additional objects to the canvas, the color disappears and looks like it resets of sort.

Upvotes: 0

Views: 193

Answers (1)

Shivam Chauhan
Shivam Chauhan

Reputation: 5

I have implemented flood fill algorithm in my project too and have taken inspiration from https://stackoverflow.com/a/52759579/9903046 You can see the final improved version of algorithm at https://github.com/Shivamc489/fabricjs-flood-fill This basically creates a image of the colored part and places atop the current objects, so your issue of color getting disappear also gets resolved.

Upvotes: 0

Related Questions