Skip to content

textmode.export.js / TextmodeExportAPI

Interface: TextmodeExportAPI

Runtime export helpers that createExportPlugin attaches to the Textmodifier instance.

Properties

PropertyTypeDescription
exportOverlayExportOverlayControllerController for managing the export overlay UI visibility at runtime.

Methods

saveCanvas()

ts
saveCanvas(options?): Promise<void>;

Saves the current canvas content to an image file ('png' by default).

Parameters

ParameterTypeDescription
options?ImageExportOptionsExport options.

Returns

Promise<void>

Example

ts
await t.saveCanvas({ format: 'png', filename: 'frame-001' });

copyCanvas()

ts
copyCanvas(options?): Promise<void>;

Copies the current canvas to the user's clipboard as an image.

Parameters

ParameterTypeDescription
options?ImageExportOptionsExport options.

Returns

Promise<void>

Example

ts
await t.copyCanvas({ format: 'png' });

saveSVG()

ts
saveSVG(options?): void;

Downloads the selected layer as an SVG file.

Parameters

ParameterTypeDescription
options?SVGExportOptionsExport options.

Returns

void

Example

ts
t.saveSVG({ filename: 'poster', layer: t.layers.base, includeBackgroundRectangles: true });

saveStrings()

ts
saveStrings(options?): void;

Downloads the selected layer's text content as a plain-text file.

Parameters

ParameterTypeDescription
options?TXTExportOptionsExport options.

Returns

void

Example

ts
t.saveStrings({ filename: 'frame', layer: t.layers.base, preserveTrailingSpaces: true });

toSVG()

ts
toSVG(options?): string;

Generates SVG markup for the selected layer.

Parameters

ParameterTypeDescription
options?SVGExportOptionsExport options.

Returns

string

The SVG content representing the artwork.

Example

ts
const svg = t.toSVG({ layer: t.layers.base, drawMode: 'stroke', strokeWidth: 1.5 });

toString()

ts
toString(options?): string;

Produces the selected layer's text content as a string.

Parameters

ParameterTypeDescription
options?TXTExportOptionsExport options.

Returns

string

The textual representation of the artwork.

Example

ts
const text = t.toString({ layer: t.layers.base, preserveTrailingSpaces: false });

toJSON()

ts
toJSON(options?): TextmodeDocumentJSON;

Produces the selected layer or layer stack as structured JSON data.

Parameters

ParameterTypeDescription
options?JSONExportOptionsExport options.

Returns

TextmodeDocumentJSON

The JSON document representing the selected layer or layer stack.

Example

ts
const layer = t.toJSON({ layer: t.layers.base, colorMode: 'hex', includeMetadata: true });
const stack = t.toJSON({ target: 'all' });

toJSONString()

ts
toJSONString(options?): string;

Produces the selected layer or layer stack as a JSON string.

Parameters

ParameterTypeDescription
options?JSONExportOptionsExport options.

Returns

string

Serialized JSON string for the selected layer or layer stack.

Example

ts
const json = t.toJSONString({ layer: t.layers.base, pretty: false, colorMode: 'hex' });
const stackJson = t.toJSONString({ target: 'all' });

saveJSON()

ts
saveJSON(options?): void;

Downloads the selected layer or layer stack as a JSON file.

Parameters

ParameterTypeDescription
options?JSONExportOptionsExport options.

Returns

void

Example

ts
t.saveJSON({ filename: 'frame', layer: t.layers.base, pretty: true });
t.saveJSON({ filename: 'stack', target: 'all' });

saveGIF()

ts
saveGIF(options?): Promise<void>;

Records an animated GIF and saves it to disk.

Parameters

ParameterTypeDescription
options?GIFExportOptionsExport options.

Returns

Promise<void>

Example

ts
await t.saveGIF({ frameCount: 120, frameRate: 30, filename: 'loop' });

saveWEBM()

ts
saveWEBM(options?): Promise<void>;

Captures a WEBM video and saves it to disk.

Parameters

ParameterTypeDescription
options?VideoExportOptionsExport options.

Returns

Promise<void>

Example

ts
await t.saveWEBM({ frameCount: 240, frameRate: 60, filename: 'capture' });