Published
Edited
Mar 28, 2022
3 stars
Insert cell
Insert cell
GPU = require("gpu.js@2.15.2")
Insert cell
viewof krender = {
const krender = new GPU.GPU()
.createKernel(function(v) {
this.color(this.thread.x / 500, this.thread.y / 500, v);
})
.setOutput([500, 500])
.setGraphical(true);

return Object.assign(krender.canvas, { value: krender });
}
Insert cell
value = Math.sin(now / 500) ** 2
Insert cell
{
// these two operations must be done in sequence, otherwise…
krender(value);
return krender.getPixels();
}
Insert cell
// …this returns a black vector (all zeros)
krender.getPixels()
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