Public
Edited
Oct 26, 2024
Insert cell
Insert cell
Insert cell
viewof lineDensity = Inputs.range([1, 20], {step: 1, value:13})
Insert cell
viewof ridgeHeight = Inputs.range([1, 40], {step: 1, value:13})
Insert cell
numberofLines = elevationMatrix.length / lineDensity
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
elevationMatrix = {
const imageWidth = dimensions[0];
const imageHeight = dimensions[1];

let retval = Array(imageHeight)
.fill()
.map(() => Array(imageWidth).fill(0));

for (var i = 0; i < imageHeight; i++) {
for (var j = 0; j < imageWidth; j++) {
var startIndex = (imageWidth * i + j) * 4;

//chroma.distance('#ffffff', '#000000')
// retval[i][j] = rgbToHex(
// imageData.data[startIndex],
// imageData.data[startIndex + 1],
// imageData.data[startIndex + 2]
// );

retval[i][j] = d3cdiff.differenceEuclideanLab(
'#000',
rgbToHex(
imageData.data[startIndex],
imageData.data[startIndex + 1],
imageData.data[startIndex + 2]
));
}
}

return retval;
}
Insert cell
function blobToFile(theBlob, fileName) {
//A Blob() is almost a File() - it's just missing the two properties below which we will add
theBlob.lastModifiedDate = new Date();
theBlob.name = fileName;
return theBlob;
}
Insert cell
Insert cell
Insert cell
Insert cell
height = 700
Insert cell
scale = d3
.scaleLinear()
// .scaleLog()
// .scaleLog()
//.domain([0, chroma.deltaE('#fff', '#000')])
.domain([1, 100])
.range([ridgeHeight, 1])
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3cdiff = require('d3-color-difference')
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