Published
Edited
Jun 30, 2020
Importers
WebGL Coordinate Conversion
Insert cell
Insert cell
Insert cell
Insert cell
function convert(p, w = 300, h = 150){
return [p[0] / w * 2 - 1, p[1] / h * 2 - 1];
}
Insert cell
convert([300, 150])
Insert cell
convert([150, 75])
Insert cell
convert([0, 0])
Insert cell
convert([1, 1], 1, 1);
Insert cell
convert([.5, .5], 1, 1)
Insert cell
convert([0, 0], 1, 1);
Insert cell
Insert cell
function convertAll(points, width, height){
const out = [];
for (let i = 0, l = points.length; i < l; i++){
const c = convert(points[i], width, height);
out.push(c[0]);
out.push(c[1]);
}
return new Float32Array(out);
}
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