pantin

This page is examples/README.md of the repository, as it is on main.

Examples

Projects to open in the application, each made to show one thing. From the root of the repository:

cargo run -p pantin-app -- examples/eyes.pantin

Started from the root of the repository with no project named, the application opens on a start screen where all of them are playing, each card saying what its example shows (File › Start screen… brings it back). Tick off Bones in the bar to see a character as a game shows it.

Each example is a project: a folder with its manifest (pantin.toml), its skeleton and its animations (rig.json), and its images (sources/), every one an SVG. docs/format/project.md says what these files mean.

One thing each

Project Shows What to look at
stickman.pantin A walk that loops Six bones and a walk of one second whose last pose is its first, with an event step at each step. The smallest project that moves; the first tour opens it.
bounce.pantin Curves A ball that is a clock hops onto the letters of pantin: each hop is a key on a curve that eases out and in (the tab Graph draws them), the squashes are scale keys, and the hand of the clock turns by stepped keys, a quarter at each landing, which the animation tells a game as land.
pendulum.pantin Overlap The rod and the weight have the same keys at the same times; the weight plays them a quarter of a second later, by an offset on the chain from rod, with no key moved. Select rod in Animate and change the step of Overlap.
tree.pantin Shear The trunk leans in the wind with its foot flat on the ground, which a rotation would lift; the crown leans a little later and is squashed by a scale key.
inherit.pantin What a bone inherits The plank turns a whole turn and stretches; its four flags are set up the same and each inherits in one of the four ways, in a colour of its own: teal inherits everything, amber the translation only, red no rotation, violet no scale. Turn Names on to read them.
planted.pantin Inverse kinematics The hips are the one bone with keys; the legs bend and the feet stay. See below.
grabber.pantin An IK that stretches A rubber arm reaches for a balloon that floats further than the arm is long: its IK constraint stretches, each bone lengthened, and keeps its area (Width: its area kept), so it thins as it grows; a softness of 12 slows it before it is straight, so that the elbow does not snap. The glove inherits no scale and stays its size. The mix of the constraint is keyed: halfway it lets go of the balloon a moment, and catches it again (the row reach · IK of the timeline).
jelly.pantin Springs keyed in time The bell of a jellyfish pulses up twice; its four tentacles, chains of three bones each on a spring, trail behind with no key of their own. For the second pulse their springs are keyed four times as heavy (mass, from 1.6 s to 2 s, back by the end): they follow later and sway further. Select a tentacle in Animate to see its row … · spring in the timeline.
cart.pantin A number that drives another Only the cart has keys, its position. Its wheels turn as it rolls: a transform constraint roll, in local space, gives each wheel a rotation of −3.18 degrees for each unit the cart goes (a wheel of radius 18). The needle of its dial is driven the same way (gauge), 90 degrees plus half a degree a unit, kept between 45 and 135: it stops at the ends of the dial. Select a wheel to see Driven under its constraint.
face.pantin A slider Only the eyes are keyed, in look. The face turns towards where they look by itself: a slider holds the animation turn (the nose and the mouth slide from left to right in a second) at the time the eyes give, their x times 0.05 plus 0.5. Nothing selected, the panel of the project shows it under Sliders.
eyes.pantin A transform constraint Only the fly has keys. Each pupil of the owl takes a share (0.075) of where the fly goes, by a constraint that mixes the translation only: the owl watches it, and its pupils stay in its eyes.
crane.pantin Springs The boom of a crane goes up and down; the hook has no key: it swings on a spring under a cable set to no_rotation, which keeps hanging straight down. Select hook to see its spring under Constraints.
dominoes.pantin Events, made by an agent A man pushes the first of eight dominoes, which fall one on the next: the first project Claude made through the MCP alone (docs/mcp.md). His arm reaches by an IK constraint, each finger has a bone for each joint, the fall comes from a simulation (tools/dominoes_physics.py), and each domino tells hit as it strikes the next. Its recipe replays the project it made, kept in fixtures/dominoes.pantin.
duelist.pantin A character for a game, whole A knight with a sword, a shield, a cape and a plume, with everything a game asks of a character: thirteen animations (idle, walk, run, jump, fall, land, a combo of three attacks, block, crouch, hurt, die), the legs on IK, springs, hit, hurt and guard boxes with their ranges, events and markers, two points, a draw order keyed while the shield is up, and a graph of thirteen states driven by eight parameters (flow.json): the combo goes on at an event, then at the end of a blow of the blade. Made through the MCP from its recipe (tools/make_duelist.py).
lamp.pantin Blend modes The light of the lamp is a white image in a slot that is additive and tinted warm: where it falls, the wall, the desk and the ball light up instead of being covered. Its arms reach for a target by inverse kinematics, and its head looks at the ball.
porthole.pantin A mask A circle on the window cuts the slots drawn after it, up to bubbles: the sea, two fish and the bubbles are seen only through the glass. Take the mask away (Masks in the panel of window) and the fish swim over the hull.
orbit.pantin Keys of the draw order A moon goes round a planet with a ring, the ring cut in a half behind it and a half in front. The animation has two keys of the draw order: from its start the moon is drawn behind the ring and the planet, from halfway in front of them. The row Draw order of the timeline shows them.
outfits.pantin Skins One character in two outfits. The default skin dresses it as a knight; the skin wizard has an attachment of the same name for the body, the hat and what it holds, a robe, a pointed hat and a staff, which a slot shows before the default one when that skin is chosen. The wizard has a beard on a bone, beard, that only the skin wizard has: the knight has no such bone. A skin is not keyed: a game chooses it. To see the wizard, choose it in Shown, in the section Skins at the bottom of the right panel (open when a project has several skins); pantin render --skin wizard draws it. The animation ends and starts with a spin among stars, where the card of the start screen and the picture of the site change the outfit, at each lap.
campfire.pantin A sequence of images The flame is six images, its own and five more, played one after the other at ten a second; the small flame plays the same images from the fourth, so the two never match.
cannon.pantin A point for a game A point, muzzle, at the mouth of the barrel: where the ball leaves and in which direction, which a game reads as the barrel turns and recoils. It draws nothing; the animation tells the game fire at the moment the flash shows.
robot.pantin A graph of states Two animations, idle and wave, and a graph (flow.json) that plays idle, waves when the trigger hello is fired and fades back. Open the Flow workspace and Play the graph.
flag.pantin A mesh The cloth is one image cut into a grid of 8 by 3 cells that hangs from a chain of four bones; each column follows the bone above it, and the columns near a joint are shared. Switch to Setup to see the triangles.
logo.pantin Strings that stretch The logo of pantin: ten flat pieces held by a hand; each of its three strings is a mesh whose top vertices are carried by the hand and its bottom ones by a wrist or the head, so that it stretches. docs/images/logo.gif is this project rendered by pantin render.
banner.pantin A linked mesh A banner on a pole, one image made a mesh of 9 by 2 cells on a chain of three bones, with a ripple keyed on its vertices. Halfway it shows its other side, back: another image of the same slot that bends as the mesh of cloth (Bends as in its panel), its vertices, triangles and weights, and takes its keys of vertices too. Change the mesh of cloth and the back changes with it.
turn.pantin Parameters that deform meshes A face, one image made a mesh of 8 by 8 cells on the bone head, and a parameter of Deform, turn, from -1 to 1, at rest at 0: at 1 its eyes, nose and mouth slide to the right, the middle of the face most and its edges not at all, at -1 to the left, and in between the shapes are blended. Open the tab Deform and move its slider; a game sets it (set_parameter, or a number of its graph named turn). Its animation only nods: a parameter is not keyed in time.
fish.pantin Keys of the vertices of a mesh The body is one image cut into 14 by 2 cells along a spine of four bones (make_mesh), and a wave runs down the spine. Its vertices have keys too: in the middle of the swim the ones of the head are moved out, most at the mouth, so the head swells as the fish breathes, and a bubble leaves it. In Animate, take Move on a vertex of the chosen mesh to key it.
tail.pantin Weights One image cut into triangles along a chain of four bones: each vertex near a joint is carried by the two bones there, each for its share, so the tail bends instead of breaking. Take the Weights tool (J) on the mesh to see and paint the share of the selected bone.
worm.pantin Bones spaced and stretched along a path An inchworm on a twig: six segments on a path constraint whose spacing is proportional (the chain spans that share of the path, each segment by its length) and turned by chain and scale (each segment lengthened to the next). Its keys move the position and the spacing: as the share grows the worm stretches out, its segments longer, then it draws itself together.
snake.pantin A path A closed trail that winds in and out on the sand, a path on the bone ground. The ten bones of the snake are laid along it by a path constraint, the head ahead, and its one key, position from 0 to 1, takes them once round; the body is a mesh, so it bends with them.

Inverse kinematics, and how to read it

A constraint turns bones by itself so that the end of a chain reaches a target, which is another bone. On the canvas a target has a pink ring around it, and a pink line joins it to the chain when it is out of reach. Select a bone and the panel on the right says, under Constraints, what holds it or what reaches for it.

Open planted and look at the timeline: one bone has keys, the hips. Yet the legs bend and stretch. Each leg is a chain of two bones, a thigh and a shin, held by a constraint whose target is a foot. The feet are not under the hips in the tree (they are roots), so they do not move when the hips do; the constraint then turns the thigh and the shin so that the shin still ends on the foot. Without constraints this needs a key on every leg bone at every moment, and the feet slide anyway.

Try it by hand: switch to Setup, take the Move tool, and drag hips or one of the feet. The legs follow at once. Then try to turn a thigh with the Rotate tool: nothing happens, because the constraint decides where it points.

To make one yourself: in Setup, select the last bone of a limb, and in the panel on the right, under Constraints, press Reach with its parent too. A target appears at the tip of the bone, already selected: drag it with the Move tool. The same panel changes the target, how much the constraint counts (Mix) and on which side the joint bends, whether the bones stretch or compress to reach, and how softly. lamp has two more: a chain that reaches, and its head, a constraint on one bone, which cannot reach anything and only points at the ball. grabber stretches, and its mix is keyed: in Animate mode, what the panel changes of a constraint is a key at the clock.

How the examples are made

Nothing here is drawn or typed in an editor. There are two ways, and one command makes them all again:

tools/build_examples.sh

By an agent. banner, campfire, cannon, cart, eyes, face, fish, grabber, jelly, lamp, orbit, outfits, pendulum, porthole, snake, turn and worm are made as an agent makes a project: through the tools of pantin mcp (docs/mcp.md). tools/make_recipes.py draws their images and writes, for each, a recipe in fixtures/recipes: the list of the calls, write_svg, add_bone, place_image, add_transform, set_draw_order, add_attachment, make_mesh, key_deform, add_path… A test of pantin-mcp (tests/examples.rs) makes each one through the protocol, on a new project, and saves it; it fails when an example is not what its recipe makes. The identifiers a tool makes are new each time: the test gives them again from the name of the example, so the files are the same each time.

From the format before. The others are each made from a folder of fixtures/legacy: a file of the format of one file, written by hand or by a script, and its SVG images, drawn by a script (tools/svg.py writes the SVG). The files beside those folders, bones only, are the examples the application carries in itself (File › Examples); tools/dress_examples.py reads each of them and writes it again, dressed, in a folder of its name. pantin migrate turns each source into a project; the springs, the keys of slots, the boxes and the graph, which the format before has no word for, are then added by tools/add_springs.py, tools/add_slot_keys.py, tools/add_boxes.py and tools/add_flow.py. The migration gives the same identifiers each time, and a test fails when an example is not what its source gives. The folders reach and walker are kept for the tests of the format only.

An SVG says it is twice the size it is shown at, so that a piece stays sharp when the canvas is zoomed in: the arm of the robot is shown 40 by 14 and drawn 80 by 28 pixels.

Reading a project from code

crates/pantin-format/examples/pose.rs is what a game does with a skeleton, in a few lines: it reads it, poses it at a time of an animation, and prints where each bone is.

cargo run -p pantin-format --example pose -- fixtures/legacy/stickman.pantin.json walk 0.5