rough-stuff / rough

Create graphics with a hand-drawn, sketchy, appearance
http://roughjs.com
MIT License
19.83k stars 613 forks source link

Holes in paths are filled #158

Closed kevinzwang closed 4 years ago

kevinzwang commented 4 years ago

Hello!

I'm drawing some paths with RoughJS that holes. For example:

image

However, when I try to fill them, the holes are filled as well, in fact they're filled in twice, once by the outer path and once by the inner path.

image

I did some more digging and in the examples page, the second example looks like it has a rectangle at the top left corner that has a hole that is correctly unfilled, but if you click on the links to view on Glitch, that rectangle is rendered with the same behavior I have been seeing myself, with a filled hole. This seems to indicate that this was a feature that worked before but has since broke.

Would greatly appreciate a fix to this.

pshihn commented 4 years ago

Yes something changed recently. So now if your PATH is actually composed of multiple disconnect paths, like in your case, you need to set combineNestedSvgPaths: true in the options. I have updated the Glitch

e.g.

rc.path('M37,17v15H14V17z M50,5H5v50h45z', {
      stroke: 'red',
      strokeWidth: '1',
      fill: 'blue',
      combineNestedSvgPaths: true
});
kevinzwang commented 4 years ago

Awesome. thanks!