npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

thin-plate-spline

v0.1.0

Published

Thin-plate-spline image warping for canvas/OffscreenCanvas — arbitrary point-correspondence warps, rendered as affine-textured triangles. Zero dependencies.

Readme

thin-plate-spline

Thin-plate-spline (TPS) image warping for canvas / OffscreenCanvas. Give it an arbitrary set of source → destination point correspondences (≥3, non-collinear) and it warps an image to match, rendered as a coarse grid of affine-textured triangles — canvas 2D can only do affine transforms, so a full nonlinear TPS warp is approximated locally per triangle.

Zero runtime dependencies. Works in a Worker or the main thread.

Extracted from pravoobi/try-on's virtual try-on garment warp, where it maps a flat garment photo's shoulder/waist/hem anchors onto a detected body pose — but the API itself has no notion of garments, bodies, or any fixed anchor count. It's just point-correspondence image warping.

Install

npm install thin-plate-spline

Usage

import { renderGarmentWarp, ThinPlateSpline, type Point } from 'thin-plate-spline';

// Low-level: just the point-correspondence math.
const src: Point[] = [[0, 0], [100, 0], [0, 100], [100, 100]];
const dst: Point[] = [[10, 5], [120, 0], [0, 90], [110, 100]];
const tps = new ThinPlateSpline(src, dst);
tps.eval([50, 50]); // -> warped [x, y]

// High-level: warp an actual image onto a canvas given the same correspondences.
const canvas = renderGarmentWarp(
  imageBitmap,       // CanvasImageSource with width/height
  srcAnchors,        // Point[] in the image's own pixel space
  dstAnchors,        // Point[] in output pixel space
  outputWidth,
  outputHeight,
);
// canvas is an OffscreenCanvas — draw it, transfer it, or read its pixels.

renderGarmentWarp options

renderGarmentWarp(
  image, srcAnchors, dstAnchors, outputWidth, outputHeight,
  grid = { cols: 16, rows: 24 },  // warp mesh resolution — higher = smoother, slower
  marginXFrac = 0.6,               // how far past the anchors' bbox to sample, as a
  marginYFrac = 0.15,               // fraction of the bbox's own width/height
)

Keep the margin modest: pixels far outside the control points' convex hull are where TPS extrapolation gets unstable and can visibly fold.

API

  • ThinPlateSplinenew ThinPlateSpline(src: Point[], dst: Point[]), .eval(p: Point): Point. Throws if src/dst differ in length, have fewer than 3 points, or are collinear (a singular system).
  • renderGarmentWarp(image, srcAnchors, dstAnchors, outputWidth, outputHeight, grid?, marginXFrac?, marginYFrac?)OffscreenCanvas.
  • Point = readonly [number, number].
  • WarpGridOptions = { cols: number; rows: number }, and DEFAULT_WARP_GRID = { cols: 16, rows: 24 }.

License

MIT