MCPcopy Create free account
hub / github.com/microsoft/SandDance / renderToImageURL

Function renderToImageURL

docs/app/js/sanddance-app.js:142254–142258  ·  view source on GitHub ↗

* Produce an image URL for the visualization. Depending on the type * parameter, the generated URL contains data for either a PNG or SVG image. * The URL can be used (for example) to download images of the visualization. * This method is asynchronous, returning a Promise instance. * @param {stri

(type, scaleFactor)

Source from the content-addressed store, hash-verified

142252 * The 'canvas' and 'png' types are synonyms for a PNG image.
142253 * @return {Promise} - A promise that resolves to an image URL.
142254 */ async function renderToImageURL(type, scaleFactor) {
142255 if (type !== (0, _vegaScenegraph.RenderType).Canvas && type !== (0, _vegaScenegraph.RenderType).SVG && type !== (0, _vegaScenegraph.RenderType).PNG) (0, _vegaUtil.error)("Unrecognized image type: " + type);
142256 const r = await renderHeadless(this, type, scaleFactor);
142257 return type === (0, _vegaScenegraph.RenderType).SVG ? toBlobURL(r.svg(), "image/svg+xml") : r.canvas().toDataURL("image/png");
142258}
142259function toBlobURL(data2, mime) {
142260 const blob = new Blob([
142261 data2

Callers

nothing calls this directly

Calls 2

renderHeadlessFunction · 0.70
toBlobURLFunction · 0.70

Tested by

no test coverage detected