spreet icon indicating copy to clipboard operation
spreet copied to clipboard

Padding support

Open brandonjpierce opened this issue 2 years ago • 4 comments

First off, excellent library, it has worked really well for us! One small need we have is actually applying a 1-2px padding around each icon. While this can be done at the SVG asset level we found it is a little easier to blanket apply it at the time of spritesheet generation. Current thought is a --spacing=1 flag or similar that would apply padding around each asset for the defined value.

brandonjpierce avatar Nov 17 '23 17:11 brandonjpierce

I don't think this would be too difficult: once the SVG has been rasterised as a Pixmap, it could then be redrawn into a buffered Pixmap (buffered by the number of padding pixels required). But I'm wondering what need you have that can't be handled by the icon-padding property. Are you able to share more details about your use-case?

flother avatar Nov 29 '23 21:11 flother

Almost less of a use case and more of a workaround for poorly exported assets. We have found on occasion that Figma, depending on how the vector is constructed, will sometimes export a SVG somewhat poorly which can result in a sort of sub-pixeling effect. Having the ability to add a 1-2px spacing around each icons accommodates for that. When drawing sprites to webgl for instance if the sub-pixeling is occurring you will see icons "bleeding" into one another just slightly.

brandonjpierce avatar Nov 30 '23 15:11 brandonjpierce

Am I right to say that Spritesmith's padding option is exactly the sort of thing you're after? For example, padding: 2 means there will be a 2px gap to the right and bottom of each image in the spritesheet.

(Not saying you should switch to Spritesmith, just wondering if that's the functionality you want to duplicate.)

flother avatar Feb 26 '24 20:02 flother

@flother precisely!

brandonjpierce avatar Feb 27 '24 20:02 brandonjpierce