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 {
Bezier,
Polyline,
FontParser,
Sprites,
CatmullRom,
Delaunay,
Projector,
} from '@shopify/klint/plugins';

Available Plugins​

PluginDescriptionDocs
BezierConstruct, analyze, offset, intersect, and render quadratic/cubic curvesBezier
PolylineBuild, smooth, simplify, analyze, and render multi-segment pathsPolyline
FontParserLoad TTF, OTF, WOFF, and WOFF2 fonts; convert text to vector paths or point arraysFontParser
SpritesSprite sheet loading, frame drawing, and animationSprites
CatmullRomSmooth curve interpolation through control pointsCatmullRom
DelaunayDelaunay triangulation, earcut polygon triangulation with holes, VoronoiDelaunay
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 {
BezierPoint,
BBox,
FontPathsResult,
FontPointsResult,
FontTextOptions,
Triangle,
SpriteConfig,
Spritesheet,
Point3D,
ProjectedPoint,
Transform3D,
} from '@shopify/klint/plugins';

Best Practices​

  • Load assets during initialization — fonts and sprites 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();
};
}, []);