Closed jesperkc closed 2 years ago
The behavior is also dependant on the combineNestedSvgPaths
in combination with the fillStyle
. For example test the fill-rule evenodd example from the SVG spec on https://fskpf.github.io/ (where combineNestedSvgPaths
is enabled) and cycle through the fill-styles:
From top to bottom (same input): Original SVG // fillStyle hachure // fillStyle solid
Is combineNestedSvgPaths
intended to address this problem, e.g. setting it dependant on the nested path direction and its fill-rule
, so basically switch between "fill or don't fill nested paths"?
Though I guess this would not really work for cases where the path contains nested subpaths with both directions (with the surrounding shape's direction and against it), e.g.
<svg viewBox="-10 -10 110 110" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="nonzero" stroke="blue" d="
M10,0 h90 v90 h-90 z
M30,20 v20 h50 v-20 z
M30,60 h50 v20 h-50 z"/>
</svg>
Also, fill-style solid needs to consider this as well.
Although I have not done any work on winding direction yet, most issues with nested paths should be fixed now:
Fixed by https://github.com/rough-stuff/rough/pull/195 Releases as v4.5.0
on npm.
Can confirm it works now
This problem still exists when using https://unpkg.com/roughjs@4.3.1/bundled/rough.js
https://jsfiddle.net/rwpgx2t0/
Using a different path (taken from the SVG spec), winding direction indeed makes a difference, indicating non-zero-ness:
fill-rule=evenodd
fill-rule=nonzero
Originally posted by @ygra in https://github.com/pshihn/rough/issues/131#issuecomment-581187205