Appearance
Export and import scripts / Hm05Script / Api
Interface: Api
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
document | readonly | any | the whole document as saved (JSON, read-only) |
image | public | object | - |
image.create | public | (width, height) => OffscreenCanvas | an empty transparent canvas |
image.pack | public | (pictures, options?) => PackResult | a sprite sheet: every picture on one canvas |
image.pixels | public | (picture) => ImageData | the RGBA pixels |
image.resize | public | (picture, width, height, options?) => OffscreenCanvas | a scaled copy |
image.toBlob | public | (picture, type?, quality?) => Promise<Blob> | encode: "image/png" (default), "image/jpeg", "image/webp" |
image.trim | public | <T>(picture, options?) => T extends ScriptImage ? ScriptImage & object : object | cut transparent edges off; x / y = where the cut starts in the source (a ScriptImage keeps its origin right) |
math | public | object | - |
math.apply | public | (m, point) => Point | - |
math.compose | public | (t) => Mat | - |
math.decompose | public | (m) => Transform | - |
math.invert | public | (m) => Mat | - |
math.multiply | public | (m, n) => Mat | multiply(m, n) = n first, then m |
math.transformBounds | public | (b, m) => Bounds | - |
math.unionBounds | public | (a, b) => Bounds | null | - |
options | readonly | Record<string, any> | your options' values (also the second argument of run) |
output | public | object | - |
output.json | public | (path, value, indent?) => Promise<void> | JSON.stringify (indent default 2; 0 = one line) |
output.list | public | () => string[] | the paths written so far |
output.write | public | (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. |
render | public | object | - |
render.asset | public | (assetId) => Promise<ScriptImage> | an imported picture of the Library (image.assetId) at its size |
render.frame | public | (options?) => Promise<ScriptImage> | a frame as a picture |
render.object | public | (object, options?) => Promise<ScriptImage> | one object alone (an ObjectInfo from objects() / find()) |
render.picture | public | (imageId, options?) => Promise<ScriptImage> | a bitmap layer's picture (image.imageId), all sub-layers |
settings | readonly | ExportSettings | the Export dialog's fields |
stage | readonly | Stage | - |
Methods
bounds()
ts
bounds(query?): Bounds | null;the art's box at a frame (timeline space); null = empty
Parameters
| Parameter | Type |
|---|---|
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
| Parameter | Type |
|---|---|
nameOrId | string |
query? | FrameQuery & LayerChoice |
Returns
ObjectInfo | null
flatten()
ts
flatten(objects): ObjectInfo[];a tree of objects as one list (parents before their children)
Parameters
| Parameter | Type |
|---|---|
objects | ObjectInfo[] |
Returns
frames()
ts
frames(): FrameInfo[];the frames the Export dialog chose, in order
Returns
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
| Parameter | Type |
|---|---|
name | string |
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
| Parameter | Type |
|---|---|
query? | FrameQuery & LayerChoice |
Returns
log()
ts
log(...values): void;shown in the Export dialog's log (console.log does the same)
Parameters
| Parameter | Type |
|---|---|
...values | unknown[] |
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
| Parameter | Type |
|---|---|
query? | FrameQuery & object |
Returns
markerTypes()
ts
markerTypes(): MarkerTypeInfo[];every component kind of the document
Returns
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
| Parameter | Type |
|---|---|
query? | FrameQuery & LayerChoice & object |
Returns
progress()
ts
progress(done, total): void;the Export button shows done / total
Parameters
| Parameter | Type |
|---|---|
done | number |
total | number |
Returns
void
symbol()
ts
symbol(idOrName): SymbolInfo | null;a symbol by id or name
Parameters
| Parameter | Type |
|---|---|
idOrName | string |
Returns
SymbolInfo | null
symbols()
ts
symbols(): SymbolInfo[];every Library symbol
Returns
timeline()
ts
timeline(target?): TimelineInfo;scenes, labels and layers of a timeline
Parameters
| Parameter | Type |
|---|---|
target? | Target |