Paint Engine

Caution: fresh paint

Paint Engine

Acrylic paint for the web. Please touch.

A JavaScript library, one file with no dependencies, that renders pointer input as acrylic paint: drags become brush strokes, taps become splatters. Use it on a canvas element, or let visitors paint on your page.

This whole page is wet. Drag anywhere to paint, tap to splatter.

How it paints

What each gesture paints

There are no brush settings: each mark is computed from the pointer's path and timestamps. Speed sets a stroke's width and dryness, the speed at release sets how it ends, and very short gestures become splatters. These six are painted from code with paintStroke().

Slow drag Full width: dense paint with a glossy edge.
Fast drag Narrower, and the paint dries into streaks and throws droplets.
Flick Released while still moving fast, the stroke carries on past the release point and tapers off.
Tap Press and release without moving: a splatter instead of a stroke.
Overlap Marks are partly transparent, so the paint gets darker where they cross.
Short drag A quick drag released while moving: a very short stroke that flicks off, with more spatter.

· each run uses new random seeds, so the marks differ. Pass a seed and a mark repeats exactly.

Specs

What's in the library

Demos

Integration examples

Each demo is one short HTML file. Open it, then view the source.

Get started

Usage

Download paint-engine.js or load it from jsDelivr, then call one of the three entry points.

A canvas you can paint on

<div id="art" style="height: 400px"></div>
<script src="https://cdn.jsdelivr.net/gh/alexandrewillame/paint-engine@v1.0.2/paint-engine.js"></script>
<script>
  const paint = PaintEngine.mount('#art');
  // paint.undo(), paint.clear(), paint.color = '#e5484d'
</script>

Let visitors paint your page

// at the end of <body>
PaintEngine.paintPage({
  palette: ['#EE4C9B', '#8B5FBF', '#F6A6C8'],
  layer: 'under',   // or 'over': blended above everything
});

Paint from code

const paint = PaintEngine.mount('#art', { input: false });
await PaintEngine.paintStroke(paint, [[40, 200], [300, 120], [560, 220]], {
  speed: 700, flick: true, color: '#17A6B5', animate: true,
});
paint.splat(480, 90);

npm, ES modules, TypeScript types, the full API and recipes are in the README.

In the wild

Used in production

Paint Engine was written for Creative Besties Club MTL, a Montréal club that runs creative workshops and social events. Their site uses it on every page: drags paint on the page, taps leave splatters, and the photos can be painted on too.

Screenshots from November 2026, in case the site has changed since. Members' photos blurred.

The Creative Besties Club MTL home page, with pink and purple paint strokes across it The same site on a phone, painted with a finger