Canvas - floodfill leaves white pixels at edges

后端 未结 4 574
清歌不尽
清歌不尽 2021-01-20 01:11

I am creating a drawing app. I have succeeded to do everything. When I paint the image with a dark color, some white pixels appear at the edges. I tried to change the value

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-20 01:17

    Your check for the outline is simply too strict, marking light gray pixels as ones you cannot color in. I simply tweaked your threshholds:

    function matchOutlineColor (r,g,b,a,e) {
      return a >= 150;
    }
    

    Notice my much higher numbers for the white value and alpha. You could maybe tweak this further but this looks good to me. Here are some before and after photos:

    Before (zoomed in 200%)

    After (zoomed in 200%)

提交回复
热议问题