diff --git a/docs/API.md b/docs/API.md index d2d8d06..06fc6b2 100644 --- a/docs/API.md +++ b/docs/API.md @@ -9,10 +9,14 @@ Its main functionalities are: Here's how the capture works: -1. the artwork must register a default exporter function -2. this function must return a data URL representing the display image +1. the artwork must register a default exporter function (`default: true`) +2. this function must resolve to a data URL representing the display image 3. the artwork must call `$o.capture()` once it's ready for capture +An artwork can register other exports than the default one. You can use those to let viewers download images from your artwork instead of implementing a hotkey system (such as *hit `d` to download a PNG*.) The parent of your iframe, which we call *the host*, will know which exports have been registered and show buttons allowing viewers to trigger those exports. + +Additionally, an artwork can register a custom thumbnail export. This is particularly interesting for animated GIFs. For thumb exports we strongly enforce an aspect ratio of 1:1 and strongly recommend a max resolution of 400x400px. Use `thumb: true`. + Example: ```js @@ -30,6 +34,10 @@ $o.registerExport( { mime: 'image/png', resolution: { x: 1024, y: 1024 }, default: true }, pngExport ); +$o.registerExport( + { mime: 'image/gif', resolution: { x: 400, y: 400 }, thumb: true }, + animatedGifExport +); async function pngExport({ resolution: { x: x, y: y } }) { draw(x, y); @@ -59,5 +67,6 @@ async function pngExport({ resolution: { x: x, y: y } }) { | ` args.resolution` | `{ x: int, y: int }` | default resolution | | ` args.aspectRatio` (optional) | `float` | if provided this exporter will be only export respecting this aspect ratio | | ` args.default` (optional) | `bool` | if `true` this exporter will be used for the capture | +| ` args.thumb` (optional) | `bool` | if `true` this exporter will be used for the thumbnail | | ` exportFn` | `({resolution: {x, y}}) => Promise(dataURL)` | an async function returning a dataURL | diff --git a/index.html b/index.html index fd09c2f..ce39e82 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@