Public
Edited
Feb 5, 2018
4 forks
Importers
17 stars
Insert cell
Insert cell
Insert cell
Insert cell
p5 = require("https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.js")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
sketch = function( sketch ) {
var x = 100;
var y = 100;

sketch.setup = function() {
sketch.createCanvas(container.width, container.height);
};

sketch.draw = function() {
sketch.background(0);
sketch.fill(100, 100, 200);
sketch.rect(x,y,50,50);
};
}
Insert cell
Insert cell
{
sketch => {
// ...
// in setup function
const canvas = sketch.createCanvas(container.width, container.height);
canvas.parent(container.id);
// ...
}
}
Insert cell
Insert cell
Insert cell
myP5 = {
// Resets div container
p5Container.innerHTML = "";
// Reinstantiate the p5 with the sketch
return new p5(sketch, p5Container);
}
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