I am trying to implement a flood-fill algorithm that produces antialiased edges in HTML5 canvas.
My initial input is an ImageData
object, which contains the outlines of overlapping circles and lines over a transparent background. The outlines are already antialised, and I have the actual color of the edges (rgba(51, 51, 51, 255)
), and some grayscale "fringe" pixels produced by antialising the shapes (with values like rgba(48, 48, 48, 32)
and rgba(54, 54, 54, 200)
).
My current flood-fill implementation is aware of these fringe pixels, but it simply applies the fill color to them - resulting in pixelation. I also tried to apply the alpha-blending from this answer, also resulting in pixelation.
What algorithm would you recommend for producing smooth edges by blending the colors from these fringe pixels and the fill color?