memononen / nanosvg

Simple stupid SVG parser
zlib License
1.71k stars 363 forks source link

Single pixel line not possible? #165

Open adipose opened 5 years ago

adipose commented 5 years ago

I tried rendering a single pixel line by putting the line between two pixel positions (1.5). Instead it rendered on both sides creating a 2 pixel line.

Bardo91 commented 3 years ago

I am facing a similar problem. Have you found a solution?

I investigated a bit the code and found that shapes have "strokeWidth". I tried to play around with that parameter to force some line width but still have the same problem. Then I found that the raster somehow depends on a macro called "NSVG__SUBSAMPLES" which is set to 5.

For example, if I force a strokeWidth of 0.1, with subsamples equals to 5 I get this result image

But, if I increase the subsamples to 20 I get this image image

But the fact is that, the strokeWidth is the same in both cases and If I decrease it even more, the raster starts failing again. I am wondering if it is possible to set a rule for the subsamples value that fixes that. Or if I am crashing nuts with a hammer.

adipose commented 3 years ago

I never solved it. I redesigned my application to manually draw lines instead of using SVG to define the button art. :-/

I am sure it's fixable but no one seemed to care.

Bardo91 commented 3 years ago

Oh I see :(... I will dig a bit on it, and write it here in case I found a solution.