Skip to content

Commit

Permalink
support UintArray data, add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Fil committed Nov 26, 2024
1 parent 11ae1ab commit 6c21a1e
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 30 deletions.
11 changes: 6 additions & 5 deletions src/contours.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ export default function() {
const v = value == null ? NaN : +value;
if (isNaN(v)) throw new Error(`invalid value: ${value}`);

// Don’t round the corners by clamping values on the edge.
const bottom = values.slice(0, dx);
const top = values.slice(-dx);
const left = Array.from({length: dy}, (_, i) => values[i * dx]);
const right = Array.from({length: dy}, (_, i) => values[i * dx + dx - 1]);
// Don’t round the corners by clamping values on the edge. Note: to blur, we
// need to ensure that the values are valid numbers.
const bottom = Array.from(values.slice(0, dx), valid);
const top = Array.from(values.slice(-dx), valid);
const left = Array.from({length: dy}, (_, i) => valid(values[i * dx]));
const right = Array.from({length: dy}, (_, i) => valid(values[i * dx + dx - 1]));
blur(bottom, blurEdges);
blur(top, blurEdges);
blur(left, blurEdges);
Expand Down
29 changes: 29 additions & 0 deletions test/output/matrixContours.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6c21a1e

Please sign in to comment.