Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP padLinear #213

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/index.js
Expand Up @@ -8,7 +8,8 @@ export {
} from "./identity.js";

export {
default as scaleLinear
default as scaleLinear,
pad as padLinear
} from "./linear.js";

export {
Expand Down
5 changes: 5 additions & 0 deletions src/linear.js
Expand Up @@ -70,3 +70,8 @@ export default function linear() {

return linearish(scale);
}

export function pad([x0, x1], k) {
var dx = (x1 - x0) * k / 2;
return [x0 - dx, x1 + dx];
}
6 changes: 6 additions & 0 deletions test/linear-test.js
Expand Up @@ -509,3 +509,9 @@ tape("linear.copy() returns a copy with changes to the unknown value are isolate
test.equal(x.unknown(), 2);
test.end();
});

tape("padLinear returns a padded domain array", function(test) {
test.deepEqual(scale.padLinear([0, 8], 0.5), [-2, 10])
test.deepEqual(scale.padLinear([0, 8], 0.25), [-1, 9])
test.end();
});