RazrFalcon / tiny-skia

A tiny Skia subset ported to Rust
BSD 3-Clause "New" or "Revised" License
1.05k stars 67 forks source link

Dashing fails for paths with odd numbers of dashes #102

Closed notgull closed 11 months ago

notgull commented 11 months ago

piet-tiny-skia-03-2 00

This is one of the piet samples that I was using to test out my new piet-tiny-skia API. The dashed lines are there to demonstrate whether or not dashed lines work. The lines start with one entry in the dash_array argument, then two, and so on and so forth. I've set up the API to fall back to a solid line if dashing fails.

Looks like the issue is this line:

https://github.com/RazrFalcon/tiny-skia/blob/d2b7abbde312a18f4c62ddc7201a32eb6e1a146f/path/src/dash.rs#L51-L53

This would probably require a re-work of the dashing engine. I'll do it at some point later once I have time.

Also, some praise: nearly all of the 17 piet samples worked out of the box for this crate, which really proves how high-quality of a software rasterization engine it is. The only ones that didn't output what I expected are this one and another one that's probably my fault.

RazrFalcon commented 11 months ago

This is the correct behavior. If I'm not mistaken here is the Skia code (and this one).

And while your solution is correct, I think this should be done by the caller. Just like resvg does. Afaik most 2D libraries require even number of intervals.

Also, some praise: nearly all of the 17 piet samples worked out of the box for this crate

Just 17? I'm using tiny-skia in resvg, which has 1500 "samples". I know it's pretty good, thanks. But there is still a lot of work left. Performance, color management, minor bugs, nicer API, etc.

notgull commented 11 months ago

I see, thanks!