jbosboom / svg-tiler Goto Github PK
View Code? Open in Web Editor NEWtiles SVGs from ASCII input (deprecated: use edemaine/svgtiler instead)
tiles SVGs from ASCII input (deprecated: use edemaine/svgtiler instead)
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:
<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;
).<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.)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).
Would help interpret output while debugging, particularly when a mapping contains more characters than are actually used in a particular image.
Some care must be taken to sanitize the filenames. Also, we might map multiple characters to the same symbol. If they really are the same (not styled differently; see #1), we should only emit one symbol; otherwise we'll need unique names.
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%.
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.
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.