Published
Edited
Mar 22, 2021
Insert cell
Insert cell
createREGL = require("regl")
Insert cell
canvas = html`<canvas width="960" height="300">`
Insert cell
// Calling the regl module with no arguments creates a full screen canvas and
// WebGL context, and then uses this context to initialize a new REGL instance
regl = createREGL({canvas: canvas})
Insert cell
image = FileAttachment("spotlight-poi2.png").image()
Insert cell
texture = regl.texture({
data: image,
})
Insert cell
{
const drawImage = regl({
frag: `
precision mediump float;
uniform sampler2D texture;
varying vec2 uv;
void main () {
gl_FragColor = texture2D(texture, uv);
}`,

vert: `
precision mediump float;
attribute vec2 position;
varying vec2 uv;
void main () {
uv = vec2(position);
gl_Position = vec4(1.0 - 2.0 * position, 0, 1);
}`,

attributes: {
position: [-2, 0, 0, -2, 2, 2]
},

uniforms: {
texture: texture
},

count: 3
})
drawImage()
}
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