color-map 1.1.0 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +16 -48
  3. package/{dist-es2015 → cjs}/createColors.d.ts +0 -0
  4. package/{dist-es5 → cjs}/createColors.js +11 -1
  5. package/cjs/createColors.js.map +1 -0
  6. package/{dist-es2015 → cjs}/createColorsFromMap.d.ts +0 -0
  7. package/{dist-es5 → cjs}/createColorsFromMap.js +3 -2
  8. package/cjs/createColorsFromMap.js.map +1 -0
  9. package/{dist-es2015 → cjs}/index.d.ts +0 -0
  10. package/cjs/index.js +18 -0
  11. package/cjs/index.js.map +1 -0
  12. package/{dist-es2015 → cjs}/interfaces.d.ts +0 -0
  13. package/{dist-es5 → cjs}/interfaces.js +0 -0
  14. package/{dist-es2015 → cjs}/interfaces.js.map +1 -1
  15. package/{dist-es2015 → cjs}/rgbHex.d.ts +0 -0
  16. package/{dist-es5 → cjs}/rgbHex.js +1 -0
  17. package/cjs/rgbHex.js.map +1 -0
  18. package/{dist-es2015 → cjs}/rgbaString.d.ts +0 -0
  19. package/{dist-es5 → cjs}/rgbaString.js +1 -0
  20. package/cjs/rgbaString.js.map +1 -0
  21. package/dist/color-map.es5.js +1 -1
  22. package/dist/color-map.es5.js.map +1 -1
  23. package/{dist-es5 → esm}/createColors.d.ts +0 -0
  24. package/{dist-es2015 → esm}/createColors.js +0 -0
  25. package/esm/createColors.js.map +1 -0
  26. package/{dist-es5 → esm}/createColorsFromMap.d.ts +0 -0
  27. package/{dist-es2015 → esm}/createColorsFromMap.js +0 -0
  28. package/esm/createColorsFromMap.js.map +1 -0
  29. package/{dist-es5 → esm}/index.d.ts +0 -0
  30. package/{dist-es2015 → esm}/index.js +1 -0
  31. package/esm/index.js.map +1 -0
  32. package/{dist-es5 → esm}/interfaces.d.ts +0 -0
  33. package/esm/interfaces.js +2 -0
  34. package/{dist-es5 → esm}/interfaces.js.map +1 -1
  35. package/{dist-es5 → esm}/rgbHex.d.ts +0 -0
  36. package/{dist-es2015 → esm}/rgbHex.js +1 -1
  37. package/esm/rgbHex.js.map +1 -0
  38. package/{dist-es5 → esm}/rgbaString.d.ts +0 -0
  39. package/{dist-es2015 → esm}/rgbaString.js +0 -0
  40. package/esm/rgbaString.js.map +1 -0
  41. package/package.json +69 -65
  42. package/ts/createColors.spec.ts +176 -0
  43. package/{src → ts}/createColors.ts +0 -0
  44. package/ts/createColorsFromMap.spec.ts +11 -0
  45. package/{src → ts}/createColorsFromMap.ts +0 -0
  46. package/{src → ts}/index.ts +0 -0
  47. package/{src → ts}/interfaces.ts +0 -0
  48. package/ts/rgbHex.spec.ts +17 -0
  49. package/{src → ts}/rgbHex.ts +1 -1
  50. package/ts/rgbaString.spec.ts +9 -0
  51. package/{src → ts}/rgbaString.ts +0 -0
  52. package/dist-es2015/createColors.js.map +0 -1
  53. package/dist-es2015/createColorsFromMap.js.map +0 -1
  54. package/dist-es2015/index.js.map +0 -1
  55. package/dist-es2015/interfaces.js +0 -1
  56. package/dist-es2015/rgbHex.js.map +0 -1
  57. package/dist-es2015/rgbaString.js.map +0 -1
  58. package/dist-es5/createColors.js.map +0 -1
  59. package/dist-es5/createColorsFromMap.js.map +0 -1
  60. package/dist-es5/index.js +0 -10
  61. package/dist-es5/index.js.map +0 -1
  62. package/dist-es5/rgbHex.js.map +0 -1
  63. package/dist-es5/rgbaString.js.map +0 -1
  64. package/src/createColors.spec.ts +0 -175
  65. package/src/createColorsFromMap.spec.ts +0 -13
  66. package/src/rgbHex.spec.ts +0 -19
  67. package/src/rgbaString.spec.ts +0 -11
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 unional, Homa Wong (homawong@gmail.com)
3
+ Copyright (c) 2017 Homa Wong (unional) (homawong@gmail.com)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,11 +2,10 @@
2
2
 
3
3
  [![NPM version][npm-image]][npm-url]
4
4
  [![NPM downloads][downloads-image]][downloads-url]
5
- [![Build status][travis-image]][travis-url]
6
- [![Coverage Status][coveralls-image]][coveralls-url]
7
- ![badge-size-es5-url]
8
5
 
9
- [![Greenkeeper][greenkeeper-image]][greenkeeper-url]
6
+ [![Github NodeJS][github-nodejs]][github-action-url]
7
+ [![Codecov][codecov-image]][codecov-url]
8
+
10
9
  [![Semantic Release][semantic-release-image]][semantic-release-url]
11
10
 
12
11
  [![Visual Studio Code][vscode-image]][vscode-url]
@@ -59,15 +58,13 @@ const colors = createColorsFromMap(summer, 60)
59
58
  ## Contribute
60
59
 
61
60
  ```sh
62
- # after fork
61
+ # after fork and clone
63
62
  npm install
64
63
 
65
64
  # begin making changes
66
65
  git checkout -b <branch>
67
66
  npm run watch
68
67
 
69
- # edit `webpack.config.dev.js` to exclude dependencies for the global build.
70
-
71
68
  # after making change(s)
72
69
  git commit -m "<commit message>"
73
70
  git push
@@ -75,46 +72,17 @@ git push
75
72
  # create PR
76
73
  ```
77
74
 
78
- ## Npm Commands
79
-
80
- There are a few useful commands you can use during development.
81
-
82
- ```sh
83
- # Run tests (and lint) automatically whenever you save a file.
84
- npm run watch
85
-
86
- # Run tests with coverage stats (but won't fail you if coverage does not meet criteria)
87
- npm run test
88
-
89
- # Manually verify the project.
90
- # This will be ran during 'npm preversion' so you normally don't need to run this yourself.
91
- npm run verify
92
-
93
- # Build the project.
94
- # You normally don't need to do this.
95
- npm run build
96
-
97
- # Run tslint
98
- # You normally don't need to do this as `npm run watch` and `npm version` will automatically run lint for you.
99
- npm run lint
100
- ```
101
-
102
- Generated by [`generator-unional@0.3.1`](https://github.com/unional/unional-cli)
103
-
104
- [npm-image]: https://img.shields.io/npm/v/color-map.svg?style=flat
105
- [npm-url]: https://npmjs.org/package/color-map
75
+ [codecov-image]: https://codecov.io/gh/unional/color-map/branch/master/graph/badge.svg
76
+ [codecov-url]: https://codecov.io/gh/unional/color-map
106
77
  [downloads-image]: https://img.shields.io/npm/dm/color-map.svg?style=flat
107
78
  [downloads-url]: https://npmjs.org/package/color-map
108
- [travis-image]: https://img.shields.io/travis/unional/color-map/master.svg?style=flat
109
- [travis-url]: https://travis-ci.org/unional/color-map?branch=master
110
- [coveralls-image]: https://coveralls.io/repos/github/unional/color-map/badge.svg
111
- [coveralls-url]: https://coveralls.io/github/unional/color-map
112
- [badge-size-es5-url]: http://img.badgesize.io/unional/color-map/master/dist/color-map.es5.js.svg?label=es5_size
113
- [greenkeeper-image]:https://badges.greenkeeper.io/unional/color-map.svg
114
- [greenkeeper-url]:https://greenkeeper.io/
115
- [semantic-release-image]:https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
116
- [semantic-release-url]:https://github.com/semantic-release/semantic-release
117
- [wallaby-image]:https://img.shields.io/badge/wallaby.js-configured-green.svg
118
- [wallaby-url]:https://wallabyjs.com
119
- [vscode-image]:https://img.shields.io/badge/vscode-ready-green.svg
120
- [vscode-url]:https://code.visualstudio.com/
79
+ [github-nodejs]: https://github.com/unional/color-map/workflows/nodejs/badge.svg
80
+ [github-action-url]: https://github.com/unional/color-map/actions
81
+ [npm-image]: https://img.shields.io/npm/v/color-map.svg?style=flat
82
+ [npm-url]: https://npmjs.org/package/color-map
83
+ [semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
84
+ [semantic-release-url]: https://github.com/semantic-release/semantic-release
85
+ [vscode-image]: https://img.shields.io/badge/vscode-ready-green.svg
86
+ [vscode-url]: https://code.visualstudio.com/
87
+ [wallaby-image]: https://img.shields.io/badge/wallaby.js-configured-green.svg
88
+ [wallaby-url]: https://wallabyjs.com
File without changes
@@ -1,11 +1,21 @@
1
1
  "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.createColors = void 0;
3
13
  function createColors(from, to, shades, alpha) {
4
14
  if (alpha === void 0) { alpha = [
5
15
  from.length === 4 ? from[3] : to.length === 4 ? to[3] : 1,
6
16
  to.length === 4 ? to[3] : from.length === 4 ? from[3] : 1
7
17
  ]; }
8
- var start = from.slice();
18
+ var start = __spreadArray([], from, true);
9
19
  var diff = [
10
20
  to[0] - from[0],
11
21
  to[1] - from[1],
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createColors.js","sourceRoot":"","sources":["../ts/createColors.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,SAAgB,YAAY,CAC1B,IAAgB,EAChB,EAAc,EACd,MAAc,EACd,KAGC;IAHD,sBAAA,EAAA;QACE,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC1D;IACD,IAAM,KAAK,qBAAO,IAAI,OAAC,CAAA;IACvB,IAAM,IAAI,GAAG;QACX,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACf,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACf,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACf,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;KACpB,CAAA;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QACpB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAEtB,IAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;IAEvC,IAAM,IAAI,GAAU,EAAE,CAAA;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAM,KAAK,GAAG;YACZ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YACxC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YACxC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YACxC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG;SAC7B,CAAA;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;KACjB;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAhCD,oCAgCC"}
File without changes
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createColorsFromMap = void 0;
3
4
  var createColors_1 = require("./createColors");
4
5
  /**
5
6
  * Create colors with specified color map.
6
7
  */
7
8
  function createColorsFromMap(colormap, shades, alpha) {
8
9
  if (shades < colormap.length) {
9
- throw new Error("Requires at least " + colormap.length + " shades.");
10
+ throw new Error("Requires at least ".concat(colormap.length, " shades."));
10
11
  }
11
12
  var result = [];
12
13
  var steps = [];
@@ -17,7 +18,7 @@ function createColorsFromMap(colormap, shades, alpha) {
17
18
  var n = steps[i + 1] - steps[i];
18
19
  var from = colormap[i].rgb;
19
20
  var to = colormap[i + 1].rgb;
20
- result.push.apply(result, createColors_1.createColors(from, to, n, alpha));
21
+ result.push.apply(result, (0, createColors_1.createColors)(from, to, n, alpha));
21
22
  }
22
23
  return result;
23
24
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createColorsFromMap.js","sourceRoot":"","sources":["../ts/createColorsFromMap.ts"],"names":[],"mappings":";;;AAAA,+CAA6C;AAG7C;;GAEG;AACH,SAAgB,mBAAmB,CAAC,QAAkB,EAAE,MAAc,EAAE,KAAa;IACnF,IAAI,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,4BAAqB,QAAQ,CAAC,MAAM,aAAU,CAAC,CAAA;KAChE;IAED,IAAM,MAAM,GAAW,EAAE,CAAA;IACzB,IAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACxC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAA;KACnD;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC5C,IAAM,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACjC,IAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAC7B,IAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAC/B,MAAM,CAAC,IAAI,OAAX,MAAM,EAAS,IAAA,2BAAY,EAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,EAAC;KACjD;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAnBD,kDAmBC"}
File without changes
package/cjs/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./createColors"), exports);
14
+ __exportStar(require("./createColorsFromMap"), exports);
15
+ __exportStar(require("./interfaces"), exports);
16
+ __exportStar(require("./rgbHex"), exports);
17
+ __exportStar(require("./rgbaString"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA8B;AAC9B,wDAAqC;AACrC,+CAA4B;AAC5B,2CAAwB;AACxB,+CAA4B"}
File without changes
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../ts/interfaces.ts"],"names":[],"mappings":""}
File without changes
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rgbHex = void 0;
3
4
  /**
4
5
  * Convert `RGB` to `#rgb`
5
6
  * JavaScript note: no check for array length, use it properly.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rgbHex.js","sourceRoot":"","sources":["../ts/rgbHex.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,SAAgB,MAAM,CAAC,GAAe;IACpC,IAAI,GAAG,GAAG,GAAG,CAAA;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;KACnB;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAND,wBAMC;AAED,SAAS,GAAG,CAAC,CAAS;IACpB,IAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC3B,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACnC,CAAC"}
File without changes
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rgbaString = void 0;
3
4
  function rgbaString(rgba) {
4
5
  return 'rgba(' + rgba.join(',') + ')';
5
6
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rgbaString.js","sourceRoot":"","sources":["../ts/rgbaString.ts"],"names":[],"mappings":";;;AAEA,SAAgB,UAAU,CAAC,IAAU;IACnC,OAAO,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AACxC,CAAC;AAFD,gCAEC"}
@@ -1,2 +1,2 @@
1
- var ColorMap=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=5)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.createColors=function(e,r,t,n){void 0===n&&(n=[4===e.length?e[3]:4===r.length?r[3]:1,4===r.length?r[3]:4===e.length?e[3]:1]);var o=e.slice(),u=[r[0]-e[0],r[1]-e[1],r[2]-e[2],n[1]-n[0]];3===o.length&&o.push(n[0]);for(var i=1/Math.max(t-1,1),a=[],c=0;c<t;c++){var l=[Math.round(o[0]+c*u[0]*i),Math.round(o[1]+c*u[1]*i),Math.round(o[2]+c*u[2]*i),o[3]+c*u[3]*i];a.push(l)}return a}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.rgbaString=function(e){return"rgba("+e.join(",")+")"}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.rgbHex=function(e){for(var r,t="#",n=0;n<3;n++)t+=(r=(+e[n]).toString(16)).length<2?"0"+r:r;return t}},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0})},function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(0);r.createColorsFromMap=function(e,r,t){if(r<e.length)throw new Error("Requires at least "+e.length+" shades.");for(var o=[],u=[],i=0;i<e.length;i++)u.push(Math.round(e[i].index*r));for(i=0;i<e.length-1;i++){var a=u[i+1]-u[i],c=e[i].rgb,l=e[i+1].rgb;o.push.apply(o,n.createColors(c,l,a,t))}return o}},function(e,r,t){"use strict";function n(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}Object.defineProperty(r,"__esModule",{value:!0}),n(t(0)),n(t(4)),n(t(3)),n(t(2)),n(t(1))}]);
1
+ var ColorMap;(()=>{"use strict";var e={938:function(e,r){var t=this&&this.__spreadArray||function(e,r,t){if(t||2===arguments.length)for(var o,n=0,a=r.length;n<a;n++)!o&&n in r||(o||(o=Array.prototype.slice.call(r,0,n)),o[n]=r[n]);return e.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(r,"__esModule",{value:!0}),r.createColors=void 0,r.createColors=function(e,r,o,n){void 0===n&&(n=[4===e.length?e[3]:4===r.length?r[3]:1,4===r.length?r[3]:4===e.length?e[3]:1]);var a=t([],e,!0),i=[r[0]-e[0],r[1]-e[1],r[2]-e[2],n[1]-n[0]];3===a.length&&a.push(n[0]);for(var l=1/Math.max(o-1,1),u=[],c=0;c<o;c++){var s=[Math.round(a[0]+c*i[0]*l),Math.round(a[1]+c*i[1]*l),Math.round(a[2]+c*i[2]*l),a[3]+c*i[3]*l];u.push(s)}return u}},879:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createColorsFromMap=void 0;var o=t(938);r.createColorsFromMap=function(e,r,t){if(r<e.length)throw new Error("Requires at least ".concat(e.length," shades."));for(var n=[],a=[],i=0;i<e.length;i++)a.push(Math.round(e[i].index*r));for(i=0;i<e.length-1;i++){var l=a[i+1]-a[i],u=e[i].rgb,c=e[i+1].rgb;n.push.apply(n,(0,o.createColors)(u,c,l,t))}return n}},403:function(e,r,t){var o=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t),Object.defineProperty(e,o,{enumerable:!0,get:function(){return r[t]}})}:function(e,r,t,o){void 0===o&&(o=t),e[o]=r[t]}),n=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||o(r,e,t)};Object.defineProperty(r,"__esModule",{value:!0}),n(t(938),r),n(t(879),r),n(t(676),r),n(t(140),r),n(t(0),r)},676:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0})},140:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.rgbHex=void 0,r.rgbHex=function(e){for(var r,t="#",o=0;o<3;o++)t+=(void 0,(r=(+e[o]).toString(16)).length<2?"0"+r:r);return t}},0:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.rgbaString=void 0,r.rgbaString=function(e){return"rgba("+e.join(",")+")"}}},r={},t=function t(o){var n=r[o];if(void 0!==n)return n.exports;var a=r[o]={exports:{}};return e[o].call(a.exports,a,a.exports,t),a.exports}(403);ColorMap=t})();
2
2
  //# sourceMappingURL=color-map.es5.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://ColorMap/webpack/bootstrap","webpack://ColorMap/./src/createColors.ts","webpack://ColorMap/./src/rgbaString.ts","webpack://ColorMap/./src/rgbHex.ts","webpack://ColorMap/./src/createColorsFromMap.ts","webpack://ColorMap/./src/index.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","r","value","n","__esModule","default","object","property","prototype","hasOwnProperty","p","s","e","t","createColors","from","to","shades","alpha","length","start","slice","diff","push","inc","Math","max","rgba","color","round","rgbaString","join","rgbHex","rgb","hex","toString","createColors_1","createColorsFromMap","colormap","Error","result","steps","index","apply","__export"],"mappings":"yBACA,IAAAA,KAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,IACAG,EAAAH,EACAI,KACAH,YAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,KAGAF,EAAAD,QA2CA,OAtCAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,GACAK,gBACAC,cACAC,IAAAN,KAMAZ,EAAAmB,EAAA,SAAAjB,GACAY,OAAAC,eAAAb,EAAA,cAAiDkB,YAIjDpB,EAAAqB,EAAA,SAAAlB,GACA,IAAAS,EAAAT,KAAAmB,WACA,WAA2B,OAAAnB,EAAAoB,SAC3B,WAAiC,OAAApB,GAEjC,OADAH,EAAAU,EAAAE,EAAA,IAAAA,GACAA,GAIAZ,EAAAa,EAAA,SAAAW,EAAAC,GAAsD,OAAAX,OAAAY,UAAAC,eAAApB,KAAAiB,EAAAC,IAGtDzB,EAAA4B,EAAA,GAIA5B,IAAA6B,EAAA,cAAAC,EAAAX,EAAAY,GAAA,aAAAjB,OAAAC,eAAAI,EAAA,cAAAC,OAAA,ICjEAlB,EAAA8B,aAAA,SACEC,EACAC,EACAC,EACAC,mBACkB,IAAhBH,EAAKI,OAAeJ,EAAK,GAAmB,IAAdC,EAAGG,OAAeH,EAAG,GAAK,EAC1C,IAAdA,EAAGG,OAAeH,EAAG,GAAqB,IAAhBD,EAAKI,OAAeJ,EAAK,GAAK,IAE1D,IAAMK,EAAYL,EAAIM,QAChBC,GACJN,EAAG,GAAKD,EAAK,GACbC,EAAG,GAAKD,EAAK,GACbC,EAAG,GAAKD,EAAK,GACbG,EAAM,GAAKA,EAAM,IAGE,IAAjBE,EAAMD,QACRC,EAAMG,KAAKL,EAAM,IAKnB,IAHA,IAAMM,EAAM,EAAIC,KAAKC,IAAIT,EAAS,EAAG,GAE/BU,KACGzC,EAAI,EAAGA,EAAI+B,EAAQ/B,IAAK,CAC/B,IAAM0C,GACJH,KAAKI,MAAMT,EAAM,GAAKlC,EAAIoC,EAAK,GAAKE,GACpCC,KAAKI,MAAMT,EAAM,GAAKlC,EAAIoC,EAAK,GAAKE,GACpCC,KAAKI,MAAMT,EAAM,GAAKlC,EAAIoC,EAAK,GAAKE,GACpCJ,EAAM,GAAKlC,EAAIoC,EAAK,GAAKE,GAE3BG,EAAKJ,KAAKK,GAEZ,OAAOD,kFC/BT3C,EAAA8C,WAAA,SAA2BH,GACzB,MAAO,QAAUA,EAAKI,KAAK,KAAO,eAAAnB,EAAAX,EAAAY,GAAA,aAAAjB,OAAAC,eAAAI,EAAA,cAAAC,OAAA,ICGpClB,EAAAgD,OAAA,SAAuBC,GAErB,IADA,IAQItB,EARAuB,EAAM,IACDhD,EAAI,EAAGA,EAAI,EAAGA,IACrBgD,IAMEvB,IANSsB,EAAI/C,IAMJiD,SAAS,KACbhB,OAAS,EAAI,IAAMR,EAAIA,EALhC,OAAOuB,iKCXT,IAAAE,EAAAtD,EAAA,GAMAE,EAAAqD,oBAAA,SAAoCC,EAAoBrB,EAAgBC,GACtE,GAAID,EAASqB,EAASnB,OACpB,MAAM,IAAIoB,MAAM,qBAAqBD,EAASnB,OAAM,YAKtD,IAFA,IAAMqB,KACAC,KACGvD,EAAI,EAAGA,EAAIoD,EAASnB,OAAQjC,IACnCuD,EAAMlB,KAAKE,KAAKI,MAAMS,EAASpD,GAAGwD,MAAQzB,IAG5C,IAAS/B,EAAI,EAAGA,EAAIoD,EAASnB,OAAS,EAAGjC,IAAK,CAC5C,IAAMiB,EAAIsC,EAAMvD,EAAI,GAAKuD,EAAMvD,GACzB6B,EAAOuB,EAASpD,GAAG+C,IACnBjB,EAAKsB,EAASpD,EAAI,GAAG+C,IAC3BO,EAAOjB,KAAIoB,MAAXH,EAAeJ,EAAAtB,aAAaC,EAAMC,EAAIb,EAAGe,IAG3C,OAAOsB,gJCxBTI,EAAA9D,EAAA,IACA8D,EAAA9D,EAAA,IACA8D,EAAA9D,EAAA,IACA8D,EAAA9D,EAAA,IACA8D,EAAA9D,EAAA","file":"color-map.es5.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 5);\n","import { RGB, RGBA, Alpha } from './interfaces'\n\nexport function createColors(\n from: RGB | RGBA,\n to: RGB | RGBA,\n shades: number,\n alpha: Alpha = [\n from.length === 4 ? from[3] : to.length === 4 ? to[3] : 1,\n to.length === 4 ? to[3] : from.length === 4 ? from[3] : 1\n ]): RGBA[] {\n const start = [...from]\n const diff = [\n to[0] - from[0],\n to[1] - from[1],\n to[2] - from[2],\n alpha[1] - alpha[0]\n ]\n\n if (start.length === 3)\n start.push(alpha[0])\n\n const inc = 1 / Math.max(shades - 1, 1)\n\n const rgba: any[] = []\n for (let i = 0; i < shades; i++) {\n const color = [\n Math.round(start[0] + i * diff[0] * inc),\n Math.round(start[1] + i * diff[1] * inc),\n Math.round(start[2] + i * diff[2] * inc),\n start[3] + i * diff[3] * inc\n ]\n rgba.push(color)\n }\n return rgba\n}\n","import { RGBA } from './interfaces'\n\nexport function rgbaString(rgba: RGBA) {\n return 'rgba(' + rgba.join(',') + ')';\n}\n","import { RGB, RGBA } from './interfaces'\n\n/**\n * Convert `RGB` to `#rgb`\n * JavaScript note: no check for array length, use it properly.\n */\nexport function rgbHex(rgb: RGB | RGBA) {\n let hex = '#'\n for (let i = 0; i < 3; i++) {\n hex += d2h(rgb[i])\n }\n return hex\n}\n\nfunction d2h(d: number) {\n let s = (+d).toString(16)\n return s.length < 2 ? '0' + s : s\n}\n","import { createColors } from './createColors'\nimport { ColorMap, Alpha, RGBA } from './interfaces'\n\n/**\n * Create colors with specified color map.\n */\nexport function createColorsFromMap(colormap: ColorMap, shades: number, alpha?: Alpha): RGBA[] {\n if (shades < colormap.length) {\n throw new Error(`Requires at least ${colormap.length} shades.`)\n }\n\n const result: RGBA[] = []\n const steps: number[] = []\n for (let i = 0; i < colormap.length; i++) {\n steps.push(Math.round(colormap[i].index * shades))\n }\n\n for (let i = 0; i < colormap.length - 1; i++) {\n const n = steps[i + 1] - steps[i]\n const from = colormap[i].rgb;\n const to = colormap[i + 1].rgb;\n result.push(...createColors(from, to, n, alpha))\n }\n\n return result\n}\n","export * from './createColors'\nexport * from './createColorsFromMap'\nexport * from './interfaces'\nexport * from './rgbHex'\nexport * from './rgbaString'\n"],"sourceRoot":""}
1
+ {"version":3,"file":"color-map.es5.js","mappings":"gWAEA,wBACEA,EACAC,EACAC,EACAC,QAAA,IAAAA,IAAAA,EAAA,CACkB,IAAhBH,EAAKI,OAAeJ,EAAK,GAAmB,IAAdC,EAAGG,OAAeH,EAAG,GAAK,EAC1C,IAAdA,EAAGG,OAAeH,EAAG,GAAqB,IAAhBD,EAAKI,OAAeJ,EAAK,GAAK,IAE1D,IAAMK,EAAQ,EAAH,GAAOL,GAAI,GAChBM,EAAO,CACXL,EAAG,GAAKD,EAAK,GACbC,EAAG,GAAKD,EAAK,GACbC,EAAG,GAAKD,EAAK,GACbG,EAAM,GAAKA,EAAM,IAGE,IAAjBE,EAAMD,QACRC,EAAME,KAAKJ,EAAM,IAKnB,IAHA,IAAMK,EAAM,EAAIC,KAAKC,IAAIR,EAAS,EAAG,GAE/BS,EAAc,GACXC,EAAI,EAAGA,EAAIV,EAAQU,IAAK,CAC/B,IAAMC,EAAQ,CACZJ,KAAKK,MAAMT,EAAM,GAAKO,EAAIN,EAAK,GAAKE,GACpCC,KAAKK,MAAMT,EAAM,GAAKO,EAAIN,EAAK,GAAKE,GACpCC,KAAKK,MAAMT,EAAM,GAAKO,EAAIN,EAAK,GAAKE,GACpCH,EAAM,GAAKO,EAAIN,EAAK,GAAKE,GAE3BG,EAAKJ,KAAKM,GAEZ,OAAOF,I,4FCjCT,aAMA,+BAAoCI,EAAoBb,EAAgBC,GACtE,GAAID,EAASa,EAASX,OACpB,MAAM,IAAIY,MAAM,4BAAqBD,EAASX,OAAM,aAKtD,IAFA,IAAMa,EAAiB,GACjBC,EAAkB,GACfN,EAAI,EAAGA,EAAIG,EAASX,OAAQQ,IACnCM,EAAMX,KAAKE,KAAKK,MAAMC,EAASH,GAAGO,MAAQjB,IAG5C,IAASU,EAAI,EAAGA,EAAIG,EAASX,OAAS,EAAGQ,IAAK,CAC5C,IAAMQ,EAAIF,EAAMN,EAAI,GAAKM,EAAMN,GACzBZ,EAAOe,EAASH,GAAGS,IACnBpB,EAAKc,EAASH,EAAI,GAAGS,IAC3BJ,EAAOV,KAAI,MAAXU,GAAe,IAAAK,cAAatB,EAAMC,EAAImB,EAAGjB,IAG3C,OAAOc,I,8YCxBT,YACA,YACA,YACA,YACA,W,2ICEA,kBAAuBI,GAErB,IADA,IAQME,EARFC,EAAM,IACDZ,EAAI,EAAGA,EAAI,EAAGA,IACrBY,SAMID,GAAAA,IANOF,EAAIT,IAMFa,SAAS,KACfrB,OAAS,EAAI,IAAMmB,EAAIA,GALhC,OAAOC,I,+ECTT,sBAA2Bb,GACzB,MAAO,QAAUA,EAAKe,KAAK,KAAO,OCFhCC,EAA2B,GCE3BC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaE,QAGrB,IAAIC,EAASP,EAAyBG,GAAY,CAGjDG,QAAS,IAOV,OAHAE,EAAoBL,GAAUM,KAAKF,EAAOD,QAASC,EAAQA,EAAOD,QAASJ,GAGpEK,EAAOD,QClBWJ,CAAoB,K","sources":["webpack://ColorMap/./ts/createColors.ts","webpack://ColorMap/./ts/createColorsFromMap.ts","webpack://ColorMap/./ts/index.ts","webpack://ColorMap/./ts/rgbHex.ts","webpack://ColorMap/./ts/rgbaString.ts","webpack://ColorMap/webpack/bootstrap","webpack://ColorMap/webpack/startup"],"sourcesContent":["import { RGB, RGBA, Alpha } from './interfaces'\n\nexport function createColors(\n from: RGB | RGBA,\n to: RGB | RGBA,\n shades: number,\n alpha: Alpha = [\n from.length === 4 ? from[3] : to.length === 4 ? to[3] : 1,\n to.length === 4 ? to[3] : from.length === 4 ? from[3] : 1\n ]): RGBA[] {\n const start = [...from]\n const diff = [\n to[0] - from[0],\n to[1] - from[1],\n to[2] - from[2],\n alpha[1] - alpha[0]\n ]\n\n if (start.length === 3)\n start.push(alpha[0])\n\n const inc = 1 / Math.max(shades - 1, 1)\n\n const rgba: any[] = []\n for (let i = 0; i < shades; i++) {\n const color = [\n Math.round(start[0] + i * diff[0] * inc),\n Math.round(start[1] + i * diff[1] * inc),\n Math.round(start[2] + i * diff[2] * inc),\n start[3] + i * diff[3] * inc\n ]\n rgba.push(color)\n }\n return rgba\n}\n","import { createColors } from './createColors'\nimport { ColorMap, Alpha, RGBA } from './interfaces'\n\n/**\n * Create colors with specified color map.\n */\nexport function createColorsFromMap(colormap: ColorMap, shades: number, alpha?: Alpha): RGBA[] {\n if (shades < colormap.length) {\n throw new Error(`Requires at least ${colormap.length} shades.`)\n }\n\n const result: RGBA[] = []\n const steps: number[] = []\n for (let i = 0; i < colormap.length; i++) {\n steps.push(Math.round(colormap[i].index * shades))\n }\n\n for (let i = 0; i < colormap.length - 1; i++) {\n const n = steps[i + 1] - steps[i]\n const from = colormap[i].rgb;\n const to = colormap[i + 1].rgb;\n result.push(...createColors(from, to, n, alpha))\n }\n\n return result\n}\n","export * from './createColors'\nexport * from './createColorsFromMap'\nexport * from './interfaces'\nexport * from './rgbHex'\nexport * from './rgbaString'\n","import { RGB, RGBA } from './interfaces'\n\n/**\n * Convert `RGB` to `#rgb`\n * JavaScript note: no check for array length, use it properly.\n */\nexport function rgbHex(rgb: RGB | RGBA) {\n let hex = '#'\n for (let i = 0; i < 3; i++) {\n hex += d2h(rgb[i])\n }\n return hex\n}\n\nfunction d2h(d: number) {\n const s = (+d).toString(16)\n return s.length < 2 ? '0' + s : s\n}\n","import { RGBA } from './interfaces'\n\nexport function rgbaString(rgba: RGBA) {\n return 'rgba(' + rgba.join(',') + ')';\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(403);\n"],"names":["from","to","shades","alpha","length","start","diff","push","inc","Math","max","rgba","i","color","round","colormap","Error","result","steps","index","n","rgb","createColors","s","hex","toString","join","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","call"],"sourceRoot":""}
File without changes
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createColors.js","sourceRoot":"","sources":["../ts/createColors.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAC1B,IAAgB,EAChB,EAAc,EACd,MAAc,EACd,QAAe;IACb,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC1D;IACD,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;IACvB,MAAM,IAAI,GAAG;QACX,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACf,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACf,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACf,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;KACpB,CAAA;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QACpB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAEtB,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;IAEvC,MAAM,IAAI,GAAU,EAAE,CAAA;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,MAAM,KAAK,GAAG;YACZ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YACxC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YACxC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YACxC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG;SAC7B,CAAA;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;KACjB;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
File without changes
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createColorsFromMap.js","sourceRoot":"","sources":["../ts/createColorsFromMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAkB,EAAE,MAAc,EAAE,KAAa;IACnF,IAAI,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,CAAC,MAAM,UAAU,CAAC,CAAA;KAChE;IAED,MAAM,MAAM,GAAW,EAAE,CAAA;IACzB,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACxC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAA;KACnD;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC5C,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACjC,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAC7B,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;KACjD;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
File without changes
@@ -1,5 +1,6 @@
1
1
  export * from './createColors';
2
2
  export * from './createColorsFromMap';
3
+ export * from './interfaces';
3
4
  export * from './rgbHex';
4
5
  export * from './rgbaString';
5
6
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA"}
File without changes
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interfaces.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../ts/interfaces.ts"],"names":[],"mappings":""}
File without changes
@@ -10,7 +10,7 @@ export function rgbHex(rgb) {
10
10
  return hex;
11
11
  }
12
12
  function d2h(d) {
13
- let s = (+d).toString(16);
13
+ const s = (+d).toString(16);
14
14
  return s.length < 2 ? '0' + s : s;
15
15
  }
16
16
  //# sourceMappingURL=rgbHex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rgbHex.js","sourceRoot":"","sources":["../ts/rgbHex.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,GAAe;IACpC,IAAI,GAAG,GAAG,GAAG,CAAA;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;KACnB;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,GAAG,CAAC,CAAS;IACpB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC3B,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACnC,CAAC"}
File without changes
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rgbaString.js","sourceRoot":"","sources":["../ts/rgbaString.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AACxC,CAAC"}
package/package.json CHANGED
@@ -1,40 +1,7 @@
1
1
  {
2
2
  "name": "color-map",
3
+ "version": "1.1.4",
3
4
  "description": "Color map generator",
4
- "version": "1.1.0",
5
- "main": "dist-es5/index.js",
6
- "module": "dist-es2015/index.js",
7
- "typings": "dist-es5/index.d.ts",
8
- "files": [
9
- "dist",
10
- "dist-es5",
11
- "dist-es2015",
12
- "src"
13
- ],
14
- "engines": {
15
- "node": ">=6"
16
- },
17
- "scripts": {
18
- "build": "npm run clean && npm run build-es5 && npm run build-es2015",
19
- "build-es5": "tsc -p tsconfig.es5.json",
20
- "build-es2015": "tsc -p tsconfig.es2015.json",
21
- "bundle": "webpack",
22
- "clean": "rimraf dist dist-es5 dist-es2015",
23
- "codecov": "codecov",
24
- "coverage": "nyc npm test",
25
- "coveralls": "nyc report --reporter=text-lcov | coveralls",
26
- "dependency-check": "dependency-check . --unused --no-dev && dependency-check . --missing --no-dev",
27
- "lint": "tslint -p tsconfig.json 'src/**/*.ts'",
28
- "prepublishOnly": "npm run build && npm run bundle",
29
- "test": "npm run clean && tsc && ava",
30
- "verify": "npm run lint && npm run coverage && npm run build && npm run bundle && npm run dependency-check",
31
- "watch": "npm run clean && node scripts/watch.js",
32
- "semantic-release": "semantic-release"
33
- },
34
- "author": {
35
- "name": "Homa Wong",
36
- "email": "homawong@gmail.com"
37
- },
38
5
  "homepage": "https://github.com/unional/color-map",
39
6
  "bugs": {
40
7
  "url": "https://github.com/unional/color-map/issues"
@@ -44,40 +11,77 @@
44
11
  "url": "https://github.com/unional/color-map.git"
45
12
  },
46
13
  "license": "MIT",
47
- "ava": {
48
- "files": [
49
- "dist-es5/**/*.spec.js"
50
- ],
51
- "source": [
52
- "scripts/*.js",
53
- "dist-es5/**/*.js",
54
- "*.json"
55
- ]
14
+ "author": {
15
+ "name": "Homa Wong (unional)",
16
+ "email": "homawong@gmail.com"
56
17
  },
57
- "nyc": {
58
- "exclude": [
59
- "scripts",
60
- "**/*.spec.*",
61
- "**/fixtures/**/*"
62
- ]
18
+ "main": "cjs/index.js",
19
+ "module": "esm/index.js",
20
+ "jsnext:main": "esm/index.js",
21
+ "typings": "cjs/index.d.ts",
22
+ "files": [
23
+ "cjs",
24
+ "dist",
25
+ "esm",
26
+ "ts"
27
+ ],
28
+ "scripts": {
29
+ "build": "run-p build:cjs build:esm bundle",
30
+ "build:cjs": "tsc -p tsconfig.cjs.json",
31
+ "build:esm": "tsc -p tsconfig.esm.json",
32
+ "build:verify": "run-s build dependency-check size-limit",
33
+ "bundle": "webpack",
34
+ "clean": "rimraf cjs esm lib libm",
35
+ "coverage": "jest --coverage",
36
+ "dependency-check": "run-p dependency-check:unused dependency-check:missing",
37
+ "dependency-check:missing": "dependency-check . --missing --no-dev",
38
+ "dependency-check:unused": "dependency-check . --unused --no-dev",
39
+ "lint": "eslint --ext=js,ts .",
40
+ "prepublishOnly": "yarn build",
41
+ "release": "npx semantic-release",
42
+ "size-limit": "size-limit",
43
+ "test": "jest",
44
+ "verify": "run-p build:verify lint coverage",
45
+ "watch": "jest --watch"
63
46
  },
64
47
  "devDependencies": {
65
- "ava": "^0.25.0",
66
- "colormap": "^2.3.0",
67
- "dependency-check": "^3.0.0",
68
- "eslint": "^4.19.1",
69
- "eslint-plugin-harmony": "^1.0.3",
70
- "nyc": "^11.7.1",
48
+ "@babel/core": "^7.16.0",
49
+ "@babel/plugin-proposal-class-properties": "^7.16.0",
50
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
51
+ "@babel/plugin-proposal-optional-chaining": "^7.16.0",
52
+ "@babel/preset-env": "^7.16.4",
53
+ "@babel/preset-typescript": "^7.16.0",
54
+ "@commitlint/cli": "^16.0.0",
55
+ "@commitlint/config-conventional": "^16.0.0",
56
+ "@size-limit/preset-small-lib": "^7.0.5",
57
+ "@types/jest": "^27.4.0",
58
+ "assertron": "^9.0.0",
59
+ "colormap": "^2.3.1",
60
+ "dependency-check": "^4.1.0",
61
+ "eslint": "^8.6.0",
62
+ "eslint-plugin-harmony": "^6.0.0",
63
+ "husky": "^7.0.4",
64
+ "jest": "^27.4.5",
65
+ "jest-junit": "^13.0.0",
66
+ "jest-progress-tracker": "^3.0.1",
67
+ "jest-validate": "^27.4.2",
68
+ "jest-watch-repeat": "^2.0.0",
69
+ "jest-watch-suspend": "^1.1.2",
70
+ "jest-watch-toggle-config": "^2.0.1",
71
+ "jest-watch-typeahead": "^1.0.0",
72
+ "npm-run-all": "^4.1.5",
71
73
  "param-case": "^2.1.1",
72
74
  "pascal-case": "^2.0.1",
73
- "rimraf": "^2.6.2",
74
- "semantic-release": "^15.2.0",
75
- "ts-loader": "^4.2.0",
76
- "tslint": "^5.10.0",
77
- "tslint-config-unional": "^0.9.3",
78
- "typescript": "^2.8.3",
79
- "uglifyjs-webpack-plugin": "^1.2.5",
80
- "webpack": "^4.6.0",
81
- "webpack-cli": "^2.1.2"
82
- }
75
+ "rimraf": "^3.0.2",
76
+ "size-limit": "^7.0.5",
77
+ "ts-loader": "^9.0.0",
78
+ "typescript": "^4.5.4",
79
+ "webpack": "^5.0.0",
80
+ "webpack-cli": "^3.3.2"
81
+ },
82
+ "size-limit": [
83
+ {
84
+ "limit": "2 KB"
85
+ }
86
+ ]
83
87
  }
@@ -0,0 +1,176 @@
1
+ import t from 'assert';
2
+ import { createColors } from '.';
3
+
4
+ test('match colormap output', () => {
5
+ const actual = createColors([0, 0, 255], [0, 255, 128], 72)
6
+
7
+ expect(actual).toEqual([
8
+ [0, 0, 255, 1],
9
+ [0, 4, 253, 1],
10
+ [0, 7, 251, 1],
11
+ [0, 11, 250, 1],
12
+ [0, 14, 248, 1],
13
+ [0, 18, 246, 1],
14
+ [0, 22, 244, 1],
15
+ [0, 25, 242, 1],
16
+ [0, 29, 241, 1],
17
+ [0, 32, 239, 1],
18
+ [0, 36, 237, 1],
19
+ [0, 40, 235, 1],
20
+ [0, 43, 234, 1],
21
+ [0, 47, 232, 1],
22
+ [0, 50, 230, 1],
23
+ [0, 54, 228, 1],
24
+ [0, 57, 226, 1],
25
+ [0, 61, 225, 1],
26
+ [0, 65, 223, 1],
27
+ [0, 68, 221, 1],
28
+ [0, 72, 219, 1],
29
+ [0, 75, 217, 1],
30
+ [0, 79, 216, 1],
31
+ [0, 83, 214, 1],
32
+ [0, 86, 212, 1],
33
+ [0, 90, 210, 1],
34
+ [0, 93, 208, 1],
35
+ [0, 97, 207, 1],
36
+ [0, 101, 205, 1],
37
+ [0, 104, 203, 1],
38
+ [0, 108, 201, 1],
39
+ [0, 111, 200, 1],
40
+ [0, 115, 198, 1],
41
+ [0, 119, 196, 1],
42
+ [0, 122, 194, 1],
43
+ [0, 126, 192, 1],
44
+ [0, 129, 191, 1],
45
+ [0, 133, 189, 1],
46
+ [0, 136, 187, 1],
47
+ [0, 140, 185, 1],
48
+ [0, 144, 183, 1],
49
+ [0, 147, 182, 1],
50
+ [0, 151, 180, 1],
51
+ [0, 154, 178, 1],
52
+ [0, 158, 176, 1],
53
+ [0, 162, 175, 1],
54
+ [0, 165, 173, 1],
55
+ [0, 169, 171, 1],
56
+ [0, 172, 169, 1],
57
+ [0, 176, 167, 1],
58
+ [0, 180, 166, 1],
59
+ [0, 183, 164, 1],
60
+ [0, 187, 162, 1],
61
+ [0, 190, 160, 1],
62
+ [0, 194, 158, 1],
63
+ [0, 198, 157, 1],
64
+ [0, 201, 155, 1],
65
+ [0, 205, 153, 1],
66
+ [0, 208, 151, 1],
67
+ [0, 212, 149, 1],
68
+ [0, 215, 148, 1],
69
+ [0, 219, 146, 1],
70
+ [0, 223, 144, 1],
71
+ [0, 226, 142, 1],
72
+ [0, 230, 141, 1],
73
+ [0, 233, 139, 1],
74
+ [0, 237, 137, 1],
75
+ [0, 241, 135, 1],
76
+ [0, 244, 133, 1],
77
+ [0, 248, 132, 1],
78
+ [0, 251, 130, 1],
79
+ [0, 255, 128, 1]])
80
+ })
81
+
82
+ test('Uses alpha in from/to', () => {
83
+ const actual = createColors([0, 0, 0, .2], [1, 1, 1, .8], 2)
84
+ expect(actual).toEqual([[0, 0, 0, .2], [1, 1, 1, .8]])
85
+ })
86
+
87
+ test('alpha in from but not in to, will use alpha in from', () => {
88
+ const actual = createColors([0, 0, 0, .2], [1, 1, 1], 2)
89
+ expect(actual).toEqual([[0, 0, 0, .2], [1, 1, 1, .2]])
90
+ })
91
+
92
+ test('alpha in `to` but not in `from`, will use alpha in `to`', () => {
93
+ const actual = createColors([0, 0, 0], [1, 1, 1, .5], 2)
94
+ expect(actual).toEqual([[0, 0, 0, .5], [1, 1, 1, .5]])
95
+ })
96
+
97
+
98
+ test('match actual colors', () => {
99
+ let actual = createColors([150, 0, 90], [0, 0, 200], 72, [0, 1])
100
+
101
+ t.deepStrictEqual(actual, [
102
+ [150, 0, 90, 0],
103
+ [148, 0, 92, 0.014084507042253521],
104
+ [146, 0, 93, 0.028169014084507043],
105
+ [144, 0, 95, 0.04225352112676056],
106
+ [142, 0, 96, 0.056338028169014086],
107
+ [139, 0, 98, 0.07042253521126761],
108
+ [137, 0, 99, 0.08450704225352113],
109
+ [135, 0, 101, 0.09859154929577466],
110
+ [133, 0, 102, 0.11267605633802817],
111
+ [131, 0, 104, 0.1267605633802817],
112
+ [129, 0, 105, 0.14084507042253522],
113
+ [127, 0, 107, 0.15492957746478875],
114
+ [125, 0, 109, 0.16901408450704225],
115
+ [123, 0, 110, 0.18309859154929578],
116
+ [120, 0, 112, 0.1971830985915493],
117
+ [118, 0, 113, 0.2112676056338028],
118
+ [116, 0, 115, 0.22535211267605634],
119
+ [114, 0, 116, 0.23943661971830987],
120
+ [112, 0, 118, 0.2535211267605634],
121
+ [110, 0, 119, 0.26760563380281693],
122
+ [108, 0, 121, 0.28169014084507044],
123
+ [106, 0, 123, 0.29577464788732394],
124
+ [104, 0, 124, 0.3098591549295775],
125
+ [101, 0, 126, 0.323943661971831],
126
+ [99, 0, 127, 0.3380281690140845],
127
+ [97, 0, 129, 0.35211267605633806],
128
+ [95, 0, 130, 0.36619718309859156],
129
+ [93, 0, 132, 0.38028169014084506],
130
+ [91, 0, 133, 0.3943661971830986],
131
+ [89, 0, 135, 0.4084507042253521],
132
+ [87, 0, 136, 0.4225352112676056],
133
+ [85, 0, 138, 0.4366197183098592],
134
+ [82, 0, 140, 0.4507042253521127],
135
+ [80, 0, 141, 0.4647887323943662],
136
+ [78, 0, 143, 0.47887323943661975],
137
+ [76, 0, 144, 0.49295774647887325],
138
+ [74, 0, 146, 0.5070422535211268],
139
+ [72, 0, 147, 0.5211267605633803],
140
+ [70, 0, 149, 0.5352112676056339],
141
+ [68, 0, 150, 0.5492957746478874],
142
+ [65, 0, 152, 0.5633802816901409],
143
+ [63, 0, 154, 0.5774647887323944],
144
+ [61, 0, 155, 0.5915492957746479],
145
+ [59, 0, 157, 0.6056338028169014],
146
+ [57, 0, 158, 0.619718309859155],
147
+ [55, 0, 160, 0.6338028169014085],
148
+ [53, 0, 161, 0.647887323943662],
149
+ [51, 0, 163, 0.6619718309859155],
150
+ [49, 0, 164, 0.676056338028169],
151
+ [46, 0, 166, 0.6901408450704225],
152
+ [44, 0, 167, 0.7042253521126761],
153
+ [42, 0, 169, 0.7183098591549296],
154
+ [40, 0, 171, 0.7323943661971831],
155
+ [38, 0, 172, 0.7464788732394366],
156
+ [36, 0, 174, 0.7605633802816901],
157
+ [34, 0, 175, 0.7746478873239436],
158
+ [32, 0, 177, 0.7887323943661972],
159
+ [30, 0, 178, 0.8028169014084507],
160
+ [27, 0, 180, 0.8169014084507042],
161
+ [25, 0, 181, 0.8309859154929577],
162
+ [23, 0, 183, 0.8450704225352113],
163
+ [21, 0, 185, 0.8591549295774648],
164
+ [19, 0, 186, 0.8732394366197184],
165
+ [17, 0, 188, 0.8873239436619719],
166
+ [15, 0, 189, 0.9014084507042254],
167
+ [13, 0, 191, 0.9154929577464789],
168
+ [11, 0, 192, 0.9295774647887324],
169
+ [8, 0, 194, 0.943661971830986],
170
+ [6, 0, 195, 0.9577464788732395],
171
+ [4, 0, 197, 0.971830985915493],
172
+ [2, 0, 198, 0.9859154929577465],
173
+ [0, 0, 200, 1]])
174
+ actual = createColors([150, 0, 90], [0, 0, 200], 72)
175
+ expect(actual).toEqual([[150, 0, 90, 1], [148, 0, 92, 1], [146, 0, 93, 1], [144, 0, 95, 1], [142, 0, 96, 1], [139, 0, 98, 1], [137, 0, 99, 1], [135, 0, 101, 1], [133, 0, 102, 1], [131, 0, 104, 1], [129, 0, 105, 1], [127, 0, 107, 1], [125, 0, 109, 1], [123, 0, 110, 1], [120, 0, 112, 1], [118, 0, 113, 1], [116, 0, 115, 1], [114, 0, 116, 1], [112, 0, 118, 1], [110, 0, 119, 1], [108, 0, 121, 1], [106, 0, 123, 1], [104, 0, 124, 1], [101, 0, 126, 1], [99, 0, 127, 1], [97, 0, 129, 1], [95, 0, 130, 1], [93, 0, 132, 1], [91, 0, 133, 1], [89, 0, 135, 1], [87, 0, 136, 1], [85, 0, 138, 1], [82, 0, 140, 1], [80, 0, 141, 1], [78, 0, 143, 1], [76, 0, 144, 1], [74, 0, 146, 1], [72, 0, 147, 1], [70, 0, 149, 1], [68, 0, 150, 1], [65, 0, 152, 1], [63, 0, 154, 1], [61, 0, 155, 1], [59, 0, 157, 1], [57, 0, 158, 1], [55, 0, 160, 1], [53, 0, 161, 1], [51, 0, 163, 1], [49, 0, 164, 1], [46, 0, 166, 1], [44, 0, 167, 1], [42, 0, 169, 1], [40, 0, 171, 1], [38, 0, 172, 1], [36, 0, 174, 1], [34, 0, 175, 1], [32, 0, 177, 1], [30, 0, 178, 1], [27, 0, 180, 1], [25, 0, 181, 1], [23, 0, 183, 1], [21, 0, 185, 1], [19, 0, 186, 1], [17, 0, 188, 1], [15, 0, 189, 1], [13, 0, 191, 1], [11, 0, 192, 1], [8, 0, 194, 1], [6, 0, 195, 1], [4, 0, 197, 1], [2, 0, 198, 1], [0, 0, 200, 1]])
176
+ })
File without changes
@@ -0,0 +1,11 @@
1
+ import a from 'assertron';
2
+ import { ColorMap, createColorsFromMap } from '.';
3
+
4
+ test('summer colors', () => {
5
+ const summer: ColorMap = [{ index: 0, rgb: [0, 128, 102] }, { index: 1, rgb: [255, 255, 102] }]
6
+
7
+ a.throws(() => createColorsFromMap(summer, 1))
8
+
9
+ const actual = createColorsFromMap(summer, 60)
10
+ expect(actual).toEqual([[0, 128, 102, 1], [4, 130, 102, 1], [9, 132, 102, 1], [13, 134, 102, 1], [17, 137, 102, 1], [22, 139, 102, 1], [26, 141, 102, 1], [30, 143, 102, 1], [35, 145, 102, 1], [39, 147, 102, 1], [43, 150, 102, 1], [48, 152, 102, 1], [52, 154, 102, 1], [56, 156, 102, 1], [61, 158, 102, 1], [65, 160, 102, 1], [69, 162, 102, 1], [73, 165, 102, 1], [78, 167, 102, 1], [82, 169, 102, 1], [86, 171, 102, 1], [91, 173, 102, 1], [95, 175, 102, 1], [99, 178, 102, 1], [104, 180, 102, 1], [108, 182, 102, 1], [112, 184, 102, 1], [117, 186, 102, 1], [121, 188, 102, 1], [125, 190, 102, 1], [130, 193, 102, 1], [134, 195, 102, 1], [138, 197, 102, 1], [143, 199, 102, 1], [147, 201, 102, 1], [151, 203, 102, 1], [156, 205, 102, 1], [160, 208, 102, 1], [164, 210, 102, 1], [169, 212, 102, 1], [173, 214, 102, 1], [177, 216, 102, 1], [182, 218, 102, 1], [186, 221, 102, 1], [190, 223, 102, 1], [194, 225, 102, 1], [199, 227, 102, 1], [203, 229, 102, 1], [207, 231, 102, 1], [212, 233, 102, 1], [216, 236, 102, 1], [220, 238, 102, 1], [225, 240, 102, 1], [229, 242, 102, 1], [233, 244, 102, 1], [238, 246, 102, 1], [242, 249, 102, 1], [246, 251, 102, 1], [251, 253, 102, 1], [255, 255, 102, 1]])
11
+ })
File without changes
File without changes
File without changes
@@ -0,0 +1,17 @@
1
+ import { rgbHex } from '.'
2
+
3
+ test('[0,0,0] => #000000', () => {
4
+ expect(rgbHex([0, 0, 0])).toBe('#000000')
5
+ })
6
+
7
+ test('[255,128,16] => #ff8010', () => {
8
+ expect(rgbHex([255, 128, 16])).toBe('#ff8010')
9
+ })
10
+
11
+ test('[255,128,16,0] => #ff8010', () => {
12
+ expect(rgbHex([255, 128, 16, 0])).toBe('#ff8010')
13
+ })
14
+
15
+ test('[255,128,16,0.8] => #ff8010', () => {
16
+ expect(rgbHex([255, 128, 16, 0.8])).toBe('#ff8010')
17
+ })
@@ -13,6 +13,6 @@ export function rgbHex(rgb: RGB | RGBA) {
13
13
  }
14
14
 
15
15
  function d2h(d: number) {
16
- let s = (+d).toString(16)
16
+ const s = (+d).toString(16)
17
17
  return s.length < 2 ? '0' + s : s
18
18
  }
@@ -0,0 +1,9 @@
1
+ import { rgbaString } from '.';
2
+
3
+ test('[255,128,16,0] => rgba(255,128,16,0)', () => {
4
+ expect(rgbaString([255, 128, 16, 0])).toBe('rgba(255,128,16,0)')
5
+ })
6
+
7
+ test('[255,128,16,0.3] => rgba(255,128,16,0.3)', () => {
8
+ expect(rgbaString([255, 128, 16, 0.3])).toBe('rgba(255,128,16,0.3)')
9
+ })
File without changes
@@ -1 +0,0 @@
1
- {"version":3,"file":"createColors.js","sourceRoot":"","sources":["../src/createColors.ts"],"names":[],"mappings":"AAEA,MAAM,uBACJ,IAAgB,EAChB,EAAc,EACd,MAAc,EACd,QAAe;IACb,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC1D;IACD,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;IACvB,MAAM,IAAI,GAAG;QACX,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACf,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACf,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACf,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;KACpB,CAAA;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QACpB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAEtB,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;IAEvC,MAAM,IAAI,GAAU,EAAE,CAAA;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,MAAM,KAAK,GAAG;YACZ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YACxC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YACxC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YACxC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG;SAC7B,CAAA;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;KACjB;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createColorsFromMap.js","sourceRoot":"","sources":["../src/createColorsFromMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C;;GAEG;AACH,MAAM,8BAA8B,QAAkB,EAAE,MAAc,EAAE,KAAa;IACnF,IAAI,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,CAAC,MAAM,UAAU,CAAC,CAAA;KAChE;IAED,MAAM,MAAM,GAAW,EAAE,CAAA;IACzB,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACxC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAA;KACnD;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC5C,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACjC,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAC7B,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;KACjD;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AAErC,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=interfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rgbHex.js","sourceRoot":"","sources":["../src/rgbHex.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,iBAAiB,GAAe;IACpC,IAAI,GAAG,GAAG,GAAG,CAAA;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;KACnB;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,aAAa,CAAS;IACpB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IACzB,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACnC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"rgbaString.js","sourceRoot":"","sources":["../src/rgbaString.ts"],"names":[],"mappings":"AAEA,MAAM,qBAAqB,IAAU;IACnC,OAAO,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AACxC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createColors.js","sourceRoot":"","sources":["../src/createColors.ts"],"names":[],"mappings":";;AAEA,sBACE,IAAgB,EAChB,EAAc,EACd,MAAc,EACd,KAGC;IAHD,sBAAA,EAAA;QACE,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC1D;IACD,IAAM,KAAK,GAAO,IAAI,QAAC,CAAA;IACvB,IAAM,IAAI,GAAG;QACX,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACf,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACf,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QACf,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;KACpB,CAAA;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QACpB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAEtB,IAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;IAEvC,IAAM,IAAI,GAAU,EAAE,CAAA;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAM,KAAK,GAAG;YACZ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YACxC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YACxC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;YACxC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG;SAC7B,CAAA;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;KACjB;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAhCD,oCAgCC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createColorsFromMap.js","sourceRoot":"","sources":["../src/createColorsFromMap.ts"],"names":[],"mappings":";;AAAA,+CAA6C;AAG7C;;GAEG;AACH,6BAAoC,QAAkB,EAAE,MAAc,EAAE,KAAa;IACnF,IAAI,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,uBAAqB,QAAQ,CAAC,MAAM,aAAU,CAAC,CAAA;KAChE;IAED,IAAM,MAAM,GAAW,EAAE,CAAA;IACzB,IAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACxC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAA;KACnD;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC5C,IAAM,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACjC,IAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAC7B,IAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAC/B,MAAM,CAAC,IAAI,OAAX,MAAM,EAAS,2BAAY,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,EAAC;KACjD;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAnBD,kDAmBC"}
package/dist-es5/index.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- function __export(m) {
3
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
- }
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- __export(require("./createColors"));
7
- __export(require("./createColorsFromMap"));
8
- __export(require("./rgbHex"));
9
- __export(require("./rgbaString"));
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,oCAA8B;AAC9B,2CAAqC;AAErC,8BAAwB;AACxB,kCAA4B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"rgbHex.js","sourceRoot":"","sources":["../src/rgbHex.ts"],"names":[],"mappings":";;AAEA;;;GAGG;AACH,gBAAuB,GAAe;IACpC,IAAI,GAAG,GAAG,GAAG,CAAA;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;KACnB;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAND,wBAMC;AAED,aAAa,CAAS;IACpB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IACzB,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACnC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"rgbaString.js","sourceRoot":"","sources":["../src/rgbaString.ts"],"names":[],"mappings":";;AAEA,oBAA2B,IAAU;IACnC,OAAO,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AACxC,CAAC;AAFD,gCAEC"}
@@ -1,175 +0,0 @@
1
- import test from 'ava'
2
-
3
- import { createColors } from './createColors'
4
-
5
- test('match colormap output', t => {
6
- const actual = createColors([0, 0, 255], [0, 255, 128], 72)
7
-
8
- t.deepEqual(actual, [[0, 0, 255, 1],
9
- [0, 4, 253, 1],
10
- [0, 7, 251, 1],
11
- [0, 11, 250, 1],
12
- [0, 14, 248, 1],
13
- [0, 18, 246, 1],
14
- [0, 22, 244, 1],
15
- [0, 25, 242, 1],
16
- [0, 29, 241, 1],
17
- [0, 32, 239, 1],
18
- [0, 36, 237, 1],
19
- [0, 40, 235, 1],
20
- [0, 43, 234, 1],
21
- [0, 47, 232, 1],
22
- [0, 50, 230, 1],
23
- [0, 54, 228, 1],
24
- [0, 57, 226, 1],
25
- [0, 61, 225, 1],
26
- [0, 65, 223, 1],
27
- [0, 68, 221, 1],
28
- [0, 72, 219, 1],
29
- [0, 75, 217, 1],
30
- [0, 79, 216, 1],
31
- [0, 83, 214, 1],
32
- [0, 86, 212, 1],
33
- [0, 90, 210, 1],
34
- [0, 93, 208, 1],
35
- [0, 97, 207, 1],
36
- [0, 101, 205, 1],
37
- [0, 104, 203, 1],
38
- [0, 108, 201, 1],
39
- [0, 111, 200, 1],
40
- [0, 115, 198, 1],
41
- [0, 119, 196, 1],
42
- [0, 122, 194, 1],
43
- [0, 126, 192, 1],
44
- [0, 129, 191, 1],
45
- [0, 133, 189, 1],
46
- [0, 136, 187, 1],
47
- [0, 140, 185, 1],
48
- [0, 144, 183, 1],
49
- [0, 147, 182, 1],
50
- [0, 151, 180, 1],
51
- [0, 154, 178, 1],
52
- [0, 158, 176, 1],
53
- [0, 162, 175, 1],
54
- [0, 165, 173, 1],
55
- [0, 169, 171, 1],
56
- [0, 172, 169, 1],
57
- [0, 176, 167, 1],
58
- [0, 180, 166, 1],
59
- [0, 183, 164, 1],
60
- [0, 187, 162, 1],
61
- [0, 190, 160, 1],
62
- [0, 194, 158, 1],
63
- [0, 198, 157, 1],
64
- [0, 201, 155, 1],
65
- [0, 205, 153, 1],
66
- [0, 208, 151, 1],
67
- [0, 212, 149, 1],
68
- [0, 215, 148, 1],
69
- [0, 219, 146, 1],
70
- [0, 223, 144, 1],
71
- [0, 226, 142, 1],
72
- [0, 230, 141, 1],
73
- [0, 233, 139, 1],
74
- [0, 237, 137, 1],
75
- [0, 241, 135, 1],
76
- [0, 244, 133, 1],
77
- [0, 248, 132, 1],
78
- [0, 251, 130, 1],
79
- [0, 255, 128, 1]])
80
- })
81
-
82
- test('Uses alpha in from/to', t => {
83
- const actual = createColors([0, 0, 0, .2], [1, 1, 1, .8], 2)
84
- t.deepEqual(actual, [[0, 0, 0, .2], [1, 1, 1, .8]])
85
- })
86
-
87
- test('alpha in from but not in to, will use alpha in from', t => {
88
- const actual = createColors([0, 0, 0, .2], [1, 1, 1], 2)
89
- t.deepEqual(actual, [[0, 0, 0, .2], [1, 1, 1, .2]])
90
- })
91
-
92
- test('alpha in `to` but not in `from`, will use alpha in `to`', t => {
93
- const actual = createColors([0, 0, 0], [1, 1, 1, .5], 2)
94
- t.deepEqual(actual, [[0, 0, 0, .5], [1, 1, 1, .5]])
95
- })
96
-
97
-
98
- test('match actual colors', t => {
99
- let actual = createColors([150, 0, 90], [0, 0, 200], 72, [0, 1])
100
-
101
- t.deepEqual(actual, [[150, 0, 90, 0],
102
- [148, 0, 92, 0.014084507042253521],
103
- [146, 0, 93, 0.028169014084507043],
104
- [144, 0, 95, 0.04225352112676056],
105
- [142, 0, 96, 0.056338028169014086],
106
- [139, 0, 98, 0.07042253521126761],
107
- [137, 0, 99, 0.08450704225352113],
108
- [135, 0, 101, 0.09859154929577466],
109
- [133, 0, 102, 0.11267605633802817],
110
- [131, 0, 104, 0.1267605633802817],
111
- [129, 0, 105, 0.14084507042253522],
112
- [127, 0, 107, 0.15492957746478875],
113
- [125, 0, 109, 0.16901408450704225],
114
- [123, 0, 110, 0.18309859154929578],
115
- [120, 0, 112, 0.1971830985915493],
116
- [118, 0, 113, 0.2112676056338028],
117
- [116, 0, 115, 0.22535211267605634],
118
- [114, 0, 116, 0.23943661971830987],
119
- [112, 0, 118, 0.2535211267605634],
120
- [110, 0, 119, 0.26760563380281693],
121
- [108, 0, 121, 0.28169014084507044],
122
- [106, 0, 123, 0.29577464788732394],
123
- [104, 0, 124, 0.3098591549295775],
124
- [101, 0, 126, 0.323943661971831],
125
- [99, 0, 127, 0.3380281690140845],
126
- [97, 0, 129, 0.35211267605633806],
127
- [95, 0, 130, 0.36619718309859156],
128
- [93, 0, 132, 0.38028169014084506],
129
- [91, 0, 133, 0.3943661971830986],
130
- [89, 0, 135, 0.4084507042253521],
131
- [87, 0, 136, 0.4225352112676056],
132
- [85, 0, 138, 0.4366197183098592],
133
- [82, 0, 140, 0.4507042253521127],
134
- [80, 0, 141, 0.4647887323943662],
135
- [78, 0, 143, 0.47887323943661975],
136
- [76, 0, 144, 0.49295774647887325],
137
- [74, 0, 146, 0.5070422535211268],
138
- [72, 0, 147, 0.5211267605633803],
139
- [70, 0, 149, 0.5352112676056339],
140
- [68, 0, 150, 0.5492957746478874],
141
- [65, 0, 152, 0.5633802816901409],
142
- [63, 0, 154, 0.5774647887323944],
143
- [61, 0, 155, 0.5915492957746479],
144
- [59, 0, 157, 0.6056338028169014],
145
- [57, 0, 158, 0.619718309859155],
146
- [55, 0, 160, 0.6338028169014085],
147
- [53, 0, 161, 0.647887323943662],
148
- [51, 0, 163, 0.6619718309859155],
149
- [49, 0, 164, 0.676056338028169],
150
- [46, 0, 166, 0.6901408450704225],
151
- [44, 0, 167, 0.7042253521126761],
152
- [42, 0, 169, 0.7183098591549296],
153
- [40, 0, 171, 0.7323943661971831],
154
- [38, 0, 172, 0.7464788732394366],
155
- [36, 0, 174, 0.7605633802816901],
156
- [34, 0, 175, 0.7746478873239436],
157
- [32, 0, 177, 0.7887323943661972],
158
- [30, 0, 178, 0.8028169014084507],
159
- [27, 0, 180, 0.8169014084507042],
160
- [25, 0, 181, 0.8309859154929577],
161
- [23, 0, 183, 0.8450704225352113],
162
- [21, 0, 185, 0.8591549295774648],
163
- [19, 0, 186, 0.8732394366197184],
164
- [17, 0, 188, 0.8873239436619719],
165
- [15, 0, 189, 0.9014084507042254],
166
- [13, 0, 191, 0.9154929577464789],
167
- [11, 0, 192, 0.9295774647887324],
168
- [8, 0, 194, 0.943661971830986],
169
- [6, 0, 195, 0.9577464788732395],
170
- [4, 0, 197, 0.971830985915493],
171
- [2, 0, 198, 0.9859154929577465],
172
- [0, 0, 200, 1]])
173
- actual = createColors([150, 0, 90], [0, 0, 200], 72)
174
- t.deepEqual(actual, [[150, 0, 90, 1], [148, 0, 92, 1], [146, 0, 93, 1], [144, 0, 95, 1], [142, 0, 96, 1], [139, 0, 98, 1], [137, 0, 99, 1], [135, 0, 101, 1], [133, 0, 102, 1], [131, 0, 104, 1], [129, 0, 105, 1], [127, 0, 107, 1], [125, 0, 109, 1], [123, 0, 110, 1], [120, 0, 112, 1], [118, 0, 113, 1], [116, 0, 115, 1], [114, 0, 116, 1], [112, 0, 118, 1], [110, 0, 119, 1], [108, 0, 121, 1], [106, 0, 123, 1], [104, 0, 124, 1], [101, 0, 126, 1], [99, 0, 127, 1], [97, 0, 129, 1], [95, 0, 130, 1], [93, 0, 132, 1], [91, 0, 133, 1], [89, 0, 135, 1], [87, 0, 136, 1], [85, 0, 138, 1], [82, 0, 140, 1], [80, 0, 141, 1], [78, 0, 143, 1], [76, 0, 144, 1], [74, 0, 146, 1], [72, 0, 147, 1], [70, 0, 149, 1], [68, 0, 150, 1], [65, 0, 152, 1], [63, 0, 154, 1], [61, 0, 155, 1], [59, 0, 157, 1], [57, 0, 158, 1], [55, 0, 160, 1], [53, 0, 161, 1], [51, 0, 163, 1], [49, 0, 164, 1], [46, 0, 166, 1], [44, 0, 167, 1], [42, 0, 169, 1], [40, 0, 171, 1], [38, 0, 172, 1], [36, 0, 174, 1], [34, 0, 175, 1], [32, 0, 177, 1], [30, 0, 178, 1], [27, 0, 180, 1], [25, 0, 181, 1], [23, 0, 183, 1], [21, 0, 185, 1], [19, 0, 186, 1], [17, 0, 188, 1], [15, 0, 189, 1], [13, 0, 191, 1], [11, 0, 192, 1], [8, 0, 194, 1], [6, 0, 195, 1], [4, 0, 197, 1], [2, 0, 198, 1], [0, 0, 200, 1]])
175
- })
@@ -1,13 +0,0 @@
1
- import test from 'ava'
2
-
3
- import { ColorMap } from './interfaces'
4
- import { createColorsFromMap } from './createColorsFromMap'
5
-
6
- test('summer colors', t => {
7
- const summer: ColorMap = [{ index: 0, rgb: [0, 128, 102] }, { index: 1, rgb: [255, 255, 102] }]
8
-
9
- t.throws(() => createColorsFromMap(summer, 1))
10
-
11
- const colors = createColorsFromMap(summer, 60)
12
- t.deepEqual(colors, [[0, 128, 102, 1], [4, 130, 102, 1], [9, 132, 102, 1], [13, 134, 102, 1], [17, 137, 102, 1], [22, 139, 102, 1], [26, 141, 102, 1], [30, 143, 102, 1], [35, 145, 102, 1], [39, 147, 102, 1], [43, 150, 102, 1], [48, 152, 102, 1], [52, 154, 102, 1], [56, 156, 102, 1], [61, 158, 102, 1], [65, 160, 102, 1], [69, 162, 102, 1], [73, 165, 102, 1], [78, 167, 102, 1], [82, 169, 102, 1], [86, 171, 102, 1], [91, 173, 102, 1], [95, 175, 102, 1], [99, 178, 102, 1], [104, 180, 102, 1], [108, 182, 102, 1], [112, 184, 102, 1], [117, 186, 102, 1], [121, 188, 102, 1], [125, 190, 102, 1], [130, 193, 102, 1], [134, 195, 102, 1], [138, 197, 102, 1], [143, 199, 102, 1], [147, 201, 102, 1], [151, 203, 102, 1], [156, 205, 102, 1], [160, 208, 102, 1], [164, 210, 102, 1], [169, 212, 102, 1], [173, 214, 102, 1], [177, 216, 102, 1], [182, 218, 102, 1], [186, 221, 102, 1], [190, 223, 102, 1], [194, 225, 102, 1], [199, 227, 102, 1], [203, 229, 102, 1], [207, 231, 102, 1], [212, 233, 102, 1], [216, 236, 102, 1], [220, 238, 102, 1], [225, 240, 102, 1], [229, 242, 102, 1], [233, 244, 102, 1], [238, 246, 102, 1], [242, 249, 102, 1], [246, 251, 102, 1], [251, 253, 102, 1], [255, 255, 102, 1]])
13
- })
@@ -1,19 +0,0 @@
1
- import test from 'ava'
2
-
3
- import { rgbHex } from './rgbHex'
4
-
5
- test('[0,0,0] => #000000', t => {
6
- t.is(rgbHex([0, 0, 0]), '#000000')
7
- })
8
-
9
- test('[255,128,16] => #ff8010', t => {
10
- t.is(rgbHex([255, 128, 16]), '#ff8010')
11
- })
12
-
13
- test('[255,128,16,0] => #ff8010', t => {
14
- t.is(rgbHex([255, 128, 16, 0]), '#ff8010')
15
- })
16
-
17
- test('[255,128,16,0.8] => #ff8010', t => {
18
- t.is(rgbHex([255, 128, 16, 0.8]), '#ff8010')
19
- })
@@ -1,11 +0,0 @@
1
- import test from 'ava'
2
-
3
- import { rgbaString } from './rgbaString'
4
-
5
- test('[255,128,16,0] => rgba(255,128,16,0)', t => {
6
- t.is(rgbaString([255, 128, 16, 0]), 'rgba(255,128,16,0)')
7
- })
8
-
9
- test('[255,128,16,0.3] => rgba(255,128,16,0.3)', t => {
10
- t.is(rgbaString([255, 128, 16, 0.3]), 'rgba(255,128,16,0.3)')
11
- })