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

Animations #72

Open
5 tasks
edemaine opened this issue May 17, 2022 · 0 comments
Open
5 tasks

Animations #72

edemaine opened this issue May 17, 2022 · 0 comments

Comments

@edemaine
Copy link
Owner

edemaine commented May 17, 2022

One approach to animations is to build your own "driver" to replace svgtiler, which instead imports the API and calls it to load mappings, build the drawings, and render frames. (#34) On the web, we have renderDOM for this; need a similarly simple API call for command-line usage.

For smooth animations like this example, I think this approach might be best. We'd just need to offer a nice API like findTile({key: /foo/, origY: 5, newX: 2}) (searching by key and/or old/new coordinates) and translate/rotate/etc. helpers.

On the web, this could render smooth animations, which would be great for slides with renderDOM. On the command line, we could ask for snapshot frames at various times that get saved as SVG. Something like:

parallel([
  findTile(...).rotate(...)
  findTile(...).rotate(...)
])
snapshot()
series([
  findTile(...).translate(...)
  findTile(...).translate(...)
])
snapshot()

Older delta encoding approach

But potentially we could integrate animations into the svgtiler command line. For example, a JavaScript/CoffeeScript file could export a new name like drawings which could look like this:

export drawings = ->
  drawing = Input.recognize 'frame1.asc', '''
    AAA
    ABA
    AAA
  '''
  yield drawing
  drawing.data[1][1] = 'C'
  yield drawing
  drawing.replaceAll 'A', 'B'

Ideas here:

  • Generator for multiple frames, instead of needing to wrap in Drawings
  • replaceAll API feature (and presumably other helpers like findFirst, replaceFirst, findAll)
  • Maybe there's a way to specify the subname of the drawing. Otherwise use a counter?
  • Input.recognize isn't very convenient way to specify files; should enable maybe new ASCIIDrawing '''...'''.
  • Of course, we'd also want a .coffee file to be able to generate a single Drawing, maybe via export drawing. This is the first-level thing that would be cool!

DSL

Another option would be to invent a DSL for specifying animations, something like:

parallel
  move (1,2) -> (3,4)
  move (3,4) -> (5,6)
replace all 'A' with 'B'

But this might not be worthwhile / flexible enough.

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