Unlisted
Edited
Mar 6, 2023
Insert cell
Insert cell
Insert cell
Insert cell
typeof window.OffscreenCanvas
Insert cell
{
let canvas
// 😔 Error on Safari => intercept by Observable as a variable not defined
if (typeof window.OffscreenCanvas !== "undefined") {
canvas = new window.OffscreenCanvas(...size);
} else {
canvas = document.createElement("canvas");
canvas.width = canvas.height = size;
}
const ctx = canvas.getContext("2d");

return ctx.canvas
}
Insert cell
Insert cell
typeof HTMLCanvasElement.prototype.transferControlToOffscreen
Insert cell
{
let canvas
if (typeof HTMLCanvasElement.prototype.transferControlToOffscreen !== "undefined") {
// 😔 Error on Safari => intercept by Observable as a variable not defined
canvas = new window.OffscreenCanvas(...size);
} else {
canvas = document.createElement("canvas");
canvas.width = canvas.height = size;
}
const ctx = canvas.getContext("2d");

return ctx.canvas
}
Insert cell
size = [150,150]
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