Exports
A kind of file the plugin writes an animation as.
It appears in the export window beside GIF and Sprite sheet whenever the picture has an animation, and uses that window's preview, scale and frame range. Its fields are asked for there, each time.
exports: [{
key: 'strip', name: 'Vertical strip', ending: '-strip.png',
about: 'Every picture of the animation, one under another in a PNG.',
fields: [{ key: 'gap', label: 'Gap', low: 0, high: 32, step: 1, usual: 0 }],
async write(work) {
const gap = Number(work.settings.gap) || 0, strip = document.createElement('canvas');
strip.width = work.w;
strip.height = work.count * work.h + (work.count - 1) * gap;
const pen = strip.getContext('2d')!;
await work.each((canvas, index) => pen.drawImage(canvas, 0, index * (work.h + gap)));
return new Promise((resolve) => strip.toBlob((blob) => resolve(blob!), 'image/png'));
},
}],
from rassam import canvas, png_bytes, slider
@plugin.export('Vertical strip', ending='-strip.png', about='Every picture of the animation, one under another in a PNG.',
fields=[slider('gap', 'Gap', 0, 32, 0)])
async def strip(work, app):
gap = int(work.settings.gap)
sheet = canvas(work.w, work.count * work.h + (work.count - 1) * gap)
pen = sheet.getContext('2d')
await work.each(lambda picture, index: pen.drawImage(picture, 0, index * (work.h + gap)))
return png_bytes(sheet) # bytes, a text, or a file of the program's own
On work | What it is |
|---|---|
name | The file's name, without its ending. |
settings | The export's own fields, as set. |
count, w, h | How many pictures, and the size of each. |
ms | How long each picture shows. |
each(use) | Draws every picture in turn and hands each to use(canvas, index). Await it. |
say(text) | A line in the export window. |
write gives the file as a Blob; a Python export gives bytes (png_bytes(sheet) for a picture) or a text. ending is added to the name the user typed, so several files belong in a zip.