Public
Edited
May 14
Importers
Insert cell
Insert cell
p5Version = "0.9.0" // 1.11.5
Insert cell
p5SoundVersion = "0.9.0" // 0.9.0
Insert cell
sketch = {
const p5 = await require(`p5@${p5Version}`).then(async (p5) => {
// newer versions of p5 sound don't work with es6 modules
await require(`p5@${p5SoundVersion}/lib/addons/p5.sound.min.js`);
return p5;
});
return function* (_sketch) {
const parent = DOM.element("div");
yield parent;
const instance = new p5((p) => _sketch(p, p5), parent);
try {
while (true) yield parent;
} finally {
instance.remove();
}
};
}
Insert cell
Insert cell
sketch((p, p5) => {
const context = {};
p.setup = () => {
context.canvas = p.createCanvas(300, 150);
};
p.draw = () => {
p.background(0);
};
})
Insert cell
import("https://unpkg.com/p5@0.9.0/lib/addons/p5.sound.min.js")
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