Skip to main content

Plugins

Klint's plugin system extends the core library with specialized functionality for common creative coding tasks. Plugins are imported from @shopify/klint/plugins.

Installation​

Plugins are included in the main Klint package:

npm install @shopify/klint

Import plugins as needed:

import { FontParser, Sprites, CatmullRom, Delaunay, MatterPhysics, Projector } from '@shopify/klint/plugins';

Available Plugins​

PluginDescriptionDocs
FontParserLoad TTF fonts, convert text to vector paths or point arraysFontParser
SpritesSprite sheet loading, frame drawing, and animationSprites
CatmullRomSmooth curve interpolation through control pointsCatmullRom
DelaunayDelaunay triangulation for point setsDelaunay
MatterPhysics2D physics via Matter.js (bodies, constraints, collisions)MatterPhysics
Projector3D to 2D projection for pseudo-3D canvas drawingProjector

Creating Your Own​

Plugins are static utility classes that manage their own state and accept KlintContext only for drawing. See Creating Custom Plugins for the architecture guide and templates.

Type Imports​

import type {
FontPathsResult,
FontPointsResult,
FontTextOptions,
Triangle,
SpriteConfig,
Spritesheet,
Point3D,
ProjectedPoint,
Transform3D,
} from '@shopify/klint/plugins';

Best Practices​

  • Load assets during initialization — fonts, sprites, and physics setup belong in useEffect or preload, not in draw
  • Cache results — pre-compute expensive operations outside the draw loop
  • Clean up on unmount — call .clear() or .destroy() in your cleanup function
useEffect(() => {
return () => {
Sprites.clear();
MatterPhysics.destroy();
};
}, []);