daef / poly-bool-comparison

10 stars 4 forks source link

Switch to evenodd rule for SVGs? #2

Closed bluenote10 closed 4 years ago

bluenote10 commented 4 years ago

I noticed that currently the SVGs don't specify a fill-rule, which means that they default to a nonzero fill rule (i.e., winding order matters). Some thoughts:

Depending on what you want to achieve (testing for correctness w.r.t. evenodd or nonzero rules) you may either fix the input polygons or change the SVG conversion to evenodd. This can be done by changing line 9 of svg.js to:

w('<path style="fill:#000000" fill-rule="evenodd" d="')

This fixes a lot of "false negatives" for me as shown here: https://github.com/21re/rust-geo-booleanop/pull/15

daef commented 4 years ago

Thank you very much for this catch, my gut told me that I've forgot something along those lines..:

As you can see I already have evenodd for the unisample svgs but I forgot to update the duplicated versions of svg.js, will fix that tomorrow I hope :)

daef commented 4 years ago

I use evenodd now everywhere and I've added your feature branch since it's so easy :)

bluenote10 commented 4 years ago

I use evenodd now everywhere and I've added your feature branch since it's so easy :)

Cool thanks!