Published
Edited
Aug 27, 2021
Insert cell
Insert cell
Insert cell
zCanvas = import('https://unpkg.com/zcanvas@4.2.2/zcanvas.js?module')
Insert cell
{
let container = html``;
let cnv = new zCanvas.canvas({
height: 200,
width: 200,
debug: false,
parentElement: container,
animate: true,
smoothing: false, // pixel art ahoy
fps: 60,
preventEventBubbling: true,
})


var bgWidth = 200, bgHeight = 200;
var bgSprite = new zCanvas.sprite({
width: bgWidth,
height: bgHeight,
bitmap: url
});

cnv.addChild( bgSprite );
yield container
}
Insert cell
coverart = {
let img = new Image();
img.crossOrigin = '*';
img.src = await FileAttachment("New Project.png").url();
await new Promise(resolve => img.addEventListener('load', resolve));
let ctx = DOM.canvas(img.width, img.height).getContext('2d');
ctx.drawImage(img, 0, 0);
return ctx.canvas;
}
Insert cell
url = coverart.toDataURL()

Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more