Public
Edited
Apr 24, 2023
Insert cell
Insert cell
canvas.toDataURL();
Insert cell
canvas = {
const context = DOM.context2d(width*scale, height*scale);
for (let x = 0; x < width; x++) {
for (let z = 0; z < height; z++) {
context.fillStyle = `#${eggs_hex_str[x][z]}`;
context.fillRect(x*scale, z*scale, 1*scale, 1*scale);
}
}
return context.canvas;
}
Insert cell
eggs_int = eggs_hex_str.map(x => parseInt(x, 16));
Insert cell
eggs_hex_str = {
let eggs = [];
for (let x = 0; x < width; x++) {
eggs[x] = [];
for (let z = 0; z < height; z++) {
let pos = (x + z * 21) * 6;
eggs[x][z] = hex.substring(pos, pos + 6);
}
}
return eggs;
}
Insert cell
Insert cell
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