Git Product home page Git Product logo

svg-tiler's People

Contributors

jbosboom avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

svg-tiler's Issues

Support defining symbols as styles over other symbols

Suppose we want to tile a chess position. The black and white pieces probably have the same shape, but differ in their color. Currently we'd have a mapping file like

K @white-king.svg
k @black-king.svg
Q @white-queen.svg
q @black-queen.svg

where the SVG files have the same paths with different stroke and fill colors. This duplication makes changing the shapes or colors unnecessarily difficult.

SVG supports CSS-like styles, and we should use them. I see two particular ways forward:

  • Use CSS classes in the tile SVG files and specify a stylesheet on the command line, which will be embedded as a <style> element in the output SVG; the mapping file syntax will be extended to apply specified CSS classes to the <use> element referencing the symbol (e.g., K @white-king.svg; fill:white; stroke:black;).
  • Extend the mapping file syntax to long names, then define other symbols as <g> elements with style attributes enclosing references to the previously-defined symbols (e.g., K <g fill="white" stroke="black"><use id="knight-template" /></g>). This still requires care when authoring the tile SVGs, as any styles specified in the symbol cannot be overridden at the <use> site. (There is syntax for referencing external files from <use> but I think the semantics are that of nested <svg> rather than <symbol> elements.)

Remove empty or unreferenced elements to reduce output file size

Inkscape struggles to load some tiler outputs because they're large compared to many SVG files. We should remove empty <g> and <defs> elements, <metadata> elements on symbols (but they may contain license information about the included files), unreferenced symbols (or avoid emitting them entirely), and default attribute values and redundant namespace definitions (Batik loves these last two for some reason).

Investigate Inkscape's mishandling of tiler output

Inkscape doesn't handle (some) outputs of the tiler very well, typically duplicating each element dozens of times at varying offsets from their actual locations. This will be a problem for us if we want to use Inkscape's PDF+LaTeX export functionality to get nice-looking text.

My current hypothesis is that Inkscape gets confused by its own sodipodi-namespaced metadata, which it may not expect to survive enclosure in a <symbol>. (I can't reproduce the bug on files not containing sodipodi metadata, but I haven't tried very hard.)

If removing that metadata doesn't fix the problem, we should find an XML testcase reducer and find minimal tiler outputs that make Inkscape's rasterization differ from rsvg-convert's by more than N%.

png tiles?

Could we allow png files in addition to svg for individual tiles? Should just have to wrap them in an <image> tag, but would be nice to be automatic. This would be especially helpful for retro video games.

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.