Public
Edited
Aug 25, 2023
2 forks
Importers
17 stars
Insert cell
Insert cell
Insert cell
Insert cell
createDrawLines = require("https://unpkg.com/regl-gpu-lines@2.4.1")
Insert cell
Insert cell
Insert cell
renderBasicExample = {
regl1.poll();
drawBasicLines(basicLineData);
}
Insert cell
basicLineData = {
const p = [[-0.6, -0.2], [-0.5, -0.1], [-0.4, -0.8], [-0.3, 0.6], [0.5, 0.6]];
const lineData = {
vertexCount: p.length,
vertexAttributes: { point: regl1.buffer(p) },
endpointCount: 2,
endpointAttributes: {
point: regl1.buffer([p.slice(0, 3), p.slice(-3).reverse()])
}
};
invalidation.then(() => {
lineData.vertexAttributes.point.destroy();
lineData.endpointAttributes.point.destroy();
});
return lineData;
}
Insert cell
drawBasicLines = createDrawLines(regl1, {
vert: `
precision highp float;

#pragma lines: attribute vec2 point;
#pragma lines: position = projectPoint(point);
#pragma lines: width = getWidth();

uniform float width;
vec4 projectPoint(vec2 point) { return vec4(point, 0, 1);}
float getWidth () { return width; }`,
frag: `
precision lowp float;
void main () {
gl_FragColor = vec4(vec3(0.5), 1);
}`,
uniforms: {
width: (ctx, props) => ctx.pixelRatio * 25
}
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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