color-map 2.1.0 → 2.2.0

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 (77) hide show
  1. package/README.md +0 -3
  2. package/cjs/index.d.ts +37 -5
  3. package/cjs/index.d.ts.map +1 -0
  4. package/cjs/index.js +68 -20
  5. package/cjs/index.js.map +1 -1
  6. package/cjs/package.json +1 -1
  7. package/dist/color-map.es5.js +1 -1
  8. package/dist/color-map.es5.js.map +1 -1
  9. package/esm/createColors.d.ts +6 -2
  10. package/esm/createColors.d.ts.map +1 -0
  11. package/esm/createColors.js +25 -25
  12. package/esm/createColors.js.map +1 -1
  13. package/esm/createColorsFromMap.d.ts +6 -2
  14. package/esm/createColorsFromMap.d.ts.map +1 -0
  15. package/esm/createColorsFromMap.js +19 -19
  16. package/esm/createColorsFromMap.js.map +1 -1
  17. package/esm/index.d.ts +6 -5
  18. package/esm/index.js +5 -5
  19. package/esm/interfaces.d.ts +17 -13
  20. package/esm/interfaces.d.ts.map +1 -0
  21. package/esm/rgbHex.d.ts +6 -2
  22. package/esm/rgbHex.d.ts.map +1 -0
  23. package/esm/rgbHex.js +13 -11
  24. package/esm/rgbHex.js.map +1 -1
  25. package/esm/rgbaString.d.ts +6 -2
  26. package/esm/rgbaString.d.ts.map +1 -0
  27. package/esm/rgbaString.js +6 -2
  28. package/esm/rgbaString.js.map +1 -1
  29. package/package.json +63 -91
  30. package/ts/createColors.ts +24 -29
  31. package/ts/createColorsFromMap.ts +16 -16
  32. package/ts/index.ts +1 -1
  33. package/ts/interfaces.ts +9 -9
  34. package/ts/rgbHex.ts +7 -7
  35. package/ts/rgbaString.ts +1 -1
  36. package/cjs/createColors.d.ts +0 -2
  37. package/cjs/createColors.js +0 -40
  38. package/cjs/createColors.js.map +0 -1
  39. package/cjs/createColors.spec.d.ts +0 -1
  40. package/cjs/createColors.spec.js +0 -176
  41. package/cjs/createColors.spec.js.map +0 -1
  42. package/cjs/createColorsFromMap.d.ts +0 -5
  43. package/cjs/createColorsFromMap.js +0 -25
  44. package/cjs/createColorsFromMap.js.map +0 -1
  45. package/cjs/createColorsFromMap.spec.d.ts +0 -1
  46. package/cjs/createColorsFromMap.spec.js +0 -11
  47. package/cjs/createColorsFromMap.spec.js.map +0 -1
  48. package/cjs/interfaces.d.ts +0 -14
  49. package/cjs/interfaces.js +0 -3
  50. package/cjs/interfaces.js.map +0 -1
  51. package/cjs/rgbHex.d.ts +0 -6
  52. package/cjs/rgbHex.js +0 -19
  53. package/cjs/rgbHex.js.map +0 -1
  54. package/cjs/rgbHex.spec.d.ts +0 -1
  55. package/cjs/rgbHex.spec.js +0 -16
  56. package/cjs/rgbHex.spec.js.map +0 -1
  57. package/cjs/rgbaString.d.ts +0 -2
  58. package/cjs/rgbaString.js +0 -7
  59. package/cjs/rgbaString.js.map +0 -1
  60. package/cjs/rgbaString.spec.d.ts +0 -1
  61. package/cjs/rgbaString.spec.js +0 -10
  62. package/cjs/rgbaString.spec.js.map +0 -1
  63. package/esm/createColors.spec.d.ts +0 -1
  64. package/esm/createColors.spec.js +0 -171
  65. package/esm/createColors.spec.js.map +0 -1
  66. package/esm/createColorsFromMap.spec.d.ts +0 -1
  67. package/esm/createColorsFromMap.spec.js +0 -9
  68. package/esm/createColorsFromMap.spec.js.map +0 -1
  69. package/esm/index.js.map +0 -1
  70. package/esm/interfaces.js +0 -2
  71. package/esm/interfaces.js.map +0 -1
  72. package/esm/rgbHex.spec.d.ts +0 -1
  73. package/esm/rgbHex.spec.js +0 -14
  74. package/esm/rgbHex.spec.js.map +0 -1
  75. package/esm/rgbaString.spec.d.ts +0 -1
  76. package/esm/rgbaString.spec.js +0 -8
  77. package/esm/rgbaString.spec.js.map +0 -1
package/README.md CHANGED
@@ -9,7 +9,6 @@
9
9
  [![Semantic Release][semantic-release-image]][semantic-release-url]
10
10
 
11
11
  [![Visual Studio Code][vscode-image]][vscode-url]
12
- [![Wallaby.js][wallaby-image]][wallaby-url]
13
12
 
14
13
  Color map generator with no dependency.
15
14
 
@@ -84,5 +83,3 @@ git push
84
83
  [semantic-release-url]: https://github.com/semantic-release/semantic-release
85
84
  [vscode-image]: https://img.shields.io/badge/vscode-ready-green.svg
86
85
  [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
package/cjs/index.d.ts CHANGED
@@ -1,5 +1,37 @@
1
- export * from './createColors.js';
2
- export * from './createColorsFromMap.js';
3
- export type { Alpha, ColorMap, RGB, RGBA } from './interfaces.js';
4
- export * from './rgbHex.js';
5
- export * from './rgbaString.js';
1
+ //#region ts/interfaces.d.ts
2
+ type RGB = [number, number, number];
3
+ type RGBA = [number, number, number, number];
4
+ type Alpha = [number, number];
5
+ type ColorMap = {
6
+ /**
7
+ * Defines how fast or slow the `rgb` values will change from one segment to the next.
8
+ * i.e. the steepness of the gradient between two segments.
9
+ */
10
+ index: number;
11
+ /**
12
+ * RGB or RGBA. if RGBA, this alpha will be used instead of the alpha specified in the call.
13
+ */
14
+ rgb: RGB | RGBA;
15
+ }[];
16
+ //#endregion
17
+ //#region ts/createColors.d.ts
18
+ declare function createColors(from: RGB | RGBA, to: RGB | RGBA, shades: number, alpha?: Alpha): RGBA[];
19
+ //#endregion
20
+ //#region ts/createColorsFromMap.d.ts
21
+ /**
22
+ * Create colors with specified color map.
23
+ */
24
+ declare function createColorsFromMap(colormap: ColorMap, shades: number, alpha?: Alpha): RGBA[];
25
+ //#endregion
26
+ //#region ts/rgbaString.d.ts
27
+ declare function rgbaString(rgba: RGBA): string;
28
+ //#endregion
29
+ //#region ts/rgbHex.d.ts
30
+ /**
31
+ * Convert `RGB` to `#rgb`
32
+ * JavaScript note: no check for array length, use it properly.
33
+ */
34
+ declare function rgbHex(rgb: RGB | RGBA): string;
35
+ //#endregion
36
+ export { type Alpha, type ColorMap, type RGB, type RGBA, createColors, createColorsFromMap, rgbHex, rgbaString };
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../ts/interfaces.ts","../ts/createColors.ts","../ts/createColorsFromMap.ts","../ts/rgbaString.ts","../ts/rgbHex.ts"],"mappings":";KAAY;KACA;KACA;KAEA;;;;;EAKX;;;;EAIA,KAAK,MAAM;;;;iBCXI,aACf,MAAM,MAAM,MACZ,IAAI,MAAM,MACV,gBACA,QAAO,QAIL;;;;;;iBCJa,oBAAoB,UAAU,UAAU,gBAAgB,QAAQ,QAAQ;;;iBCJxE,WAAW,MAAM;;;;;;;iBCIjB,OAAO,KAAK,MAAM"}
package/cjs/index.js CHANGED
@@ -1,21 +1,69 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./createColors.js"), exports);
18
- __exportStar(require("./createColorsFromMap.js"), exports);
19
- __exportStar(require("./rgbHex.js"), exports);
20
- __exportStar(require("./rgbaString.js"), exports);
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region ts/createColors.ts
3
+ function createColors(from, to, shades, alpha = [from.length === 4 ? from[3] : to.length === 4 ? to[3] : 1, to.length === 4 ? to[3] : from.length === 4 ? from[3] : 1]) {
4
+ const start = [...from];
5
+ const diff = [
6
+ to[0] - from[0],
7
+ to[1] - from[1],
8
+ to[2] - from[2],
9
+ alpha[1] - alpha[0]
10
+ ];
11
+ if (start.length === 3) start.push(alpha[0]);
12
+ const inc = 1 / Math.max(shades - 1, 1);
13
+ const rgba = [];
14
+ for (let i = 0; i < shades; i++) {
15
+ const color = [
16
+ Math.round(start[0] + i * diff[0] * inc),
17
+ Math.round(start[1] + i * diff[1] * inc),
18
+ Math.round(start[2] + i * diff[2] * inc),
19
+ start[3] + i * diff[3] * inc
20
+ ];
21
+ rgba.push(color);
22
+ }
23
+ return rgba;
24
+ }
25
+ //#endregion
26
+ //#region ts/createColorsFromMap.ts
27
+ /**
28
+ * Create colors with specified color map.
29
+ */
30
+ function createColorsFromMap(colormap, shades, alpha) {
31
+ if (shades < colormap.length) throw new Error(`Requires at least ${colormap.length} shades.`);
32
+ const result = [];
33
+ const steps = [];
34
+ for (let i = 0; i < colormap.length; i++) steps.push(Math.round(colormap[i].index * shades));
35
+ for (let i = 0; i < colormap.length - 1; i++) {
36
+ const n = steps[i + 1] - steps[i];
37
+ const from = colormap[i].rgb;
38
+ const to = colormap[i + 1].rgb;
39
+ result.push(...createColors(from, to, n, alpha));
40
+ }
41
+ return result;
42
+ }
43
+ //#endregion
44
+ //#region ts/rgbaString.ts
45
+ function rgbaString(rgba) {
46
+ return "rgba(" + rgba.join(",") + ")";
47
+ }
48
+ //#endregion
49
+ //#region ts/rgbHex.ts
50
+ /**
51
+ * Convert `RGB` to `#rgb`
52
+ * JavaScript note: no check for array length, use it properly.
53
+ */
54
+ function rgbHex(rgb) {
55
+ let hex = "#";
56
+ for (let i = 0; i < 3; i++) hex += d2h(rgb[i]);
57
+ return hex;
58
+ }
59
+ function d2h(d) {
60
+ const s = (+d).toString(16);
61
+ return s.length < 2 ? "0" + s : s;
62
+ }
63
+ //#endregion
64
+ exports.createColors = createColors;
65
+ exports.createColorsFromMap = createColorsFromMap;
66
+ exports.rgbHex = rgbHex;
67
+ exports.rgbaString = rgbaString;
68
+
21
69
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,2DAAwC;AAExC,8CAA2B;AAC3B,kDAA+B"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../ts/createColors.ts","../ts/createColorsFromMap.ts","../ts/rgbaString.ts","../ts/rgbHex.ts"],"sourcesContent":["import type { Alpha, RGB, RGBA } from './interfaces.js'\n\nexport function createColors(\n\tfrom: RGB | RGBA,\n\tto: RGB | RGBA,\n\tshades: number,\n\talpha: Alpha = [\n\t\tfrom.length === 4 ? from[3] : to.length === 4 ? to[3] : 1,\n\t\tto.length === 4 ? to[3] : from.length === 4 ? from[3] : 1\n\t]\n): RGBA[] {\n\tconst start = [...from]\n\tconst diff = [to[0] - from[0], to[1] - from[1], to[2] - from[2], alpha[1] - alpha[0]]\n\n\tif (start.length === 3) start.push(alpha[0])\n\n\tconst inc = 1 / Math.max(shades - 1, 1)\n\n\tconst rgba: any[] = []\n\tfor (let i = 0; i < shades; i++) {\n\t\tconst color = [\n\t\t\tMath.round(start[0] + i * diff[0] * inc),\n\t\t\tMath.round(start[1] + i * diff[1] * inc),\n\t\t\tMath.round(start[2] + i * diff[2] * inc),\n\t\t\tstart[3] + i * diff[3] * inc\n\t\t]\n\t\trgba.push(color)\n\t}\n\treturn rgba\n}\n","import { createColors } from './createColors.js'\nimport type { Alpha, ColorMap, RGBA } from './interfaces.js'\n\n/**\n * Create colors with specified color map.\n */\nexport function createColorsFromMap(colormap: ColorMap, shades: number, alpha?: Alpha): RGBA[] {\n\tif (shades < colormap.length) {\n\t\tthrow new Error(`Requires at least ${colormap.length} shades.`)\n\t}\n\n\tconst result: RGBA[] = []\n\tconst steps: number[] = []\n\tfor (let i = 0; i < colormap.length; i++) {\n\t\tsteps.push(Math.round(colormap[i].index * shades))\n\t}\n\n\tfor (let i = 0; i < colormap.length - 1; i++) {\n\t\tconst n = steps[i + 1] - steps[i]\n\t\tconst from = colormap[i].rgb\n\t\tconst to = colormap[i + 1].rgb\n\t\tresult.push(...createColors(from, to, n, alpha))\n\t}\n\n\treturn result\n}\n","import type { RGBA } from './interfaces.js'\n\nexport function rgbaString(rgba: RGBA) {\n\treturn 'rgba(' + rgba.join(',') + ')'\n}\n","import type { RGB, RGBA } from './interfaces.js'\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\tlet hex = '#'\n\tfor (let i = 0; i < 3; i++) {\n\t\thex += d2h(rgb[i])\n\t}\n\treturn hex\n}\n\nfunction d2h(d: number) {\n\tconst s = (+d).toString(16)\n\treturn s.length < 2 ? '0' + s : s\n}\n"],"mappings":";;AAEA,SAAgB,aACf,MACA,IACA,QACA,QAAe,CACd,KAAK,WAAW,IAAI,KAAK,KAAK,GAAG,WAAW,IAAI,GAAG,KAAK,GACxD,GAAG,WAAW,IAAI,GAAG,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,CACzD,GACS;CACT,MAAM,QAAQ,CAAC,GAAG,IAAI;CACtB,MAAM,OAAO;EAAC,GAAG,KAAK,KAAK;EAAI,GAAG,KAAK,KAAK;EAAI,GAAG,KAAK,KAAK;EAAI,MAAM,KAAK,MAAM;CAAE;CAEpF,IAAI,MAAM,WAAW,GAAG,MAAM,KAAK,MAAM,EAAE;CAE3C,MAAM,MAAM,IAAI,KAAK,IAAI,SAAS,GAAG,CAAC;CAEtC,MAAM,OAAc,CAAC;CACrB,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,KAAK;EAChC,MAAM,QAAQ;GACb,KAAK,MAAM,MAAM,KAAK,IAAI,KAAK,KAAK,GAAG;GACvC,KAAK,MAAM,MAAM,KAAK,IAAI,KAAK,KAAK,GAAG;GACvC,KAAK,MAAM,MAAM,KAAK,IAAI,KAAK,KAAK,GAAG;GACvC,MAAM,KAAK,IAAI,KAAK,KAAK;EAC1B;EACA,KAAK,KAAK,KAAK;CAChB;CACA,OAAO;AACR;;;;;;ACvBA,SAAgB,oBAAoB,UAAoB,QAAgB,OAAuB;CAC9F,IAAI,SAAS,SAAS,QACrB,MAAM,IAAI,MAAM,qBAAqB,SAAS,OAAO,SAAS;CAG/D,MAAM,SAAiB,CAAC;CACxB,MAAM,QAAkB,CAAC;CACzB,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KACpC,MAAM,KAAK,KAAK,MAAM,SAAS,EAAE,CAAC,QAAQ,MAAM,CAAC;CAGlD,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,SAAS,GAAG,KAAK;EAC7C,MAAM,IAAI,MAAM,IAAI,KAAK,MAAM;EAC/B,MAAM,OAAO,SAAS,EAAE,CAAC;EACzB,MAAM,KAAK,SAAS,IAAI,EAAE,CAAC;EAC3B,OAAO,KAAK,GAAG,aAAa,MAAM,IAAI,GAAG,KAAK,CAAC;CAChD;CAEA,OAAO;AACR;;;ACvBA,SAAgB,WAAW,MAAY;CACtC,OAAO,UAAU,KAAK,KAAK,GAAG,IAAI;AACnC;;;;;;;ACEA,SAAgB,OAAO,KAAiB;CACvC,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KACtB,OAAO,IAAI,IAAI,EAAE;CAElB,OAAO;AACR;AAEA,SAAS,IAAI,GAAW;CACvB,MAAM,KAAK,CAAC,EAAA,CAAG,SAAS,EAAE;CAC1B,OAAO,EAAE,SAAS,IAAI,MAAM,IAAI;AACjC"}
package/cjs/package.json CHANGED
@@ -1 +1 @@
1
- {"type":"commonjs"}
1
+ { "type": "commonjs" }
@@ -1,2 +1,2 @@
1
- var ColorMap;(()=>{"use strict";var e={476(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=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}},664(e,r,t){Object.defineProperty(r,"__esModule",{value:!0}),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};var o=t(476)},934(e,r,t){var o=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var n=Object.getOwnPropertyDescriptor(r,t);n&&!("get"in n?!r.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,n)}: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(476),r),n(t(664),r),n(t(4),r),n(t(455),r)},4(e,r){function t(e){var r=(+e).toString(16);return r.length<2?"0"+r:r}Object.defineProperty(r,"__esModule",{value:!0}),r.rgbHex=function(e){for(var r="#",o=0;o<3;o++)r+=t(e[o]);return r}},455(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.rgbaString=function(e){return"rgba("+e.join(",")+")"}}};const r={};let t=function t(o){const n=r[o];if(void 0!==n)return n.exports;const a=r[o]={exports:{}};return e[o].call(a.exports,a,a.exports,t),a.exports}(934);ColorMap=t})();
1
+ var ColorMap=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t,n,r=[e.length===4?e[3]:t.length===4?t[3]:1,t.length===4?t[3]:e.length===4?e[3]:1]){let i=[...e],a=[t[0]-e[0],t[1]-e[1],t[2]-e[2],r[1]-r[0]];i.length===3&&i.push(r[0]);let o=1/Math.max(n-1,1),s=[];for(let e=0;e<n;e++){let t=[Math.round(i[0]+e*a[0]*o),Math.round(i[1]+e*a[1]*o),Math.round(i[2]+e*a[2]*o),i[3]+e*a[3]*o];s.push(t)}return s}function n(e,n,r){if(n<e.length)throw Error(`Requires at least ${e.length} shades.`);let i=[],a=[];for(let t=0;t<e.length;t++)a.push(Math.round(e[t].index*n));for(let n=0;n<e.length-1;n++){let o=a[n+1]-a[n],s=e[n].rgb,c=e[n+1].rgb;i.push(...t(s,c,o,r))}return i}function r(e){return`rgba(`+e.join(`,`)+`)`}function i(e){let t=`#`;for(let n=0;n<3;n++)t+=a(e[n]);return t}function a(e){let t=(+e).toString(16);return t.length<2?`0`+t:t}return e.createColors=t,e.createColorsFromMap=n,e.rgbHex=i,e.rgbaString=r,e})({});
2
2
  //# sourceMappingURL=color-map.es5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"color-map.es5.js","mappings":"iUAEAA,EAAAC,aAAA,SACEC,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,EAAKC,EAAA,GAAON,GAAI,GAChBO,EAAO,CACXN,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,EAAc,GACXC,EAAI,EAAGA,EAAIX,EAAQW,IAAK,CAC/B,IAAMC,EAAQ,CACZJ,KAAKK,MAAMV,EAAM,GAAKQ,EAAIN,EAAK,GAAKE,GACpCC,KAAKK,MAAMV,EAAM,GAAKQ,EAAIN,EAAK,GAAKE,GACpCC,KAAKK,MAAMV,EAAM,GAAKQ,EAAIN,EAAK,GAAKE,GACpCJ,EAAM,GAAKQ,EAAIN,EAAK,GAAKE,GAE3BG,EAAKJ,KAAKM,EACZ,CACA,OAAOF,CACT,+DC5BAd,EAAAkB,oBAAA,SAAoCC,EAAoBf,EAAgBC,GACtE,GAAID,EAASe,EAASb,OACpB,MAAM,IAAIc,MAAM,qBAAAC,OAAqBF,EAASb,OAAM,aAKtD,IAFA,IAAMgB,EAAiB,GACjBC,EAAkB,GACfR,EAAI,EAAGA,EAAII,EAASb,OAAQS,IACnCQ,EAAMb,KAAKE,KAAKK,MAAME,EAASJ,GAAGS,MAAQpB,IAG5C,IAASW,EAAI,EAAGA,EAAII,EAASb,OAAS,EAAGS,IAAK,CAC5C,IAAMU,EAAIF,EAAMR,EAAI,GAAKQ,EAAMR,GACzBb,EAAOiB,EAASJ,GAAGW,IACnBvB,EAAKgB,EAASJ,EAAI,GAAGW,IAC3BJ,EAAOZ,KAAIiB,MAAXL,GAAe,EAAAM,EAAA3B,cAAaC,EAAMC,EAAIsB,EAAGpB,GAC3C,CAEA,OAAOiB,CACT,EAzBA,IAAAM,EAAAC,EAAA,sfCAAC,EAAAD,EAAA,KAAA7B,GACA8B,EAAAD,EAAA,KAAA7B,GAEA8B,EAAAD,EAAA,GAAA7B,GACA8B,EAAAD,EAAA,KAAA7B,WCUA,SAAS+B,EAAIC,GACX,IAAMC,IAAMD,GAAGE,SAAS,IACxB,OAAOD,EAAE3B,OAAS,EAAI,IAAM2B,EAAIA,CAClC,kDAXAjC,EAAAmC,OAAA,SAAuBT,GAErB,IADA,IAAIU,EAAM,IACDrB,EAAI,EAAGA,EAAI,EAAGA,IACrBqB,GAAOL,EAAIL,EAAIX,IAEjB,OAAOqB,CACT,6DCVApC,EAAAqC,WAAA,SAA2BvB,GACzB,MAAO,QAAUA,EAAKwB,KAAK,KAAO,GACpC,ICHA,MAAAC,EAAA,GCEA,IAAAC,EDCA,SAAAX,EAAAY,GAEA,MAAAC,EAAAH,EAAAE,GACA,QAAAE,IAAAD,EACA,OAAAA,EAAA1C,QAGA,MAAA4C,EAAAL,EAAAE,GAAA,CAGAzC,QAAA,IAOA,OAHA6C,EAAAJ,GAAAK,KAAAF,EAAA5C,QAAA4C,EAAAA,EAAA5C,QAAA6B,GAGAe,EAAA5C,OACA,CCnBA6B,CAAA","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 type { RGB, RGBA, Alpha } from './interfaces.js'\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.js'\nimport type { ColorMap, Alpha, RGBA } from './interfaces.js'\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.js'\nexport * from './createColorsFromMap.js'\nexport type { Alpha, ColorMap, RGB, RGBA } from './interfaces.js'\nexport * from './rgbHex.js'\nexport * from './rgbaString.js'\n","import type { RGB, RGBA } from './interfaces.js'\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 type { RGBA } from './interfaces.js'\n\nexport function rgbaString(rgba: RGBA) {\n return 'rgba(' + rgba.join(',') + ')';\n}\n","// The module cache\nconst __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tconst 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\tconst 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\nlet __webpack_exports__ = __webpack_require__(934);\n"],"names":["exports","createColors","from","to","shades","alpha","length","start","__spreadArray","diff","push","inc","Math","max","rgba","i","color","round","createColorsFromMap","colormap","Error","concat","result","steps","index","n","rgb","apply","createColors_js_1","__webpack_require__","__exportStar","d2h","d","s","toString","rgbHex","hex","rgbaString","join","__webpack_module_cache__","__webpack_exports__","moduleId","cachedModule","undefined","module","__webpack_modules__","call"],"sourceRoot":""}
1
+ {"version":3,"file":"color-map.es5.js","names":[],"sources":["../ts/createColors.ts","../ts/createColorsFromMap.ts","../ts/rgbaString.ts","../ts/rgbHex.ts"],"sourcesContent":["import type { Alpha, RGB, RGBA } from './interfaces.js'\n\nexport function createColors(\n\tfrom: RGB | RGBA,\n\tto: RGB | RGBA,\n\tshades: number,\n\talpha: Alpha = [\n\t\tfrom.length === 4 ? from[3] : to.length === 4 ? to[3] : 1,\n\t\tto.length === 4 ? to[3] : from.length === 4 ? from[3] : 1\n\t]\n): RGBA[] {\n\tconst start = [...from]\n\tconst diff = [to[0] - from[0], to[1] - from[1], to[2] - from[2], alpha[1] - alpha[0]]\n\n\tif (start.length === 3) start.push(alpha[0])\n\n\tconst inc = 1 / Math.max(shades - 1, 1)\n\n\tconst rgba: any[] = []\n\tfor (let i = 0; i < shades; i++) {\n\t\tconst color = [\n\t\t\tMath.round(start[0] + i * diff[0] * inc),\n\t\t\tMath.round(start[1] + i * diff[1] * inc),\n\t\t\tMath.round(start[2] + i * diff[2] * inc),\n\t\t\tstart[3] + i * diff[3] * inc\n\t\t]\n\t\trgba.push(color)\n\t}\n\treturn rgba\n}\n","import { createColors } from './createColors.js'\nimport type { Alpha, ColorMap, RGBA } from './interfaces.js'\n\n/**\n * Create colors with specified color map.\n */\nexport function createColorsFromMap(colormap: ColorMap, shades: number, alpha?: Alpha): RGBA[] {\n\tif (shades < colormap.length) {\n\t\tthrow new Error(`Requires at least ${colormap.length} shades.`)\n\t}\n\n\tconst result: RGBA[] = []\n\tconst steps: number[] = []\n\tfor (let i = 0; i < colormap.length; i++) {\n\t\tsteps.push(Math.round(colormap[i].index * shades))\n\t}\n\n\tfor (let i = 0; i < colormap.length - 1; i++) {\n\t\tconst n = steps[i + 1] - steps[i]\n\t\tconst from = colormap[i].rgb\n\t\tconst to = colormap[i + 1].rgb\n\t\tresult.push(...createColors(from, to, n, alpha))\n\t}\n\n\treturn result\n}\n","import type { RGBA } from './interfaces.js'\n\nexport function rgbaString(rgba: RGBA) {\n\treturn 'rgba(' + rgba.join(',') + ')'\n}\n","import type { RGB, RGBA } from './interfaces.js'\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\tlet hex = '#'\n\tfor (let i = 0; i < 3; i++) {\n\t\thex += d2h(rgb[i])\n\t}\n\treturn hex\n}\n\nfunction d2h(d: number) {\n\tconst s = (+d).toString(16)\n\treturn s.length < 2 ? '0' + s : s\n}\n"],"mappings":"uFAEA,SAAgB,EACf,EACA,EACA,EACA,EAAe,CACd,EAAK,SAAW,EAAI,EAAK,GAAK,EAAG,SAAW,EAAI,EAAG,GAAK,EACxD,EAAG,SAAW,EAAI,EAAG,GAAK,EAAK,SAAW,EAAI,EAAK,GAAK,CACzD,EACS,CACT,IAAM,EAAQ,CAAC,GAAG,CAAI,EAChB,EAAO,CAAC,EAAG,GAAK,EAAK,GAAI,EAAG,GAAK,EAAK,GAAI,EAAG,GAAK,EAAK,GAAI,EAAM,GAAK,EAAM,EAAE,EAEhF,EAAM,SAAW,GAAG,EAAM,KAAK,EAAM,EAAE,EAE3C,IAAM,EAAM,EAAI,KAAK,IAAI,EAAS,EAAG,CAAC,EAEhC,EAAc,CAAC,EACrB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAAK,CAChC,IAAM,EAAQ,CACb,KAAK,MAAM,EAAM,GAAK,EAAI,EAAK,GAAK,CAAG,EACvC,KAAK,MAAM,EAAM,GAAK,EAAI,EAAK,GAAK,CAAG,EACvC,KAAK,MAAM,EAAM,GAAK,EAAI,EAAK,GAAK,CAAG,EACvC,EAAM,GAAK,EAAI,EAAK,GAAK,CAC1B,EACA,EAAK,KAAK,CAAK,CAChB,CACA,OAAO,CACR,CCvBA,SAAgB,EAAoB,EAAoB,EAAgB,EAAuB,CAC9F,GAAI,EAAS,EAAS,OACrB,MAAU,MAAM,qBAAqB,EAAS,OAAO,SAAS,EAG/D,IAAM,EAAiB,CAAC,EAClB,EAAkB,CAAC,EACzB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAS,OAAQ,IACpC,EAAM,KAAK,KAAK,MAAM,EAAS,EAAE,CAAC,MAAQ,CAAM,CAAC,EAGlD,IAAK,IAAI,EAAI,EAAG,EAAI,EAAS,OAAS,EAAG,IAAK,CAC7C,IAAM,EAAI,EAAM,EAAI,GAAK,EAAM,GACzB,EAAO,EAAS,EAAE,CAAC,IACnB,EAAK,EAAS,EAAI,EAAE,CAAC,IAC3B,EAAO,KAAK,GAAG,EAAa,EAAM,EAAI,EAAG,CAAK,CAAC,CAChD,CAEA,OAAO,CACR,CCvBA,SAAgB,EAAW,EAAY,CACtC,MAAO,QAAU,EAAK,KAAK,GAAG,EAAI,GACnC,CCEA,SAAgB,EAAO,EAAiB,CACvC,IAAI,EAAM,IACV,IAAK,IAAI,EAAI,EAAG,EAAI,EAAG,IACtB,GAAO,EAAI,EAAI,EAAE,EAElB,OAAO,CACR,CAEA,SAAS,EAAI,EAAW,CACvB,IAAM,GAAK,CAAC,EAAA,CAAG,SAAS,EAAE,EAC1B,OAAO,EAAE,OAAS,EAAI,IAAM,EAAI,CACjC"}
@@ -1,2 +1,6 @@
1
- import type { RGB, RGBA, Alpha } from './interfaces.js';
2
- export declare function createColors(from: RGB | RGBA, to: RGB | RGBA, shades: number, alpha?: Alpha): RGBA[];
1
+ import { Alpha, RGB, RGBA } from "./interfaces.js";
2
+ //#region ts/createColors.d.ts
3
+ declare function createColors(from: RGB | RGBA, to: RGB | RGBA, shades: number, alpha?: Alpha): RGBA[];
4
+ //#endregion
5
+ export { createColors };
6
+ //# sourceMappingURL=createColors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createColors.d.ts","names":[],"sources":["../ts/createColors.ts"],"mappings":";;iBAEgB,aACf,MAAM,MAAM,MACZ,IAAI,MAAM,MACV,gBACA,QAAO,QAIL"}
@@ -1,27 +1,27 @@
1
- export function createColors(from, to, shades, alpha = [
2
- from.length === 4 ? from[3] : to.length === 4 ? to[3] : 1,
3
- to.length === 4 ? to[3] : from.length === 4 ? from[3] : 1
4
- ]) {
5
- const start = [...from];
6
- const diff = [
7
- to[0] - from[0],
8
- to[1] - from[1],
9
- to[2] - from[2],
10
- alpha[1] - alpha[0]
11
- ];
12
- if (start.length === 3)
13
- start.push(alpha[0]);
14
- const inc = 1 / Math.max(shades - 1, 1);
15
- const rgba = [];
16
- for (let i = 0; i < shades; i++) {
17
- const color = [
18
- Math.round(start[0] + i * diff[0] * inc),
19
- Math.round(start[1] + i * diff[1] * inc),
20
- Math.round(start[2] + i * diff[2] * inc),
21
- start[3] + i * diff[3] * inc
22
- ];
23
- rgba.push(color);
24
- }
25
- return rgba;
1
+ //#region ts/createColors.ts
2
+ function createColors(from, to, shades, alpha = [from.length === 4 ? from[3] : to.length === 4 ? to[3] : 1, to.length === 4 ? to[3] : from.length === 4 ? from[3] : 1]) {
3
+ const start = [...from];
4
+ const diff = [
5
+ to[0] - from[0],
6
+ to[1] - from[1],
7
+ to[2] - from[2],
8
+ alpha[1] - alpha[0]
9
+ ];
10
+ if (start.length === 3) start.push(alpha[0]);
11
+ const inc = 1 / Math.max(shades - 1, 1);
12
+ const rgba = [];
13
+ for (let i = 0; i < shades; i++) {
14
+ const color = [
15
+ Math.round(start[0] + i * diff[0] * inc),
16
+ Math.round(start[1] + i * diff[1] * inc),
17
+ Math.round(start[2] + i * diff[2] * inc),
18
+ start[3] + i * diff[3] * inc
19
+ ];
20
+ rgba.push(color);
21
+ }
22
+ return rgba;
26
23
  }
24
+ //#endregion
25
+ export { createColors };
26
+
27
27
  //# sourceMappingURL=createColors.js.map
@@ -1 +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,CAAC;QAChC,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;IAClB,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
1
+ {"version":3,"file":"createColors.js","names":[],"sources":["../ts/createColors.ts"],"sourcesContent":["import type { Alpha, RGB, RGBA } from './interfaces.js'\n\nexport function createColors(\n\tfrom: RGB | RGBA,\n\tto: RGB | RGBA,\n\tshades: number,\n\talpha: Alpha = [\n\t\tfrom.length === 4 ? from[3] : to.length === 4 ? to[3] : 1,\n\t\tto.length === 4 ? to[3] : from.length === 4 ? from[3] : 1\n\t]\n): RGBA[] {\n\tconst start = [...from]\n\tconst diff = [to[0] - from[0], to[1] - from[1], to[2] - from[2], alpha[1] - alpha[0]]\n\n\tif (start.length === 3) start.push(alpha[0])\n\n\tconst inc = 1 / Math.max(shades - 1, 1)\n\n\tconst rgba: any[] = []\n\tfor (let i = 0; i < shades; i++) {\n\t\tconst color = [\n\t\t\tMath.round(start[0] + i * diff[0] * inc),\n\t\t\tMath.round(start[1] + i * diff[1] * inc),\n\t\t\tMath.round(start[2] + i * diff[2] * inc),\n\t\t\tstart[3] + i * diff[3] * inc\n\t\t]\n\t\trgba.push(color)\n\t}\n\treturn rgba\n}\n"],"mappings":";AAEA,SAAgB,aACf,MACA,IACA,QACA,QAAe,CACd,KAAK,WAAW,IAAI,KAAK,KAAK,GAAG,WAAW,IAAI,GAAG,KAAK,GACxD,GAAG,WAAW,IAAI,GAAG,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,CACzD,GACS;CACT,MAAM,QAAQ,CAAC,GAAG,IAAI;CACtB,MAAM,OAAO;EAAC,GAAG,KAAK,KAAK;EAAI,GAAG,KAAK,KAAK;EAAI,GAAG,KAAK,KAAK;EAAI,MAAM,KAAK,MAAM;CAAE;CAEpF,IAAI,MAAM,WAAW,GAAG,MAAM,KAAK,MAAM,EAAE;CAE3C,MAAM,MAAM,IAAI,KAAK,IAAI,SAAS,GAAG,CAAC;CAEtC,MAAM,OAAc,CAAC;CACrB,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,KAAK;EAChC,MAAM,QAAQ;GACb,KAAK,MAAM,MAAM,KAAK,IAAI,KAAK,KAAK,GAAG;GACvC,KAAK,MAAM,MAAM,KAAK,IAAI,KAAK,KAAK,GAAG;GACvC,KAAK,MAAM,MAAM,KAAK,IAAI,KAAK,KAAK,GAAG;GACvC,MAAM,KAAK,IAAI,KAAK,KAAK;EAC1B;EACA,KAAK,KAAK,KAAK;CAChB;CACA,OAAO;AACR"}
@@ -1,5 +1,9 @@
1
- import type { ColorMap, Alpha, RGBA } from './interfaces.js';
1
+ import { Alpha, ColorMap, RGBA } from "./interfaces.js";
2
+ //#region ts/createColorsFromMap.d.ts
2
3
  /**
3
4
  * Create colors with specified color map.
4
5
  */
5
- export declare function createColorsFromMap(colormap: ColorMap, shades: number, alpha?: Alpha): RGBA[];
6
+ declare function createColorsFromMap(colormap: ColorMap, shades: number, alpha?: Alpha): RGBA[];
7
+ //#endregion
8
+ export { createColorsFromMap };
9
+ //# sourceMappingURL=createColorsFromMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createColorsFromMap.d.ts","names":[],"sources":["../ts/createColorsFromMap.ts"],"mappings":";;;;;iBAMgB,oBAAoB,UAAU,UAAU,gBAAgB,QAAQ,QAAQ"}
@@ -1,22 +1,22 @@
1
- import { createColors } from './createColors.js';
1
+ import { createColors } from "./createColors.js";
2
+ //#region ts/createColorsFromMap.ts
2
3
  /**
3
- * Create colors with specified color map.
4
- */
5
- export function createColorsFromMap(colormap, shades, alpha) {
6
- if (shades < colormap.length) {
7
- throw new Error(`Requires at least ${colormap.length} shades.`);
8
- }
9
- const result = [];
10
- const steps = [];
11
- for (let i = 0; i < colormap.length; i++) {
12
- steps.push(Math.round(colormap[i].index * shades));
13
- }
14
- for (let i = 0; i < colormap.length - 1; i++) {
15
- const n = steps[i + 1] - steps[i];
16
- const from = colormap[i].rgb;
17
- const to = colormap[i + 1].rgb;
18
- result.push(...createColors(from, to, n, alpha));
19
- }
20
- return result;
4
+ * Create colors with specified color map.
5
+ */
6
+ function createColorsFromMap(colormap, shades, alpha) {
7
+ if (shades < colormap.length) throw new Error(`Requires at least ${colormap.length} shades.`);
8
+ const result = [];
9
+ const steps = [];
10
+ for (let i = 0; i < colormap.length; i++) steps.push(Math.round(colormap[i].index * shades));
11
+ for (let i = 0; i < colormap.length - 1; i++) {
12
+ const n = steps[i + 1] - steps[i];
13
+ const from = colormap[i].rgb;
14
+ const to = colormap[i + 1].rgb;
15
+ result.push(...createColors(from, to, n, alpha));
16
+ }
17
+ return result;
21
18
  }
19
+ //#endregion
20
+ export { createColorsFromMap };
21
+
22
22
  //# sourceMappingURL=createColorsFromMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createColorsFromMap.js","sourceRoot":"","sources":["../ts/createColorsFromMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGhD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAkB,EAAE,MAAc,EAAE,KAAa;IACnF,IAAI,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,CAAC,MAAM,UAAU,CAAC,CAAA;IACjE,CAAC;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,CAAC;QACzC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAA;IACpD,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,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,CAAA;QAC5B,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;QAC9B,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
1
+ {"version":3,"file":"createColorsFromMap.js","names":[],"sources":["../ts/createColorsFromMap.ts"],"sourcesContent":["import { createColors } from './createColors.js'\nimport type { Alpha, ColorMap, RGBA } from './interfaces.js'\n\n/**\n * Create colors with specified color map.\n */\nexport function createColorsFromMap(colormap: ColorMap, shades: number, alpha?: Alpha): RGBA[] {\n\tif (shades < colormap.length) {\n\t\tthrow new Error(`Requires at least ${colormap.length} shades.`)\n\t}\n\n\tconst result: RGBA[] = []\n\tconst steps: number[] = []\n\tfor (let i = 0; i < colormap.length; i++) {\n\t\tsteps.push(Math.round(colormap[i].index * shades))\n\t}\n\n\tfor (let i = 0; i < colormap.length - 1; i++) {\n\t\tconst n = steps[i + 1] - steps[i]\n\t\tconst from = colormap[i].rgb\n\t\tconst to = colormap[i + 1].rgb\n\t\tresult.push(...createColors(from, to, n, alpha))\n\t}\n\n\treturn result\n}\n"],"mappings":";;;;;AAMA,SAAgB,oBAAoB,UAAoB,QAAgB,OAAuB;CAC9F,IAAI,SAAS,SAAS,QACrB,MAAM,IAAI,MAAM,qBAAqB,SAAS,OAAO,SAAS;CAG/D,MAAM,SAAiB,CAAC;CACxB,MAAM,QAAkB,CAAC;CACzB,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KACpC,MAAM,KAAK,KAAK,MAAM,SAAS,EAAE,CAAC,QAAQ,MAAM,CAAC;CAGlD,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,SAAS,GAAG,KAAK;EAC7C,MAAM,IAAI,MAAM,IAAI,KAAK,MAAM;EAC/B,MAAM,OAAO,SAAS,EAAE,CAAC;EACzB,MAAM,KAAK,SAAS,IAAI,EAAE,CAAC;EAC3B,OAAO,KAAK,GAAG,aAAa,MAAM,IAAI,GAAG,KAAK,CAAC;CAChD;CAEA,OAAO;AACR"}
package/esm/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export * from './createColors.js';
2
- export * from './createColorsFromMap.js';
3
- export type { Alpha, ColorMap, RGB, RGBA } from './interfaces.js';
4
- export * from './rgbHex.js';
5
- export * from './rgbaString.js';
1
+ import { Alpha, ColorMap, RGB, RGBA } from "./interfaces.js";
2
+ import { createColors } from "./createColors.js";
3
+ import { createColorsFromMap } from "./createColorsFromMap.js";
4
+ import { rgbaString } from "./rgbaString.js";
5
+ import { rgbHex } from "./rgbHex.js";
6
+ export { type Alpha, type ColorMap, type RGB, type RGBA, createColors, createColorsFromMap, rgbHex, rgbaString };
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export * from './createColors.js';
2
- export * from './createColorsFromMap.js';
3
- export * from './rgbHex.js';
4
- export * from './rgbaString.js';
5
- //# sourceMappingURL=index.js.map
1
+ import { createColors } from "./createColors.js";
2
+ import { createColorsFromMap } from "./createColorsFromMap.js";
3
+ import { rgbaString } from "./rgbaString.js";
4
+ import { rgbHex } from "./rgbHex.js";
5
+ export { createColors, createColorsFromMap, rgbHex, rgbaString };
@@ -1,14 +1,18 @@
1
- export type RGB = [number, number, number];
2
- export type RGBA = [number, number, number, number];
3
- export type Alpha = [number, number];
4
- export type ColorMap = {
5
- /**
6
- * Defines how fast or slow the `rgb` values will change from one segment to the next.
7
- * i.e. the steepness of the gradient between two segments.
8
- */
9
- index: number;
10
- /**
11
- * RGB or RGBA. if RGBA, this alpha will be used instead of the alpha specified in the call.
12
- */
13
- rgb: RGB | RGBA;
1
+ //#region ts/interfaces.d.ts
2
+ type RGB = [number, number, number];
3
+ type RGBA = [number, number, number, number];
4
+ type Alpha = [number, number];
5
+ type ColorMap = {
6
+ /**
7
+ * Defines how fast or slow the `rgb` values will change from one segment to the next.
8
+ * i.e. the steepness of the gradient between two segments.
9
+ */
10
+ index: number;
11
+ /**
12
+ * RGB or RGBA. if RGBA, this alpha will be used instead of the alpha specified in the call.
13
+ */
14
+ rgb: RGB | RGBA;
14
15
  }[];
16
+ //#endregion
17
+ export { Alpha, ColorMap, RGB, RGBA };
18
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","names":[],"sources":["../ts/interfaces.ts"],"mappings":";KAAY;KACA;KACA;KAEA;;;;;EAKX;;;;EAIA,KAAK,MAAM"}
package/esm/rgbHex.d.ts CHANGED
@@ -1,6 +1,10 @@
1
- import type { RGB, RGBA } from './interfaces.js';
1
+ import { RGB, RGBA } from "./interfaces.js";
2
+ //#region ts/rgbHex.d.ts
2
3
  /**
3
4
  * Convert `RGB` to `#rgb`
4
5
  * JavaScript note: no check for array length, use it properly.
5
6
  */
6
- export declare function rgbHex(rgb: RGB | RGBA): string;
7
+ declare function rgbHex(rgb: RGB | RGBA): string;
8
+ //#endregion
9
+ export { rgbHex };
10
+ //# sourceMappingURL=rgbHex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rgbHex.d.ts","names":[],"sources":["../ts/rgbHex.ts"],"mappings":";;;;;;iBAMgB,OAAO,KAAK,MAAM"}
package/esm/rgbHex.js CHANGED
@@ -1,16 +1,18 @@
1
+ //#region ts/rgbHex.ts
1
2
  /**
2
- * Convert `RGB` to `#rgb`
3
- * JavaScript note: no check for array length, use it properly.
4
- */
5
- export function rgbHex(rgb) {
6
- let hex = '#';
7
- for (let i = 0; i < 3; i++) {
8
- hex += d2h(rgb[i]);
9
- }
10
- return hex;
3
+ * Convert `RGB` to `#rgb`
4
+ * JavaScript note: no check for array length, use it properly.
5
+ */
6
+ function rgbHex(rgb) {
7
+ let hex = "#";
8
+ for (let i = 0; i < 3; i++) hex += d2h(rgb[i]);
9
+ return hex;
11
10
  }
12
11
  function d2h(d) {
13
- const s = (+d).toString(16);
14
- return s.length < 2 ? '0' + s : s;
12
+ const s = (+d).toString(16);
13
+ return s.length < 2 ? "0" + s : s;
15
14
  }
15
+ //#endregion
16
+ export { rgbHex };
17
+
16
18
  //# sourceMappingURL=rgbHex.js.map
package/esm/rgbHex.js.map CHANGED
@@ -1 +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,CAAC;QAC3B,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACpB,CAAC;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"}
1
+ {"version":3,"file":"rgbHex.js","names":[],"sources":["../ts/rgbHex.ts"],"sourcesContent":["import type { RGB, RGBA } from './interfaces.js'\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\tlet hex = '#'\n\tfor (let i = 0; i < 3; i++) {\n\t\thex += d2h(rgb[i])\n\t}\n\treturn hex\n}\n\nfunction d2h(d: number) {\n\tconst s = (+d).toString(16)\n\treturn s.length < 2 ? '0' + s : s\n}\n"],"mappings":";;;;;AAMA,SAAgB,OAAO,KAAiB;CACvC,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KACtB,OAAO,IAAI,IAAI,EAAE;CAElB,OAAO;AACR;AAEA,SAAS,IAAI,GAAW;CACvB,MAAM,KAAK,CAAC,EAAA,CAAG,SAAS,EAAE;CAC1B,OAAO,EAAE,SAAS,IAAI,MAAM,IAAI;AACjC"}
@@ -1,2 +1,6 @@
1
- import type { RGBA } from './interfaces.js';
2
- export declare function rgbaString(rgba: RGBA): string;
1
+ import { RGBA } from "./interfaces.js";
2
+ //#region ts/rgbaString.d.ts
3
+ declare function rgbaString(rgba: RGBA): string;
4
+ //#endregion
5
+ export { rgbaString };
6
+ //# sourceMappingURL=rgbaString.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rgbaString.d.ts","names":[],"sources":["../ts/rgbaString.ts"],"mappings":";;iBAEgB,WAAW,MAAM"}
package/esm/rgbaString.js CHANGED
@@ -1,4 +1,8 @@
1
- export function rgbaString(rgba) {
2
- return 'rgba(' + rgba.join(',') + ')';
1
+ //#region ts/rgbaString.ts
2
+ function rgbaString(rgba) {
3
+ return "rgba(" + rgba.join(",") + ")";
3
4
  }
5
+ //#endregion
6
+ export { rgbaString };
7
+
4
8
  //# sourceMappingURL=rgbaString.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"rgbaString.js","names":[],"sources":["../ts/rgbaString.ts"],"sourcesContent":["import type { RGBA } from './interfaces.js'\n\nexport function rgbaString(rgba: RGBA) {\n\treturn 'rgba(' + rgba.join(',') + ')'\n}\n"],"mappings":";AAEA,SAAgB,WAAW,MAAY;CACtC,OAAO,UAAU,KAAK,KAAK,GAAG,IAAI;AACnC"}