Published
Edited
Apr 13, 2020
Also listed in…
TIL
Insert cell
Insert cell
canvasA = {
const ctx = DOM.context2d(w, h);
ctx.strokeStyle = 'steelblue';
ctx.lineWidth = 8;
ctx.strokeRect(w / 4, h / 4, w / 2, h / 2);
return ctx.canvas;
}
Insert cell
Insert cell
canvasB = {
const ctx = DOM.context2d(w, h);
ctx.strokeStyle = 'red';
ctx.lineWidth = 8;
ctx.strokeRect(w / 8, h / 8, w / 4, (3 * h) / 4);
return ctx.canvas;
}
Insert cell
Insert cell
canvasC = {
const ctx = DOM.context2d(w, h);
// drawImage respects the transparency
ctx.drawImage(canvasA, 0, 0, w, h);
ctx.drawImage(canvasB, 0, 0, w, h);
return ctx.canvas;
}
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