mirror of
https://github.com/netbymatt/nexrad-level-2-plot.git
synced 2026-11-28 18:28:05 -08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cea4fb15d | ||
|
|
9b4295e872 | ||
|
|
483f73547b | ||
|
|
68ab79161b |
No files matched your search
Generated
+406
-971
File diff suppressed because it is too large.
Load diff
+4
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nexrad-level-2-plot",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.2",
|
||||
"description": "Plotting library for nexrad-level-2-data",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
@@ -25,11 +25,11 @@
|
||||
"homepage": "https://github.com/netbymatt/nexrad-level-2-plot#readme",
|
||||
"dependencies": {
|
||||
"canvas": "^2.8.0",
|
||||
"nexrad-level-2-data": "file:../nexrad-level-2-data"
|
||||
"nexrad-level-2-data": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint": "^8.0.0",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-plugin-import": "^2.23.4",
|
||||
"glob": "^7.1.7"
|
||||
},
|
||||
|
||||
@@ -6,7 +6,6 @@ const palettizeImage = (sourceCtx, palette) => {
|
||||
x: sourceCtx.canvas.width,
|
||||
y: sourceCtx.canvas.height,
|
||||
};
|
||||
console.time('Palettize image');
|
||||
|
||||
// transform into indexed palette by finding the closest indexed color for each pixel
|
||||
// create a destination image that is transparent and indexed
|
||||
@@ -19,11 +18,10 @@ const palettizeImage = (sourceCtx, palette) => {
|
||||
const indexedImageData = indexedCtx.getImageData(0, 0, dim.x, dim.y);
|
||||
|
||||
// loop through each pixel
|
||||
console.log(`Palettized cache size: ${Object.keys(palette.closest).length}`);
|
||||
indexedImageData.data.forEach((val, idx) => {
|
||||
indexedImageData.data[idx] = palette.closestIndex(sourceImageData.data.slice(idx * 4, idx * 4 + 3));
|
||||
});
|
||||
console.timeEnd('Palettize image');
|
||||
|
||||
// write the new image data
|
||||
indexedCtx.putImageData(indexedImageData, 0, 0);
|
||||
|
||||
|
||||
Reference in new issue
Block a user