Run Pts.js from the command line.

Generate images and SVGs directly without a browser.

$ npx pts-cli interpolate.mjs

pts-output/interpolate-<render-id>.png
Geom.interpolate example output Nested white and navy squares twist inward on a transparent background.

Simple interface

Export one function with Pts drawing code, and run npx pts-cli file.mjs.

Alternatively, install globally via npm i -g pts-cli and run ptsjs file.mjs.

Pts.js code sample

interpolate.mjs
export default function run({ Pts, space, form }) {
  const { Geom, Num, Rectangle } = Pts;

  function interpolate(points, t, depth = 0) {
    if (depth > 20) return;
    t = Num.boundValue(t, 0, 1);
    const next = points.map((p, i) =>
      Geom.interpolate(p, points[(i + 1) % points.length], t),
    );
    form.fillOnly(depth % 2 === 0 ? "#fff" : "#123").polygon(next);
    interpolate(next, t + 0.02, depth + 1);
  }

  space.add(() => {
    const size = space.size.$multiply(0.5).minValue().value;
    const rect = Rectangle.corners([
      space.center.$subtract(size),
      space.center.$add(size),
    ]);
    const t = 0.15;
    interpolate(rect, t);
  });
}

Render it from command line

$ npx pts-cli interpolate.mjs \
  --out interpolate.png \
  --out interpolate.svg

$ npx pts-cli interpolate.mjs \
  --size 1200x630 \
  --out card.png

Size and background are optional. They default to 800 × 600 and transparent.

You can also use the same file in a browser

import { mountScene } from
  "pts-cli/browser";
import run from "./interpolate.mjs";

await mountScene(run, {
  target: "#pt"
});

Features

Repeatable renders
Control the frame, input, parameters, and random seed when a stable result matters.
CLI and API
Use the ptsjs command or call renderScene() from Node.
Structured results
Request JSON output for build scripts, automation, and agents.
More
See command options and additional documentations in the README.