Running with Data Wolves

A hand-drawn run-cycle animation, rebuilt on an explicit data model

The wolves began as drawings: six sheets of run cycles traced with a digitizing pen in early 2019, 227 frames in all. On the page they are gesture, weight and timing, a pack loping across the screen. In the files they are something else entirely: 3.4 million coordinates in two unit systems, laid out in six incompatible ways, with nothing recording where a frame starts, how big a wolf is, which way it runs, or whether its cycle loops.

Thirty frames from one source sheet, registered to about 1 px and played as a seamless loop. 32 KB gzipped.

An animator reads a sheet and sees frames. A computer reads the same sheet and sees a pile of paths. Everything a viewer notices about the animation lives in the gap between those two readings: shimmering lines, a wolf that drifts and jerks at the restart, line weights that change from one wolf to the next, pages that stutter in some browsers.

The 2019 version closed that gap by hand, one frame at a time, in a vector editor. In 2026 we closed it with a data model. The art didn't change. What changed was that every property the animator knew by eye became a value the code could read.

  • 227 frames across six cycles, rebuilt from the untouched source sheets with one command in about four minutes
  • Payload down from 1.06 MB to 205 KB gzipped
  • Frame placement error down from 10–24 px to 0.7–4.3 px rms
  • The jump where the loop restarts down from as much as 65 px to 1–7 px
  • One unit system, one scale, one direction and one line weight across every cycle

Two Readings of the Same Sheet

What the artist seesWhat the file contains
A wolf in a frameSome paths near each other, sometimes grouped, sometimes not
A clean lineAbout 400 points per stroke, mostly hand tremor
Wolves of a similar sizeSheets drawn in millimetres and pixels, at scales 20× apart
A wolf standing in its cellA position set by eye, off by 10–24 px
A cycle that loopsA sequence that ends wherever the drawing stopped
A strideNothing at all

None of this is a flaw in the drawings. Drawing is supposed to be loose. But an animation is played by software, and software needs the things an artist leaves implicit to be written down.

The 2019 Approach: Data Fixed by Hand

The first site played each cycle as a CSS sprite: one very wide SVG strip per cycle, slid behind a fixed window with steps(). To get there, every frame was ungrouped, simplified, nudged into its cell and resized by hand.

That made the animation work, but the only data model was "a very wide picture". Frame width, frame count and duration lived in three places (the file name, the CSS width and the steps() count), typed by hand and checked by eye. Registration was guessed by comparing each frame to its neighbour, which is a different pose by definition. Millimetre-based strips drew a thicker line than pixel-based ones. And because frames existed only as positions inside a strip up to 67,000 px wide, the work couldn't be reused with any other technique, and some browsers struggled to rasterize it at all.

How We Modelled It

  1. A Coordinate System Before Anything Else

    Three sheets used millimetres and three used pixels, so stroke-width: 1px meant 1 px in one file and 3.78 px in another. Every path is flattened into absolute pixel coordinates by multiplying its nested transforms from the root down. From that point on, a number means the same thing in every file, which is what lets every later tolerance be a fixed distance rather than a guess.

    Before: originals/cassanova-run.svg Frame 1: 25 paths, 18,272 numbers, up to 8 decimals, in mm, 1 transform above each path
    <svg width="1146.5278mm" height="1093.6112mm" viewBox="0 0 1146.5278 1093.6112" …>
     <g inkscape:groupmode="layer" id="layer2">
      <g id="g15038" transform="translate(0,-0.52916667)">
       <path inkscape:connector-curvature="0" id="path83" d="m 49.130447,52.974194 c -0.128953,0.515806 -0.14908,1.071867 -0.386855,1.547416 -0.05767,0.115337 -0.271516,-0.05767 -0.386853,0 -0.163113,0.08156 -0.3053,0.223742 -0.386855,0.386855 …" style="fill:none;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
       <!-- …more paths -->
      </g>
    After: processed/cassanova-run.svg Frame 1: 1 path, 2,030 numbers, whole pixels, no transforms beyond its cell
    <svg width="20274" height="342" viewBox="0 0 20274 342" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
     <path id="f01" transform="translate(0 0)" d="M246 108c-6 19 4-20 11-16 4 1-23 29-25 27-3-4 18-25 20-25 3 2-15 16-17 15-4-4 17-12 23-14 12-5 48-13 49-10 1 4-26 7-35 9-2 0-4 1-7 1 0 0-2 1-2 1 18-7 40-17 60-17 2 0-2 0-4 0-3 0-5 0-8 1-9 1-19 1-28 3-1 0-12 0-11-1 11-10 90-3 107-3 10 0 18-4 28-5 1 0-2 0-3 0-2 0-4 0-6 0-6 0-17-5-21-5-2 1 2 4 4 5 3 3 …" />
     <!-- f02 … f31 -->
    </svg>
  2. Deciding What a Frame Is

    This was the central modelling problem. No two sheets agreed: one used named groups in order, two used unnamed groups, one ran in reverse on alternate rows, and two had no groups at all, just hundreds of loose paths. We stopped trusting the file structure and defined a frame by geometry: the ink inside one cell of a grid.

    Weighted k-means finds the column and row centres, and a least-squares fit through them gives each sheet's exact origin and pitch. Every stroke joins the cell nearest its ink-weighted centre. Cells with too little ink, and strokes off the grid, are reported as strays rather than silently kept. Getting this robust mattered: a single stroke 3,300 units below one page collapsed the first fit from 31 frames to 20, until outlying ink was excluded from the fit.

    Two wolves per frame, stored as 675 loose paths with no groups at all. Every frame was recovered from the position of its ink.
  3. Size and Direction as Data, Not Styling

    In 2019, size and direction were CSS: a scale() here, a rotateY(180deg) there. Now each cycle is scaled so its median frame is 280 px tall (the median, so one raised tail doesn't shrink the whole wolf), and the one cycle drawn running left is mirrored. Scale factors ranged from 0.6× to 12.9×, which shows how far apart the drawings really were.

    Drawn running left and mirrored in the data, so it runs with the pack without a CSS transform.
  4. Position as a Measurement

    An artist places a frame where it looks right. The model needs a number. A run cycle repeats its poses once per stride, so two frames in the same pose should sit in the same place, and any offset between them is placement error. We compared every pair of frames using distance fields, scored on the closest 60% of points so swinging legs don't dominate, weighted each pair by how similar its poses are, and solved for one offset per frame with weighted least squares. Cycles with close repeats now register to about 1 px.

    Fifty-nine frames whose placement scatter dropped from 8–14 px to under 1 px.
  5. Timing and Looping as Properties of the Cycle

    Registration leaves a by-product: a matrix of pose distances between every pair of frames. That turns questions the artist answered by feel into values. Does the last frame step back to the first like any other step? How many frames is a stride? Where should the loop end? Four cycles loop cleanly. One has a gap at the seam, and one goes from a walk into a run, so it never fully closes. For each, the analysis proposed the frame to end on. The final loop ends were then chosen by eye, frame by frame, and all six matched the frame the numbers had picked. Stride lengths also exposed that the 2019 wolves ran at different paces, from 0.5 s to 0.9 s per stride.

    A walk into a run that never fully closes. It ends on frame 29, the end the loop analysis proposed and the one chosen by eye.
  6. Keeping the Gesture, Removing the Noise

    The pen recorded tremor as stair-step jitter, and the line's character had to survive its removal. Each stroke is cleaned on its own: resampled by arc length, smoothed with its endpoints pinned so strokes don't shrink, refit as cubic Béziers within 2 px, and rounded to whole pixels. Coordinates dropped from 3.4 million to 214,000. Those tolerances only mean something because step 1 put every sheet in the same units.

    Before: the raw pen trace 140 points in a 64 × 35 px window, magnified 9.4×
    A magnified stretch of hand-drawn wolf outline. The line steps back and forth in small stair-step jitters, with 140 pen points marked.
    After: smoothed and refit 21 curve points in the same window, on whole pixels
    The same stretch of outline after cleanup: smooth curves with 21 points marked.

    The de-jitter step itself. Each stroke has already been resampled to an even spacing, so a Gaussian kernel can average out tremor along the line. Open strokes are padded by reflecting them through their endpoints, which keeps each stroke its full length instead of letting it shrink at the ends:

    def smooth(P, sigma, closed):
        """Gaussian smoothing in sample units. Open strokes are padded by point
        reflection so endpoints stay fixed and the stroke does not shrink."""
        if sigma <= 0 or len(P) < 3:
            return P
        r = int(3 * sigma)
        k = np.exp(-0.5 * (np.arange(-r, r + 1) / sigma) ** 2); k /= k.sum()
        if closed:
            Q = np.vstack([P[-r - 1:-1], P, P[1:r + 1]]) if len(P) > r + 1 else P
        else:
            r = min(r, len(P) - 1)
            k = np.exp(-0.5 * (np.arange(-r, r + 1) / sigma) ** 2); k /= k.sum()
            Q = np.vstack([2 * P[0] - P[r:0:-1], P, 2 * P[-1] - P[-2:-r - 2:-1]])
        out = np.column_stack([np.convolve(Q[:, i], k, mode='valid') for i in (0, 1)])
        if not closed:
            out[0], out[-1] = P[0], P[-1]
        return out
  7. One Record per Cycle

    Each cycle ends up as one JSON file: cell size, frame rate, stride, loop verdict, the placement correction applied, and one path per frame relative to its cell. Cell size is derived from the registered content plus a margin, so nothing spills past an edge and nothing is typed into a file name. Everything the 2019 version kept in an animator's head or scattered across CSS is now in one place.

What the Model Made Possible

Once the data was explicit, the rest became bookkeeping on known quantities. The same records drive a canvas player, inline SVG and a drop-in replacement for the 2019 sprite strips. Because each frame is its own path, a player draws only the visible frame, and no browser has to rasterize a giant image: canvas went from 33 to 61 fps with 1,000 wolves on screen. Behaviour can be decided per cycle (loop end, pace, reduced motion) because the facts it depends on are recorded. Style is a parameter too: strokes use currentColor at one width, so any colour scheme comes from the same files.

Results

  • Every visible flaw (shimmer, drift, the hitch at the loop, uneven lines, slow playback) traced back to an unstated fact in the data, and each fix was a calculation, not a correction by eye
  • The source drawings stay untouched; the pipeline reads them and never edits them
  • Every run writes a report with frame counts, sizes, residual error and loop verdicts, so a change to any tolerance is measurable

Talk to us about building something like it.

The Original Project