Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining mappings #83

Closed
edemaine opened this issue Aug 9, 2022 · 1 comment
Closed

Combining mappings #83

edemaine opened this issue Aug 9, 2022 · 1 comment

Comments

@edemaine
Copy link
Owner

edemaine commented Aug 9, 2022

Currently, symbols defined by a later mapping file override symbols defined in earlier mapping files. I think this behavior is reasonable and intuitive as a default, but #33 makes me wonder about alternative approaches for overlays/underlays. For example:

export combine =  # add rectangle underlay to x/o symbols
  x: <rect z-index="-10" fill="black"/>
  o: <rect z-index="-10" fill="gray"/>
export combine =  # add checkerboard underlay to all symbols
  -> <rect z-index="-10" fill={if @i + @j % 2 == 0 then "gray" else "black"}/>

To implement this, we could have a separate CombineMapping class, and Mappings would check all CombineMappings (and treat them like added <symbol>s at the end), but use the current behavior for regular Mappings. I wonder if the provided context should also specify the "main" <symbol> (in particular its width and height) for these mappings.

Alternatively, we could define combination to be the default behavior....


With #33 complete, we could combine two known mappings by wrapping them in an array. Perhaps we need an svgtiler.require to load the mapping defined by another file (.txt or .js or whatever) as a Mapping, and then someone wanting to combine could wrap them in an array. For example:

export default [
  svgtiler.require './topLayer.txt'
  svgtiler.require './bottomLayer.coffee'
]
@edemaine
Copy link
Owner Author

With the addition of svgtiler.require, combining two existing mapping files in sequence (as in command line) or parallel (as in this issue) is now easy:

  • Sequence: new Mappings(svgtiler.require(f1), svgtiler.require(f2))
  • Parallel: [svgtiler.require(f1), svgtiler.require(f2)]

@edemaine edemaine mentioned this issue Nov 8, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant