Skip to content

Export and import scripts / Hm05Script / Api

Interface: Api ​

Properties ​

PropertyModifierTypeDescription
documentreadonlyanythe whole document as saved (JSON, read-only)
imagepublicobject-
image.createpublic(width, height) => OffscreenCanvasan empty transparent canvas
image.packpublic(pictures, options?) => PackResulta sprite sheet: every picture on one canvas
image.pixelspublic(picture) => ImageDatathe RGBA pixels
image.resizepublic(picture, width, height, options?) => OffscreenCanvasa scaled copy
image.toBlobpublic(picture, type?, quality?) => Promise<Blob>encode: "image/png" (default), "image/jpeg", "image/webp"
image.trimpublic<T>(picture, options?) => T extends ScriptImage ? ScriptImage & object : objectcut transparent edges off; x / y = where the cut starts in the source (a ScriptImage keeps its origin right)
mathpublicobject-
math.applypublic(m, point) => Point-
math.composepublic(t) => Mat-
math.decomposepublic(m) => Transform-
math.invertpublic(m) => Mat-
math.multiplypublic(m, n) => Matmultiply(m, n) = n first, then m
math.transformBoundspublic(b, m) => Bounds-
math.unionBoundspublic(a, b) => Bounds | null-
optionsreadonlyRecord<string, any>your options' values (also the second argument of run)
outputpublicobject-
output.jsonpublic(path, value, indent?) => Promise<void>JSON.stringify (indent default 2; 0 = one line)
output.listpublic() => string[]the paths written so far
output.writepublic(path, data) => Promise<void>write a file ("folder/name.ext"). Canvases / pictures become PNG; objects are not accepted — use json. Writing the same path again replaces it.
renderpublicobject-
render.assetpublic(assetId) => Promise<ScriptImage>an imported picture of the Library (image.assetId) at its size
render.framepublic(options?) => Promise<ScriptImage>a frame as a picture
render.objectpublic(object, options?) => Promise<ScriptImage>one object alone (an ObjectInfo from objects() / find())
render.picturepublic(imageId, options?) => Promise<ScriptImage>a bitmap layer's picture (image.imageId), all sub-layers
settingsreadonlyExportSettingsthe Export dialog's fields
stagereadonlyStage-

Methods ​

bounds() ​

ts
bounds(query?): Bounds | null;

the art's box at a frame (timeline space); null = empty

Parameters ​

ParameterType
query?FrameQuery & LayerChoice

Returns ​

Bounds | null


exportBounds() ​

ts
exportBounds(): Bounds | null;

one box around every frame of the export (what region "export" uses)

Returns ​

Bounds | null


find() ​

ts
find(nameOrId, query?): ObjectInfo | null;

the first object (any depth) whose instance name, id or key is nameOrId; null = none at that frame

Parameters ​

ParameterType
nameOrIdstring
query?FrameQuery & LayerChoice

Returns ​

ObjectInfo | null


flatten() ​

ts
flatten(objects): ObjectInfo[];

a tree of objects as one list (parents before their children)

Parameters ​

ParameterType
objectsObjectInfo[]

Returns ​

ObjectInfo[]


frames() ​

ts
frames(): FrameInfo[];

the frames the Export dialog chose, in order

Returns ​

FrameInfo[]


layer() ​

ts
layer(name, query?): LayerState | null;

one layer (or its object layer's object) by name — names are unique per timeline; null = none

Parameters ​

ParameterType
namestring
query?FrameQuery

Returns ​

LayerState | null


layers() ​

ts
layers(query?): LayerState[];

the layers at a frame (top → bottom) with alpha, blend mode, filters, layer move and bounds

Parameters ​

ParameterType
query?FrameQuery & LayerChoice

Returns ​

LayerState[]


log() ​

ts
log(...values): void;

shown in the Export dialog's log (console.log does the same)

Parameters ​

ParameterType
...valuesunknown[]

Returns ​

void


markers() ​

ts
markers(query?): MarkerInfo[];

the markers at a frame: those on the timeline's component layers and (deep, default true) those inside the symbol instances shown, mapped onto this timeline

Parameters ​

ParameterType
query?FrameQuery & object

Returns ​

MarkerInfo[]


markerTypes() ​

ts
markerTypes(): MarkerTypeInfo[];

every component kind of the document

Returns ​

MarkerTypeInfo[]


objects() ​

ts
objects(query?): ObjectInfo[];

the objects at a frame, in paint order (bottom first). Mask layers only with layers: "all", a list naming them, or layer.

Parameters ​

ParameterType
query?FrameQuery & LayerChoice & object

Returns ​

ObjectInfo[]


progress() ​

ts
progress(done, total): void;

the Export button shows done / total

Parameters ​

ParameterType
donenumber
totalnumber

Returns ​

void


symbol() ​

ts
symbol(idOrName): SymbolInfo | null;

a symbol by id or name

Parameters ​

ParameterType
idOrNamestring

Returns ​

SymbolInfo | null


symbols() ​

ts
symbols(): SymbolInfo[];

every Library symbol

Returns ​

SymbolInfo[]


timeline() ​

ts
timeline(target?): TimelineInfo;

scenes, labels and layers of a timeline

Parameters ​

ParameterType
target?Target

Returns ​

TimelineInfo

HereSplash — 2D animation for the web