Settings and exports

Export a PNG, a video loop or portable JSON settings, and load settings in the generator.

Export formats

FormatUse it for
PNGA rendered still, such as a background, social image, or poster frame.
MP4A video loop for use in a site, presentation, or video editor. The browser must support the selected video encoder.
JSONAn editable, versioned settings document you can keep or import back into the generator.

For PNG, use Current frame to capture the preview or choose a larger size to render the first frame. For MP4, pick a size, frame rate, and codec, then choose Full loop. Use Settings · JSON to download the file you can import later.

Portable settings

Settings documents use the schema identifier visualmodo.gradient/1. The envelope carries a preset ID, a positive revision number, and the full rendering parameters in params. Validate the document when you read it to catch missing or out-of-range values.

Read and write portable settings
import { getPreset } from "@visualmodo/gradients/catalog";
import { settingsDocument, serializeSettingsDocument, parseSettingsDocument } from "@visualmodo/gradients/settings";

const preset = getPreset("copper");
if (!preset) throw new Error("Preset unavailable");

const document = settingsDocument(preset.id, 1, preset.config);
const json = serializeSettingsDocument(document);
const restored = parseSettingsDocument(json);

Parameter reference

Start with a preset or use kindDefaults(id) from the SDK. Adjust the parameters supported by that material. The library metadata exposes the current schema, material IDs, and defaults.

FieldsAccepted values
kindA registered material ID, such as chrome for Liquid Alloys
colors, backgroundTwo to six palette colors and one background, in six-digit HEX
speed, drift0 to 2 each. Drift is optional.
loopSeconds4 to 30 seconds
scale0.25 to 4
warp, blur, grain0 to 1 each
seedInteger from 0 to 65,535
interaction.pointer, interaction.scroll0 to 1 each
dither.enabledBoolean
dither.cell, dither.levelsInteger cell size from 1 to 32 and color levels from 2 to 32
dither.softnessOptional value from 0 to 1

Browser export helpers

The SDK renders PNG and video to Blob values in the browser. Export helpers use WebGL2, with WebCodecs and the optional mediabunny dependency for video. Pass an abort signal and use the progress callback to report progress or cancel a long export.

Export a still or loop
import { exportStill } from "@visualmodo/gradients/export/png";
import { exportLoop } from "@visualmodo/gradients/export/video";

const controller = new AbortController();
const reportProgress = (progress: number) => console.log(progress);
const png = await exportStill(restored.params, 3840, 2160, controller.signal, reportProgress);
const mp4 = await exportLoop(restored.params, controller.signal, reportProgress, {
  width: 1920,
  height: 1080,
  fps: 30,
  codec: "avc",
});