Public
Edited
Apr 22, 2023
Insert cell
Insert cell
{
const boxSize = 100;
const cx1 = 10;
const cy1 = 10;
const cx2 = 15;
const cy2 = 18;
const cx3 = 8;
const cy3 = 18;
return html`<svg width="400" viewBox="0 0 ${boxSize} ${boxSize}" style="border: 2px solid black">
${[
...(function* () {
for (let i = 0; i < boxSize; i++) {
for (let j = 0; j < boxSize; j++) {
yield `<rect x="${i}" y="${j}" width="1" height="1" fill="black" opacity="${
(1 +
(noise.simplex2(i / 40, j / 40) +
noise.simplex2(i / 10, j / 10) * 0.5 +
noise.simplex2(i / 2, j / 2) * 0.2)) *
0.5 *
0.3
}" />`;
}
}
})()
].join("\n")}
<path d="M${cx1},${cy1} L${cx2},${cy2} L${cx3},${cy3}" stroke="grey" stroke-width="0.1" />
</svg>`;
}
Insert cell
noise.simplex2(0, 2)
Insert cell
noise = {
const noise = new Noise();
noise.seed(Math.random());
return noise;
}
Insert cell
Noise = require("noisejs").catch(() => window.Noise)
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more