Skip to content

Commit

Permalink
Tile returning array of <symbol>s (#33)
Browse files Browse the repository at this point in the history
* Mapping can now return an array of strings or VDOM tiles, each with
  their own `z-index`.  First non-null tile controls `viewBox`.
* `chess` examples save 15-35% by avoiding duplication of background tiles
  • Loading branch information
edemaine committed Sep 26, 2022
1 parent 8dfb900 commit b528d51
Show file tree
Hide file tree
Showing 10 changed files with 392 additions and 663 deletions.
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,23 @@ or return value of a function) should be specified as one of the following:
6. An empty string, short for the empty symbol `<symbol viewBox="0 0 0 0"/>`.
7. `undefined` or `null`, indicating that this mapping doesn't define a tile
for this tile name (and the next mapping should be checked).
8. Another mapping (JavaScript object, `Map` object, or function) that gets
8. An `Array` of tiles of any of the above formats (or more `Array`s, which
get flattened), meaning to stack multiple tiles on top of each other,
where the first non-null tile defines the `viewBox` and size
(but all can influence the [`overflowBox`](#overflow-and-bounding-box)).
Use [`z-index`](#z-index-stacking-order-of-tiles)
to control stacking order.
Null items in the array get ignored, and an empty array acts like `null`
(this mapping does not define a tile for this tile name).
9. Another mapping (JavaScript object, `Map` object, or function) that gets
recursively evaluated as described above (with the same tile name and
context). For example, a top-level JavaScript object could map some tile
names to functions (when they need to be dynamic); or a top-level function
could return different mappings depending on context.
9. One of the tiles above wrapped in a call to `svgtiler.static`, e.g.,
`svgtiler.static(<symbol/>)`. This wrapper tells SVG Tiler that the tile
mapping is always the same for this tile name, and does not depend on
`Context` (e.g. adjacent tiles), enabling SVG Tiler to do more caching.
10. One of the tiles above wrapped in a call to `svgtiler.static`, e.g.,
`svgtiler.static(<symbol/>)`. This wrapper tells SVG Tiler that the tile
mapping is always the same for this tile name, and does not depend on
`Context` (e.g. adjacent tiles), enabling SVG Tiler to do more caching.

If you need to use a `<marker>`, `<filter>`, gradient, or other element
intended for `<defs>`, call `svgtiler.def(tag)`, where `tag`
Expand Down
112 changes: 32 additions & 80 deletions examples/chess/board-immortal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
159 changes: 48 additions & 111 deletions examples/chess/board-init.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 39 additions & 51 deletions examples/chess/board-kasparov-immortal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b528d51

Please sign in to comment.