Giter Club home page Giter Club logo

spreet's Issues

Support for optional properties (content, stretchX & stretchY)

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?

Convert all `.unwrap()` and similar panics to proper errors

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?

Add `--unique` command-line argument

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.

Add a CLI argument to allow sprite index file to be minified

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}}

File Input or SymLinks

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.

Support for png/jpg source images

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!

Crates.io release

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).

Add support for SDF sprites

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?

Padding support

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.

Unable to parallelize pixmap loading

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!

Include sub directories

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)?

The SDF icons seem to lack antialiasing

In the following example, the icons generated with spritezero seem to apply some antialiasing whereas the spreet one does not:

spritezero

spreet

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.