flother / spreet Goto Github PK
View Code? Open in Web Editor NEWCreate a spritesheet from a set of SVG images
License: MIT License
Create a spritesheet from a set of SVG images
License: MIT License
The actions-rs/toolchain action is used to install the Rust toolchain on GitHub Actions, but it's been unmaintained for a while now (see actions-rs/toolchain#216) and is in dire need of replacing (see actions-rs/toolchain#219). It looks like dtolnay/rust-toolchain is a suitable drop-in replacement.
Github actually supports easy transition - just rename it, and it will create proper redirects
I don't think there is currently a way to set the content
, stretchX
and stretchY
optional properties in the inext file, correct? (take a look at the mapbox docs)
Maybe these values could be read from data attributes of the SVG root element or an optional json file with the same name as the svg or another JSON as another input, which includes optional properties for all sprites.
Thoughts?
Currently there are many .unwrap()
calls that would cause a lib user to have an unexpected crash. I think actix
web framework will handle when a URL path handler would crash, but clearly it would be better to have proper error handling instead.
I propose to add thiserror
-implementing Error enums instead. Would that be ok?
It's not mentioned in the README but spritezero-cli has had a --unique
option since v1.1.0 in June 2016, added in mapbox/spritezero-cli#10. When given, it only includes unique images in the spritesheet but maps them to multiple names in the index file. For Spreet to be compatible with spritezero-cli it should have the same option.
For two sprites to be considered unique, Spritezero actually compares the text of the SVG files (see 00dd132b
), but it would be better to compare the rendered raster sprites. That would take care of any differences in e.g. whitespace between the two original SVGs.
When a sprite index file is output by Spreet, it's pretty-printed. There should be an option to allow it to be output without any optional whitespace. For example, this should be the default output:
{
"poi": {
"width": 32,
"height": 32,
"x": 0,
"y": 0,
"pixelRatio": 1
}
}
But when the --minify-index-file
argument is passed it should be output as:
{"poi":{"width":32,"height":32,"x":0,"y":0,"pixelRatio":1}}
Thanks for making this library!
I previously used Spritezero in Javascript. Not the Spritezero-CLI version.
Here I could input a list of files instead of pointing to a folder.
Would it be possible to implement something like this?
I probably have a weird use case, where I can upload to 3 different folders, for example:
/sprites/public
/sprites/version-a
/sprites/version-a/part-b
where I want to generate a spritesheet for part-b
, but including the sprites in public
and version-a
.
But not including /sprites/version-a/part-a
.
I tried to use Symbolic Links to create a new directory first /sprites/temp
then create symbolic links to all .svgs.
They work in other programs correctly.
But this gives me the error:
Error: cannot make a valid sprite name from "/sprites/temp/new-sprite.svg"
When i copy the files to the same folder, so no symlinks, they work correctly.
Hey, really nice tool! Happy to discover this after dealing with spritezero's (via mapnik) Node versioning issues.
It would be cool to be able to include jpg or png images in the source folder and to have them map across to the sprite sheet too.
Cheers and well done!
Thanks a bunch for making this project! It would be great if it were on crates.io as well for ease of installation on non-macOS platforms (like my CI/CD pipelines).
Really cool project!
I'm currently looking for a solution to converts SVG files to SDF sprites. In MapLibre, this kind of sprites allow to change the color of the icons in the style.
Here is a PNG storing SDF icons:
https://tiles.baremaps.com/sprites/osm/[email protected]
The corresponding sprite definition file:
https://tiles.baremaps.com/sprites/osm/[email protected]
And a demonstration:
https://demo.baremaps.com/#14.59/46.52182/6.63022
Spritezero works well for small SVG icons, but I'm struggling to convert more complex SVG files to SDF sprites (e.g. forest pattern). Is SDF in your roadmap?
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.
with the recent release, it is no longer possible to pre-process each SVG pixmap independently, and merge the results. I was doing it all in parallel using Tokio, and I think there is a significant enough benefit, esp for a high-load scenario, to offer rapid sprite generation.
How could we make this a bit more optimized? Thx!
I have a the following directory structure:
input
├── category1
│ ├── foo.svg
│ └── bar.svg
├── baz.svg
└── category2
├── foo.svg
└── bar.svg
When calling spreet
i only get a spritesheet including baz.svg
. Instead I would like to include all files with the following ids: category1/foo
, category1/bar
, baz
, category2/foo
, category2/bar
.
As far as I can tell this is not possible at the moment. Would you be open to a PR which adds this functionality?
If yes, should this this be disabled by default and behind an option (--deep
or something)?
In the following example, the icons generated with spritezero seem to apply some antialiasing whereas the spreet one does not:
The svg file used to generate the veterinary icon is located here:
https://github.com/apache/incubator-baremaps/blob/main/basemap/assets/icons/veterinary.svg
The following README contains instructions to generate a sprite that contains most openstreetmap-carto icons:
https://github.com/apache/incubator-baremaps/blob/main/basemap/assets/README.md
All the icons seem to be affected by this issue.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.