Getting started
Your first clip: one track, two keyframes. Change where it ends and watch the data and the motion change together.
Your first clip
A clip is a duration in seconds and a list of tracks. Each track moves one property of one target, through its keyframes. This one moves a ball along x.
{
"duration": 2,
"tracks": [
{
"targetUid": "ball",
"property": "x",
"keyframes": [
{ "time": 0, "value": 0 },
{ "time": 1.2, "value": 400 }
]
}
]
}Play it
compile reads the clip once. svgDrawer writes each frame on the SVG: its bind function hands back the elements a target is written to, here every element whose data-stew-uid matches. createPlayer ties the two together, and play starts it.
The keyframes have no easing, so the move uses the default, power1.inOut: a gentle start and a gentle stop.
Nothing throws. A track or a keyframe the engine can't read is left out and noted in program.skipped, and the rest still plays.
What you can animate
A track's property is one of these. The pages that follow show each kind.
Movex,y,rotate,scale,scaleX,scaleY,skewX,skewY: composed into one transform about the target's pivot.Paintopacity,fill,stroke,strokeWidth,fillGradient, and the self-draw:draw(0 to 1 of the stroke) anddashOffset.Shapecx,cy,r,width,height, and whole outlines:morphandwarp.Travelmotion: how far along a path, 0 to 1.anchor: where the target turns about, keyed.Effectsblur,shadowX,shadowY,shadowBlur,shadowOpacity,shadowColor,glassRefraction,glassFrost,glassTint,seed.
Reference
durationnumberrequired- Seconds: one lap.
Infinitymeans it never ends. tracksStewTrack[]required- What moves.
loopbooleandefault true- Repeat when it ends. Read into
program.loopfor you; the player itself repeats by itsrepeatoption. pivotsRecord<string, StewPoint>default 0, 0- Where each target turns, scales and skews about, in the units of the element its transform is written to.
pathsRecord<string, StewPath>optional- The path each target's
motiontrack follows. boxesRecord<string, StewBox>optional- Each target's own box, for an
anchortrack. version1default 1- The format version.
targetUidstringrequired- Which target: your name for it.
propertystringrequired- What it animates:
"x","rotate","fill"... keyframesStewKeyframe[]required- Where it is at moments, in any order: the engine sorts them.
cyclenumberoptional- Seconds: the keys start over every
cycleseconds, forever, whatever the clip's length.
timenumberrequired- Seconds.
valuenumber | stringrequired- A number, a color, or path data, as the property needs.
easingstringdefault "power1.inOut"- The ease of the stretch leaving this keyframe, toward the next one.