LIVING FRAME / ALPHA 0.1
Media, in motion.
A small, dependency-free WebGL2 library for images and video. Layer 25 effects, tune their character, and choose how they move.
Get started
Living Frame is distributed as native ES modules on GitHub. It is not published to npm yet. Copy the src/ directory into your project, or import from the hosted module below. Pin a Git commit and self-host for a stable production version.
import { createEffect, zoomIn } from
'https://mmaxence.github.io/prisma/src/index.js';
const fx = createEffect(document.querySelector('.media img'), {
effect: zoomIn,
trigger: 'loop',
duration: 10,
amount: 0.5
});Give the source a wrapper with explicit dimensions. Keep meaningful alternative text on the native image.
<div class="media" tabindex="0">
<img src="photo.jpg" alt="Coastal cliffs at sunset">
</div>
<style>
.media { position: relative; aspect-ratio: 4 / 3; overflow: hidden; }
.media img, .media video {
display: block; width: 100%; height: 100%; object-fit: cover;
}
</style>For selective imports, use src/core.js and individual src/effects/zoomIn.js modules. TypeScript declarations are included.
Compose effects
Layers render in order. Each layer transforms the previous result, using a single WebGL context. Reordering changes the look.
import { createEffect, zoomIn, noise } from './src/index.js';
const fx = createEffect(document.querySelector('img'), {
layers: [
{ effect: zoomIn, amount: 0.5, detail: 0.3 },
{ effect: noise, amount: 0.2, blendMode: 'soft-light' }
],
trigger: 'loop', duration: 10
});
fx.set({ duration: 12 });
// On unmount:
fx.destroy();Layer options: effect, amount, detail, blendMode, and enabled. An empty layer array displays the original. The playground supports six layers.
Blend modes: normal, multiply, screen, overlay, soft-light, hard-light, difference, exclusion, darken, and lighten. Use normal for camera movements to avoid a double-image blend with the source.
Motion & interaction
Motion is shared across the composition. duration sets one cycle, in seconds.
| Trigger | Behavior |
|---|---|
| loop | Continuous periodic animation, the default. |
| hover | Activate on pointer hover or keyboard focus. |
| click | Activate on click, tap, Enter, or Space. Make the wrapper focusable. |
| scroll | Map the wrapper’s passage through the viewport to progress. |
| still | Freeze a frame using phase, from 0 to 1. |
Practical camera motion
Slow zooms ease in both directions so the loop has no snap. Zoom in and zoom out start in opposite directions. They move the framing; they do not change video playback speed. Vibration plays a short burst between quiet holds. Pan and handheld use a protective crop to hide moving edges. Tilt-shift moves a band of focus with soft blur above and below it.
Start with 10 seconds for zoom, pan, and tilt-shift; 4 seconds for interval vibration. Intensity controls motion or blur strength. The second slider adjusts zoom range, burst length, travel distance, drift character, or focus-band width.
Effect reference
All effects accept images and video, support the five triggers, and preserve the original at zero intensity.
Prism
prismChromatic glass. Light separates along a breathing lens.
Liquid
liquidA slow, refractive current moving through the image.
Ripple
rippleConcentric waves radiate from your point of contact.
Fluted glass
flutedSculptural glass ribs with moving refraction and dispersion.
Halftone
halftoneA living print screen, with ink shaped by luminance.
Vortex
vortexA localized gravity well twisting the surface of the image.
Dither
ditherA four-tone ordered print, with a slow exposure sweep.
Pixelate
pixelateA breathing mosaic that resolves from chunky pixels into detail.
RGB split
rgbSplitThree color plates slip out of register, then find each other again.
Glass impact
glassBreakAn impact sends sharp cracks across the surface. The fractured glass stays in place.
Duotone
duotoneCobalt shadows and warm paper highlights, with a rolling tonal wash.
Scanlines
scanlinesPhosphor lines and a traveling refresh band, like a quiet analog display.
Retro TV
retroTvCurved tube edges, phosphor lines, soft color bleed, and a moving refresh band.
Code rain
matrixGreen procedural glyphs reveal the image beneath looping columns of falling code.
VHS tape
vhsColor bleed, tracking noise, and a traveling tape tear with adjustable wear.
Signal glitch
glitchShort horizontal tears and displaced color blocks that settle back into the source.
ASCII terminal
asciiLuminance becomes a field of terminal characters under a slow phosphor sweep.
False color
thermalA moving violet-to-gold false-color palette driven by image brightness.
Film noise
noiseFine, independently changing grain with luminance-sensitive strength.
Slow zoom in
zoomInA slow push in with an eased return. A seamless breathing loop for editorial images.
Slow zoom out
zoomOutStart close, pull back, and ease into the next loop.
Interval vibration
vibrationA brief damped shake between quiet holds, with a safe crop to hide the edges.
Gentle pan
panA slow left-to-right camera drift with a soft return and protected edges.
Handheld
handheldSubtle camera movement for stills, with periodic organic sway instead of random jitter.
Animated tilt-shift
tiltShiftA moving plane of focus with soft, graduated blur above and below the subject.
API reference
createEffect(media, options)
Pass a connected HTMLImageElement or HTMLVideoElement and either an effect or a layers array.
| Option | Default | Range / meaning |
|---|---|---|
| amount | 0.8 | 0–1, intensity |
| detail | 0.5 | 0–1, effect-specific character |
| trigger | loop | loop, hover, click, scroll, still |
| duration | 6 | 0.2–120 seconds |
| phase | 0 | 0–1, still-frame position |
| blendMode | normal | Composition blend operation |
| pixelRatio | Device ratio, capped at 1.5 | 0.5–2, rendering scale |
| onError | None | Receives renderer failures |
Controller
- set(partialOptions)
- Update settings in place, including the layer stack.
- pause() / play()
- Freeze or resume effect motion. Video playback is independent.
- trigger()
- Fire a click envelope in click mode.
- reset()
- Clear a glass impact and reset motion state.
- preview(layer) / preview(null)
- Temporarily append an effect, then restore the committed composition.
- destroy()
- Release the canvas, observers, listeners, and GPU objects; restore native media. Safe to call twice.
- canvas / stats
- The output canvas and diagnostics: frames, cpuMs, width, height, active, fallback, programs, intermediateTextures. CPU submission time is not GPU frame time.
Images & video
Use same-origin media, local uploads, or CORS-enabled remote files. Set crossorigin="anonymous" before a remote source URL, and ensure the source server permits access. YouTube embeds do not expose usable video frames.
<video muted loop playsinline autoplay src="clip.webm"></video>Play and pause the video through its own API. The playground’s uploads stay in your browser and are never sent to a server. Glass impact creates persistent cracks on an intact image; click again for a new impact or call reset to clear it.
Performance lab: measurements, methodology and device benchmark
fx.stats.textureUploads counts source uploads; sourceTextureAllocations counts source storage allocations over the controller lifetime. CPU timings exclude asynchronous GPU execution.
Accessibility & performance
Native media stays in the DOM. Unsupported WebGL2, shader compilation failures, and texture errors reveal the native source and invoke onError. Context restoration rebuilds the renderer.
Reduced-motion preferences freeze shader time. Hidden documents and offscreen effects stop rendering. Static images render on demand; video textures update with decoded frames. The title animations also respect reduced motion and visibility.
The complete media runtime and 25 effect modules are under 12 KB gzip when concatenated, excluding demo assets, fonts, and the demo-only Living Type title effects. Each extra layer adds a render pass. Start with a low pixel ratio and a short stack on mobile; tilt-shift uses multiple texture samples.
License & contributing
Living Frame uses the MIT license, copyright 2026 Maxence Mauduit. See asset notices for fonts, generated sample images, and the Living Type demo modules.
To develop locally, clone the repository, run npm run dev, then npm test. Read the effect authoring guide to add a shader.