sunli829 / nvg

Pure-rust implementation of NanoVG

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shape Antialias Causes Incorrect Stroke Width and Color For Odd Widths

geom3trik opened this issue · comments

Forgive me if this is me not using the library correctly, but I've noticed that the stroke width and colour doesn't seem to match what I specify when the stroke width is set to an odd number when shape antialiasing is set to true. For example, if I set the stroke colour to black and width to 1.0 I end up with a 2px wide gray border as shown here:

image

Inspecting the color of the stroke shows that it is a gray rather than black. Similarly if I change only the stroke color to red, rgb(1.0, 0.0, 0.0), but keep everything else the same I get this:

image

Which is also 2px wide and not the correct color. Now if I set the stroke width to 2.0 I get what I would expect, a 2 pixels wide border with the specified color:

image

Now if I try a stroke width of 3.0 I get this:

image

It's difficult to see from the screenshot but the border is 4 pixels wide with a 2px wide black center surrounded by 1 pixel wide gray borders.

My DPI scaling is set to 1.0 so I assume that the units correspond directly to pixels. If I turn shape antialiasing off then the stroke width and color are exactly what I would expect except now I can't use rounded corners because they look terrible. I don't know how the antialiasing works but I'm assuming it is adding fragments to blend the edges and that could maybe be the cause?

I just want to say this is a great library by the way. Very easy to use and renders very quickly. Thank you for your time and effort.

commented

I fixed stroke width problem at v0.5.11.