Published
Edited
Mar 4, 2020
5 stars
Hello, PGLiteINSEE ParquetHello, apcachDruidJS workerHello, OrbitWord Tour: 40k words and their friendsHello, spectral.jsHello, petite-vueHello, @thi.ng/grid-iteratorsHello, thumbhashHello, SwissGLHello, QOI (and glitches)Hello, orbHello, cosmographHello, TabulatorUsing d3.blur with PlotMath.cbrtHello debounceColorcetHello, gliiHello, Open MeteoHello, PyWaveletsHello, typesenseHello, libgifHello, kmeans-engineHappy anniversary, Project Gutenberg!Hello, fflateHello, ArchieML!Hello, d3-bboxCollideHello, jsgeoda!Hello, EDTF!Hello, protovis!Hello, placekeyHello, fuse.jsHello, Reorder.jsHello, shadow DOMjszipHello, procedural-glHello, qhullHello, genetic-jsDruidJSHello, Tippy.jsHello, paintWorkletBig πHello, AutoencoderHello, Shakespearean UUIDsHello, ccwt.jsHello, constrainautorHello, talismanHello, polygon-offsetHello p-queueHello async-poolHello rollup-plugin-asciiHello, algebra.jsHello, pixi.jsHello, d3-renderHello zip/unzipCumulative Wikipedia DonationsHTML <details>
regl texture
Hello, npyjsHello protobufHello, pencil touchHello, LOESSHello html2canvaslegra mapscolor2cssHello, ecsy2D point distributionsHello, delatinThe gpu.js loopDijkstra’s shortest-path treeHello nojacko/Dijkstras-jsHello, tcort/dijkstrajsHello, lambdabaa/dijkstraHello, gpu.js v2Hello jsqrHello qrcodeHello SharedArrayBufferHello GamePad APIHello vtk.jsHello nd4jsHello BiofabricTravelling with a self-organizing mapHello glitchHello UMAP-jsHello pandemoniumHello iocaneHello JSON-editorHello d3-griddingHello mljs/knnWorkerHello lalolibImage to GPU.jsImage to blink.jsTissot's indicatrixVega projectionsHello WebCLGLUsing d3-inertia with observableVideo contouring 3ngraph: pagerank, louvain…Union-FindPerceptron (simple statistics)mljsHello h3-jsEmoji FlagsHello, poisson-disk-sampling
Insert cell
Insert cell
Insert cell
viewof regl = {
const pixelRatio = Math.min(1.5, devicePixelRatio);

const canvas = DOM.canvas(
Math.floor(width * pixelRatio),
Math.floor(height * pixelRatio)
);
canvas.style.width = `${width}px`;
canvas.style.height = `${height}px`;
const regl = createREGL({
canvas,
pixelRatio,
// This can also dramatically increase performance:
attributes: { antialias: false }
});
return Object.assign(canvas, { value: regl });
}
Insert cell
draw({ zoom })
Insert cell
draw = createDrawCommand(regl)
Insert cell
createDrawCommand = regl =>
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;
uniform vec2 aspectRatio;
uniform float zoom;
varying vec2 uv;
void main () {
uv = 0.5 + 0.5 * vec2(position) * aspectRatio;
gl_Position = vec4(position, 0, 1.0 / zoom);
}`,

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

depth: { enable: false },

uniforms: {
texture: regl.texture({ data: image, flipY: true }),
aspectRatio: ctx => {
const ar = ctx.viewportWidth / ctx.viewportHeight;
return ar > 1 ? [ar, 1] : [1, 1 / ar];
},
zoom: regl.prop('zoom')
},

count: 3
})
Insert cell
image = new Promise(resolve => {
const im = new Image();
im.crossOrigin = "anonymous";
im.src =
"https://raw.githubusercontent.com/regl-project/regl/master/example/assets/peppers.png";
im.onload = () => resolve(Object.assign(im, { style: "max-width:200px" }));
})
Insert cell
createREGL = require("regl")
Insert cell
height = 500
Insert cell
import { slider } from "@jashkenas/inputs"
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