rough-stuff / rough

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

Hachure fill is randomly missing for certain fractional hachureGap values #221

Closed fskpf closed 8 months ago

fskpf commented 8 months ago

For hachureGap values of 1.6, 1.7, or presumably fractions other than x.5 or integers, the hachure fill is randomly missing in the result.

For example, test this fiddle: https://jsfiddle.net/d7xjk5qb/ (run it multiple times). Note the hachureGap value. Changing it to an integer or x.5 values makes it work consistently.

I'm not sure about the hachureGap option anyway. The documentation states that it is a numerical value, but also states that it is the average pixel distance of the lines (guessing integer here?). Looking at the hachure-fill implementation the hachureGap is at least clamped to a minimum of 0.1, so I guess fractions should work in general.

pshihn commented 8 months ago

Wow this is a weird bug. Thanks for reporting it. Will update soon.

pshihn commented 8 months ago

The current scan-line algorithm doesn't work well with fractions. It can be fixed if needed. but for now I have updated Rough. to round the gap to the nearest integer. Since line-fills are always calculated in 1 pixel units you wouldn't notice any difference considering the roughness. involved. Resolved with https://github.com/rough-stuff/rough/pull/222 Rough version 4.6.6 published