drawDots = newRegl({
frag: `
precision mediump float;
uniform vec4 color;
void main () {
float r = 0.0, delta = 0.0, alpha = 1.0;
vec2 cxy = 2.0 * gl_PointCoord - 1.0;
r = dot(cxy, cxy);
if (r > 1.0) {
discard;
}
gl_FragColor = color * alpha;
}`,
vert: `
precision mediump float;
attribute vec2 position;
attribute float pointWidth;
uniform float stageWidth;
uniform float stageHeight;
vec2 normalizeCoords(vec2 position) {
float x = position[0];
float y = position[1];
return vec2(
2.0 * ((x / stageWidth) - 0.5),
-(2.0 * ((y / stageHeight) - 0.5)));
}
void main () {
gl_PointSize = pointWidth;
gl_Position = vec4(normalizeCoords(position), 0, 1);
}`,
attributes: {
position: function(context, props) {
return props.points.map(function(point) {
return [point.x, point.y];
});
},
pointWidth: function(context, props) {
return props.points.map(function(point) {
return point.size;
});
}
},
uniforms: {
color: function(context, props) {
return [Math.cos(context.tick / 100), 0.304, 1.0, 1.0];
},
stageWidth: newRegl.context("drawingBufferWidth"),
stageHeight: newRegl.context("drawingBufferHeight")
},
count: function(context, props) {
return props.points.length;
},
primitive: "points"
})