I would not name your function stroke()
- there is already a canvas method of this name and it will only cause confusion and possible conflict.
is a free graphics editor that uses bezier curves. However, I can't say that I've used it but thought it worth mentioning. Perhaps it can use the same co-ordinates system as a canvas(??).
I haven't explored canvas but my first thought would be that a path is not fully closed before fill() but, as you say, you have checked this already. Perhaps you need to create the line starting at a different point - so that it will realise you intend to fill the larger area.