Problem: Outline around SVGs using Nano SVG

Hi all,

I am using the Nano SVG plugin for a game I am developing. Unfortunately, while my SVGs work perfectly on a white background, when they appear on any other coloured background they have a exhibit a slight lighter coloured outline. This is particularly noticeable when they are at smaller sizes. It looks as though the plugin is having some trouble dealing with transparency on edges.

I’ve just swapped in image sheets consisting of PNGs of my sprites instead, but it’s just not practical for me to use image sheets, as the number of sprites I am employing, and the size I wish to display them at, means that I would require a large number of image sheets. SVGs are perfect for my use case, but the white outline is not at all desirable.

I am ‘supersampling’ my SVGs, i.e. setting a pixelWidth which is a few times greater that the displayed size, to achieve the desired sharpness, e.g.

local testEmoji = svg.newImage {

pixelWidth = 120,

width = 30,

filename = “assets/svg/emoji/1f60d.svg”,

x = SCREEN_CENTER_X,

y = SCREEN_CENTER_Y,

}

I have also tried setting the pixelWidth to be the same as the displayed width, but my images do not come out as sharp, and, in fact, the outline effect is worsened!

FWIW I am using svgs from https://www.emojione.com/. The forum does not permit me to attach an SVG file to this post, but many examples of the SVGs I am using can be found here: https://github.com/emojione/emojione/tree/2.2.7/assets/svg

I have attached a couple of screenshots from the device I am testing on to illustrate the problem.

Many thanks in anticipation.

Hm… It may be because of some kind of scaling. Try to use power of 2 texture sizes, not sure if it really helps. This effect is more because of scaling. It would be rather hard to get rid of. I tried couple emojis, they look ok-ish

MNgbj2r.png

kfMtj2x.png

I think big part of the issue is high contrast between emojii and background, this is rather “optical illusion” rather than graphical side effect.

For example, try doing similar in your browser, it would have same effect - https://jsbin.com/lezorujowo/edit?html,css,output

(especially on non-retina screen).

P.S. nano svg is thin wrapper around nanoSVG library

Thanks for looking Vlad, I’ll update if I have any success.

Hm… It may be because of some kind of scaling. Try to use power of 2 texture sizes, not sure if it really helps. This effect is more because of scaling. It would be rather hard to get rid of. I tried couple emojis, they look ok-ish

MNgbj2r.png

kfMtj2x.png

I think big part of the issue is high contrast between emojii and background, this is rather “optical illusion” rather than graphical side effect.

For example, try doing similar in your browser, it would have same effect - https://jsbin.com/lezorujowo/edit?html,css,output

(especially on non-retina screen).

P.S. nano svg is thin wrapper around nanoSVG library

Thanks for looking Vlad, I’ll update if I have any success.