Pts
Pts is a TypeScript and JavaScript library for visualization and creative coding.
Get started at ptsjs.org. Please try it, file issues, and send feedback to @williamngan.
Usage
Browser script
Download pts.js or pts.min.js from the dist directory, or use a CDN such as cdnjs, jsDelivr, or unpkg.
<script src="path/to/pts.min.js"></script>The classic script exposes the library as globalThis.Pts.
Package
Install the package:
npm install ptsPts is ESM-first and also provides a CommonJS compatibility entry.
import { CanvasSpace, Group, Line, Pt } from "pts";const { CanvasSpace, Group, Line, Pt } = require("pts");Starter projects and integrations:
Read the guides and explore the demos.
Development
The maintained build environment is Node 24.18 or newer in the Node 24 line. The published library is also exercised on current Node 20 and 22 releases.
pnpm install --frozen-lockfile
pnpm exec playwright install chromium
pnpm checkUseful individual commands include:
pnpm build
pnpm typecheck
pnpm test
pnpm test:browser
pnpm test:integrations
pnpm check:package
pnpm format
pnpm format:watchpnpm check validates formatting, linting, types, unit tests, deterministic documentation, documentation and bundle behavior in a real browser, reproducible artifacts, the packed package, ESM and CommonJS resolution, declarations, and tree-shaking. Its packed-package integration suite also builds and runs the maintained React, Vue, skia-canvas, and single-file vanilla fixtures in test/integrations.
Prettier defines the repository's formatting rules. Run pnpm format once or keep pnpm format:watch running to reformat maintained source files as they change. The recommended VS Code extension and workspace settings also enable Prettier on save, while pnpm check rejects unformatted changes in CI.
Generate documentation
The documentation generator uses TypeDoc's Node API to rebuild the custom static documentation JSON from explicit source entry points. It also generates docs.md, guide.md, and llms.txt for agents and other clients that cannot navigate the documentation SPA:
pnpm run docsGenerated documentation is checked in. pnpm check:docs regenerates it in memory, reports stale or extra files, and exercises navigation, search, anchors, and responsive layouts in Chromium.
Contributing
Issues and small pull requests are welcome. For larger changes, please start a discussion with @williamngan.
License
Apache License 2.0. See LICENSE.
Copyright © 2017-present William Ngan and contributors.
