Settings and exports
Export a PNG, a video loop or portable JSON settings, and load settings in the generator.
Export formats
| Format | Use it for |
|---|---|
| PNG | A rendered still, such as a background, social image, or poster frame. |
| MP4 | A video loop for use in a site, presentation, or video editor. The browser must support the selected video encoder. |
| JSON | An 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.
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.
| Fields | Accepted values |
|---|---|
| kind | A registered material ID, such as chrome for Liquid Alloys |
| colors, background | Two to six palette colors and one background, in six-digit HEX |
| speed, drift | 0 to 2 each. Drift is optional. |
| loopSeconds | 4 to 30 seconds |
| scale | 0.25 to 4 |
| warp, blur, grain | 0 to 1 each |
| seed | Integer from 0 to 65,535 |
| interaction.pointer, interaction.scroll | 0 to 1 each |
| dither.enabled | Boolean |
| dither.cell, dither.levels | Integer cell size from 1 to 32 and color levels from 2 to 32 |
| dither.softness | Optional value from 0 to 1 |
Generator links
Use ?preset=copper to start from a published preset. To pass edited values, use settings with the validated params from the document. Use URLSearchParams to encode the payload.
const url = new URL("https://app.visualmodo.com/create/gradients");
url.searchParams.set("preset", restored.preset);
url.searchParams.set("settings", JSON.stringify(restored.params));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.
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",
});