tvf played player/tvf-player.js

The animations a third way: as the scene itself. A .tvfs file holds what the leaf editor holds, each shape's leaves or corners and each morph's keys and settings, and no frames at all. The player poses it with the editor's own engine, taken from draw.html unchanged, and draws the curves at whatever size the canvas is, so every tile below is as sharp in a thumbnail as full screen and moves as it moves in the editor, to a part in ten million.

The files are small because they keep only what was chosen: the metamorphosis is 4.9 kB against 1,080 kB as an animated SVG, the snow 46 kB against 3.3 MB. The price is a script: the player and the curve library, about 80 kB and 75 kB, loaded once for every scene on a page. Below, how to make one, put it on a page and drive it, then a place to drop your own, then every example.

how to your own

how to use it

4 steps

Four things to know, each as short as it can be. The code is the code: copy it and it works.

1 make a scene

In the leaf editor, select two or more shapes, press morph and then live, and set it going: keys, paths, motions, colours, clips, whatever it needs. Then the morph bar's tvfs button writes the file. Or start from any tile on the animated page: open in draw, change it, press tvfs.

What is on the page is what is written: the live morphs as their keys and their own settings, every other shape as it stands, in the drawing's order, with the bar's ease, hold, trail, gravity and wind and the loop's length.

2 put it on a page

Two scripts and a canvas. The canvas names its scene in data-tvfs and plays as soon as the page has loaded; give it a size with CSS, and the player draws at that size, times the screen's pixel ratio.


        
that code, running (the scene's address made local)

The files can live anywhere a page can fetch from: next to it, or here (GitHub Pages lets any page fetch them). data-background paints the canvas first; without it the page shows through.

3 drive it from a script

TVFPlayer.play takes a canvas and a scene (its address, or the object) and hands back the controller:


        

For a loop of your own, load the scene once and draw it into any 2D context at any time; poses gives each morph's outline at a time as numbers, the leaves {x, y} or the corners {x, y, r, c}, for anything else you want to do with them.

4 what is in the file

One JSON object, written for reading back, not for frames:


        

Leaves are float32 in base64, two rows a shape; exact shapes keep their corners, roundings, smooth corners, curve handles and holes. A morph's own is the editor's own record of its settings (clock, path, motion, colour, clip, parent, facing), read back by the editor's own function. Not in it: anything the editor shows only while editing (guides, handles, numbers).

your own

drop a .tvfs or a Lottie

Open a .tvfs or drop one on this panel, and it plays here at the size of the panel. A Lottie file (Bodymovin's .json) is turned into a scene first, here, by player/lottie.js, and what it could not read is named under the panel. Scrub it with the slider. Nothing is sent anywhere: the file is read in this tab. The same is on its own page, player/player.html, which also takes ?src=.

drop a .tvfs or a Lottie .json here
no scene yet: try one of the examples below, each has a download button