SHADERERA®Video made in code · v0.1.2PluginsAgentsGitHub ↗
← PluginsTypographycomponent · v0.1.0 · MIT
text-glyph-morphOfficial · by Shaderera

Glyph morph

One glyph outline or word morphing into another: contours resampled by arc length, paired outer to outer and hole to hole, a contour with no partner grown from a point, the in-between a pure function of k.

Add it to a filmOr ask your agent
“Use the shaderera-plugins skill to add text-glyph-morph to this film and wire it in, then run check and show me a still.”
Type
component · Typography
Version
0.1.0 · published
Licence
MIT
npm
No packages
Tags
morph, tween, glyph, outlines, letters, shape morph, kinetic typography, vector
Source on GitHub ↗
READMEtext-glyph-morph

How to
use it.

One glyph outline or word morphing into another, letter by letter or as a whole.

README.mdexample
import { lettersOf, morphLetters, morphOf, shapeOf, tracePath } from './type/glyph-morph.ts'import { loadFont } from './type/outlines.ts'// in open: shapes and morphs are worked out onceconst font = await loadFont(host, 'assets/fonts/IBMPlexSans-Medium.ttf')const glyph = morphOf(shapeOf(font, 'A'), shapeOf(font, 'g'))const word = morphLetters(lettersOf(font, 'Shape'), lettersOf(font, 'Morph'))// in render(t): k runs 0 to 1 (clamped; ease it as the film likes), here from t 1 over 0.6 sctx.beginPath()tracePath(ctx, glyph.at((t - 1) / 0.6).rings, { x: 400, y: 700, size: 500 })word.forEach((m, i) => {  // each letter 0.05 s after the one before  tracePath(ctx, m.at((t - 1 - i * 0.05) / 0.6).rings, { x: 80, y: 900, size: 160 })})ctx.fill('nonzero')

Units are ems, y up, the pen at 0 and the baseline at 0, as glyphOutlines gives them; tracePath places them at x, baseline y and size px per em, y flipped. shape.rings are Float32Arrays of x, y pairs, every one points long (160 by default), to draw however a film draws: a Canvas2D path, a line strip, points for particles.

How it pairs: contours are resampled evenly by arc length; outers pair with outers and holes with holes, nearest centroid first; each partner is wound the same way and turned so its points lie nearest. A contour with no partner grows from, or shrinks to, a point at its centroid, so an "O" into an "I" closes its hole. morphLetters pairs letter i with letter i; the longer word's extra letters grow from points. Two shapes must have the same points. shapeOf and lettersOf take glyphOutlines' kerning, letterSpacing, tolerance and variation, so the same glyph in two weights of a variable font ({ wght: 400 } and { wght: 700 }) morphs too.

morphOf does the pairing once; at(k) is a lerp, so the same k always gives the same rings. Pairing is by position and size, not by meaning: a morph between unlike glyphs is a plausible in-between, not a designed one. Needs text-glyph-outlines, which add brings with it.

More in Typography05 plugins

More in Typography