Building a Deterministic Stick Figure Animation Pipeline with a Skill
This article explains how to replace unpredictable generative video workflows with a reusable local skill package for stick figure animation. It covers the core rigging rules, single-joint interpolation with fixed bone lengths, incremental scene-level edits, and a local headless rendering and encoding pipeline, along with a cost comparison and the boundaries where this approach makes sense.
1. The Starting Problem: Why Animation Production Often Depends on Luck
Beyond pure code animation, a common industry practice is to hand prompts to a generative video solution and let the model decide the visuals. The fatal flaw of this path is not image quality but uncertainty: generating the same description twice can change character proportions, shot transitions, and character appearance; changing a single line of dialogue often means re-rolling the entire segment, so cost rises linearly with the number of revisions.
The pure code route is the opposite. A stick figure’s torso and limbs are essentially a few polylines, and the frame is determined by math rather than by sampling. As long as the skeleton baseline and motion rules are fixed, the output is reproducible. A typical counter-example from early practice is telling: without constraints, the model was left to improvise, the skeleton proportions had no mathematical baseline, the arm lines were skewed, and the figure’s shape distorted immediately after a shot change. The root cause of such problems is a “missing baseline,” not “a model that is not strong enough.”
2. The Core Idea: Package the Rules into a Reusable Skill
The solution is to distill domain knowledge into a local skill package instead of repeating the same instructions in every conversation. A minimal viable skill package usually contains three parts:
- A documentation file that states the applicable scenarios, inputs and outputs, and calling conventions;
- A skeleton rendering library that computes coordinates from joint angles and draws them;
- A recording and export script that drives a local browser to capture frames one by one and hands them to an encoder.
The value of the skill package lies in front-loading constraints. The model does not need to understand human aesthetics; it only needs to follow the interface: read fixed bone length parameters, compute coordinates from given angles, and advance interpolation frame by frame. Once the rules are written into the skill, all subsequent generations automatically inherit the same baseline.
A schematic definition of the skeleton baseline is as follows (it only expresses structure and is not a specific product interface):
const RIG = {bone: { torso: 120, upperArm: 60, foreArm: 55, thigh: 70, shin: 65 },joint: { shoulder: 0, elbow: 0, hip: 0, knee: 0 },view: { scale: 1.0, centerX: 0, centerY: 0 }};function solveJoint(origin, length, angleDeg) {const rad = angleDeg * Math.PI / 180;return { x: origin.x + length * Math.cos(rad), y: origin.y + length * Math.sin(rad) };}
3. Keeping Motion from Breaking: Single-Joint Interpolation and Fixed Bone Lengths
Two rules are key to stability. First, interpolate the angle of only one joint per frame, avoiding simultaneous changes across multiple joints that cause pose jumps. Second, lock the bone lengths and view parameters, so coordinates are derived only from angles. This way, changing the motion or the shot does not change body proportions, and character consistency turns from a “probability problem” into a “structural guarantee.”
In engineering terms, it helps to split the animation into “acts,” where each act declares its start and end angles and duration, and the render loop advances by frame number:
function frameAt(t) {const k = clamp(t / duration, 0, 1);const eased = k * k * (3 - 2 * k); // Smooth transition to avoid a mechanical feelreturn lerpAngle(startAngle, endAngle, eased);}
Combined with a fixed frame rate (such as 60 FPS) and a subtitle track, bilingual Chinese-English text can be displayed at the bottom of the frame, ensuring that information delivery does not depend on audio.
4. Handling Requirement Changes Fast: Local Incremental Edits Instead of Full Regeneration
The biggest benefit of code animation is localized changes. To add a floating text effect in the second act or a frame rate and cost badge in the third act, you only adjust the rendering branch of the corresponding act, and the protagonist’s skeleton data is completely unaffected. Such changes are usually done in a very short time and require no re-sampling of any frame.
By comparison, with a generative solution, changing one line of dialogue means paying to re-roll, and the character may drift or become inconsistent. Deterministic production replaces “uncertain re-rolling” with “predictable building,” which is a fundamental difference in cost structure.
5. The Export Pipeline: Local Headless Rendering Plus Local Encoding
The export stage does not require cloud graphics compute. The approach is to have the script drive a local headless browser to take screenshots frame by frame, then hand the frame sequence to a local encoder to compose the video. A finished 15-second video at 60 FPS is about 900 frames; measured export time is about 52 seconds, and the output is about 0.81 MB at 720P. The cumulative cost of the entire pipeline (including multiple rounds of revisions and export tests) is on the order of about 0.54 CNY, and a scale of 30 videos per month still stays in the tens-of-CNY range.
To scale up, rendering and encoding can be split into a pipeline: object storage holds the frame sequences and finished videos, a message queue distributes rendering tasks, a container platform hosts headless browser instances, and logging and monitoring services track failed frames and elapsed time.
6. Cost Comparison and Applicability Boundaries
| Solution | 15 seconds per video | 30 videos/month | Change one line of dialogue | Character consistency |
|---|---|---|---|---|
| Skill package code flow | About 0.54 CNY | About 16 CNY | Edit code and re-export in about 52 seconds | Structurally stable |
| Common generative solution A | About 0.75 CNY | About 22 CNY | Re-roll and be charged again | Prone to shot drift |
| Common generative solution B | About 2.88 CNY | About 86 CNY | Re-roll and be charged again | Prone to character collapse |
The boundaries need to be stated just as clearly: teams that pursue realistic live-action quality, or that have no development environment locally at all, are not suited to this route; its advantage lies in stylized, structurable animation content that requires frequent revisions. If you are worn down by credits and re-rolling, consider building an animation skill package locally and locking uncertainty inside code.
