Skip to content
blotter

API

API reference

Every export of blotter.ts and blotter.ts/materials: the classes you build with, the utilities around them, the GLSL snippets, and the types that tie them together.

Two entry points. The core classes, the shaders namespace and the utilities come from blotter.ts; the five bundled effects come from blotter.ts/materials. Both are ES modules with types, and both tree-shake.

import { Blotter, Text, Material, ShaderMaterial, shaders } from "blotter.ts";
import { ChannelSplitMaterial, FliesMaterial } from "blotter.ts/materials";

Core #

Blotter
The orchestrator: packs its texts into one atlas, renders them through the material in a single draw call, and hands each text its own canvas.
Text
A string and the styles to draw it with. One per word or title you want rendered.
Material
A fragment shader with named uniforms. The plain Material draws text unchanged; subclasses and options make effects.
ShaderMaterial
A Material for a one-off shader: the mainImage string first, everything else second.
RenderScope
Per-text output: the canvas for one text, and the place to set uniforms for that text alone.
UniformInterface
The live handle for one uniform: a type, a validated value, and an update event its owner listens to.

Plumbing #

Mapping
The packed atlas layout: which rectangle of the shared texture each text occupies. Built by Blotter; exported for custom pipelines.
MappingMaterial
The built, renderable form of a Material for one Mapping: the composed THREE.ShaderMaterial and the per-text uniform interfaces.

Functions #

filterTexts
Normalises a text, an array of texts, or nothing into an array of valid Text instances.
pixelRatio
The device pixel ratio Blotter will draw at, or 1 outside a browser.
isWebGLSupported
Whether this browser can create a WebGL context.

Materials #

ChannelSplitMaterial
Lets the red, green and blue channels drift apart along an angle, with an optional motion blur.
FliesMaterial
Redraws the text as a swarm of points that can dodge a position you feed it.
LiquidDistortMaterial
Bends the text through a slow field of noise, like tiles under water.
RollingDistortMaterial
Rolls a wave across the text with finer noise underneath, like a failing television.
SlidingDoorMaterial
Cuts the text into panes that slide out of their frames and back, one after another.

Shaders #

shaders is a namespace of GLSL snippets exported as strings: blending, blinnPhongSpecular, easing, gamma, inf, lineMath, map, noise, noise2d, noise3d, noise4d, pi, random. GLSL helpers as strings, ready to interpolate at the top of a mainImage. The bundled materials are built from them.

Types #

The types page lists every exported type and interface: TextProperties, TextEvents, TextBounds, RenderScopeEvents, BlotterEvents, BlotterOptions, UniformType, Vec2, Vec3, Vec4, UniformValueMap, UniformDescriptor, UniformMap, UniformInterfaceMap, MaterialEvents, MaterialOptions.