Published
Edited
Mar 26, 2021
Insert cell
Insert cell
Insert cell
Insert cell
vertexShader = createShader(gl, gl.VERTEX_SHADER, `
precision highp float;
attribute vec4 aPos;

void main() {
float x1 = aPos.x + 0.001; // Slowly increasing the x position
if (aPos.x > 1.0){x1 -= 2.0;} // Wrapping around
gl_Position = vec4(x1, aPos.yzw); // Setting the new position
gl_PointSize = 2.0; // And the size - set it small when dealing with large numbers of points
}
`)
Insert cell
fragShader = createShader(gl, gl.FRAGMENT_SHADER, `
precision highp float;
void main() {
gl_FragColor = vec4(0.4, 0.1, 0.6, 1.0); // Pick your favourite colour :)
}
`)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
draw() + now // This repeatedly calls draw() updating our canvas.
Insert cell
Insert cell
Insert cell
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