Skip to content

Commit 11a6ddb

Browse files
authored
mapTransferGamma: fix pow -> Math.pow (#116)
There's no such global function as `pow`, so `mapTransferGamma` didn't work.
1 parent 93e05dd commit 11a6ddb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/map.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const mapTransferGamma = (amplitude = 1, exponent = 1, offset = 0) => (
5454
ch
5555
) => {
5656
if (ch !== 'alpha') {
57-
return amplitude * pow(v, exponent) + offset;
57+
return amplitude * Math.pow(v, exponent) + offset;
5858
}
5959
return v;
6060
};

test/map.test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
mapAlphaMultiply,
55
mapAlphaDivide,
66
mapTransferLinear,
7+
mapTransferGamma,
78
formatHex,
89
formatHex8
910
} from '../src/index';
@@ -17,8 +18,14 @@ tape('mapping alpha', t => {
1718
t.end();
1819
});
1920

20-
tape('transfer functions', t => {
21+
tape('linear transfer function', t => {
2122
let brighten = mapper(mapTransferLinear(2));
2223
t.equal(formatHex(brighten('#cc0033')), '#ff0066');
2324
t.end();
2425
});
26+
27+
tape('gamma transfer function', t => {
28+
let brighten = mapper(mapTransferGamma(2.2));
29+
t.equal(formatHex(brighten('#cc0033')), '#ff0070');
30+
t.end();
31+
});

0 commit comments

Comments
 (0)