marionebl / svg-term-cli

Share terminal sessions via SVG and CSS
MIT License
3.48k stars 116 forks source link

Extract a single frame #3

Closed mathiasbynens closed 6 years ago

mathiasbynens commented 6 years ago

Would it be feasible to extract just a single frame as an SVG?

marionebl commented 6 years ago

Sure, that is what derhuerst/asciicast-to-svg does.

We'd have to implement this over at marionebl/svg-term.

Could be something like this:

Below src/index.js#L35

const frames = 'frameAt' in options 
  ? frames.filter(frame => frame.stamp === frameAt)  // pseudo code
  : frames;

src/index.js#52

<Reel
   duration={data.duration}
   frameWidth={cast.width}
   stamps={data.stamps}
   width={data.frames.length * cast.width}
   animates={frames.length > 0}
   >

src/index.js#58

frames.map(frame => ...)

Want to to lend a hand? :)

marionebl commented 6 years ago

Ping @mathiasbynens (Guess I completed my comment edits after you read it)

marionebl commented 6 years ago

Introduce via https://github.com/marionebl/svg-term-cli/commit/7ec55c4ec0b381bac237f0358eba48609544b674

marionebl commented 6 years ago

Released via 1.1.0

$ yarn global add svg-term-cli@latest
$ svg-term --version
1.1.0

svg-term --cast=3 --out nyancat.svg --frame --from=3000 --to=6000 #1
svg-term --cast=rfS1M5ynKm1hGaBqJYJj0mGCi --out jsvu.svg --frame -at 40000 # 2
nyan.svg ![](https://rawgit.com/marionebl/svg-term-cli/master/examples/nyan.svg)
jsvu.svg ![](https://rawgit.com/marionebl/svg-term-cli/master/examples/jsvu.svg)
Timmmm commented 3 years ago

Did the --frame option get removed? It would have been really useful...

Timmmm commented 3 years ago

Ah never mind, you don't need --frame -at 10, just --at 10.