From e9b9aad537666efe1e50fd318fb02d7f12e03197 Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Fri, 13 Jan 2017 11:17:35 -0800 Subject: [PATCH] 0.5.5 --- dist/color-map.es2015.js | 115 +++++++++++++++++++++ dist/color-map.es2015.js.map | 1 + dist/color-map.es5.js | 187 +++++++++++++++++++++++++++++++++++ dist/color-map.es5.js.map | 1 + package.json | 2 +- 5 files changed, 305 insertions(+), 1 deletion(-) create mode 100644 dist/color-map.es2015.js create mode 100644 dist/color-map.es2015.js.map create mode 100644 dist/color-map.es5.js create mode 100644 dist/color-map.es5.js.map diff --git a/dist/color-map.es2015.js b/dist/color-map.es2015.js new file mode 100644 index 0000000..df274aa --- /dev/null +++ b/dist/color-map.es2015.js @@ -0,0 +1,115 @@ +(function (exports) { +'use strict'; + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +function createColors(from, to, shades, alpha) { + const rgba = []; + const start = [...from]; + const diff = [ + to[0] - from[0], + to[1] - from[1], + to[2] - from[2] + ]; + if (alpha) { + start.push(alpha[0]); + diff.push(alpha[1] - alpha[0]); + } + for (let i = 0; i < shades; i++) { + const inc = 1 / + Math.max(shades - 1, 1); + const color = [ + Math.round(start[0] + i * diff[0] * inc), + Math.round(start[1] + i * diff[1] * inc), + Math.round(start[2] + i * diff[2] * inc), + alpha ? start[3] + i * diff[3] * inc : 1 + ]; + rgba.push(color); + } + return rgba; +} +var createColors_2 = createColors; + + +var createColors_1 = { + createColors: createColors_2 +}; + +const createColors_1$2 = createColors_1; +/** + * Create colors with specified color map. + */ +function createColorsFromMap(colormap, shades, alpha) { + if (shades < colormap.length) { + throw new Error(`Requires at least ${colormap.length} shades.`); + } + const result = []; + const steps = []; + for (let i = 0; i < colormap.length; i++) { + steps.push(Math.round(colormap[i].index * shades)); + } + for (let i = 0; i < colormap.length - 1; i++) { + const n = steps[i + 1] - steps[i]; + const from = colormap[i].rgb; + const to = colormap[i + 1].rgb; + result.push(...createColors_1$2.createColors(from, to, n, alpha)); + } + return result; +} +var createColorsFromMap_2 = createColorsFromMap; + + +var createColorsFromMap_1 = { + createColorsFromMap: createColorsFromMap_2 +}; + +/** + * Convert `RGB` to `#rgb` + * JavaScript note: no check for array length, use it properly. + */ +function rgbHex(rgb) { + let hex = '#'; + for (let i = 0; i < 3; i++) { + hex += d2h(rgb[i]); + } + return hex; +} +var rgbHex_2 = rgbHex; +function d2h(d) { + let s = (+d).toString(16); + return s.length < 2 ? '0' + s : s; +} + + +var rgbHex_1 = { + rgbHex: rgbHex_2 +}; + +function rgbaString(rgba) { + return 'rgba(' + rgba.join(',') + ')'; +} +var rgbaString_2 = rgbaString; + + +var rgbaString_1 = { + rgbaString: rgbaString_2 +}; + +var index = createCommonjsModule(function (module, exports) { +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +__export(createColors_1); +__export(createColorsFromMap_1); +__export(rgbHex_1); +__export(rgbaString_1); + +}); + +exports['default'] = index; + +}((this.ColorMap = this.ColorMap || {}))); +//# sourceMappingURL=color-map.es2015.js.map diff --git a/dist/color-map.es2015.js.map b/dist/color-map.es2015.js.map new file mode 100644 index 0000000..ad67e0b --- /dev/null +++ b/dist/color-map.es2015.js.map @@ -0,0 +1 @@ +{"version":3,"file":"color-map.es2015.js","sources":["../../../../../../color-map/createColors.ts","../../../../../../color-map/createColorsFromMap.ts","../../../../../../color-map/rgbHex.ts","../../../../../../color-map/rgbaString.ts","../../../../../../color-map/index.ts"],"sourcesContent":["import { RGB, RGBA, Alpha } from './interfaces'\n\nexport function createColors(from: RGB, to: RGB, shades: number, alpha?: Alpha): RGBA[] {\n const rgba: any[] = []\n const start = [...from]\n const diff = [\n to[0] - from[0],\n to[1] - from[1],\n to[2] - from[2]\n ]\n if (alpha) {\n start.push(alpha[0])\n diff.push(alpha[1] - alpha[0])\n }\n for (let i = 0; i < shades; i++) {\n const inc = 1 /\n Math.max(shades - 1, 1)\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 alpha ? start[3] + i * diff[3] * inc : 1\n ]\n rgba.push(color)\n }\n return rgba\n}\n","import { ColorMap, Alpha, RGBA, RGB } from './interfaces'\nimport { createColors } from './createColors'\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: RGB = 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","import { RGB } 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) {\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 { RGBA } from './interfaces'\n\nexport function rgbaString(rgba: RGBA) {\n return 'rgba(' + rgba.join(',') + ')';\n}\n","export * from './createColors'\nexport * from './createColorsFromMap'\nexport * from './interfaces'\nexport * from './rgbHex'\nexport * from './rgbaString'\n"],"names":["createColors_1"],"mappings":";;;;;;;AAEA,sBAA6B,IAAS,EAAE,EAAO,EAAE,MAAc,EAAE,KAAa;IAC5E,MAAM,IAAI,GAAU,EAAE,CAAA;IACtB,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,C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AC,CAAC,MAAM,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAA;CAClC;;;;;;;ACfD,oBAA2B,IAAU;IACnC,OAAO,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;CACvC;AAFD,8BAEC;;;;;;;;;;;;ACJD,yBAA8B;AAC9B,gCAAqC;AAErC,mBAAwB;AACxB,uBAA4B;;;;;;"} \ No newline at end of file diff --git a/dist/color-map.es5.js b/dist/color-map.es5.js new file mode 100644 index 0000000..b25fc32 --- /dev/null +++ b/dist/color-map.es5.js @@ -0,0 +1,187 @@ +var ColorMap = +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __webpack_require__.i = function(value) { return value; }; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 4); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +function createColors(from, to, shades, alpha) { + var rgba = []; + var start = from.slice(); + var diff = [ + to[0] - from[0], + to[1] - from[1], + to[2] - from[2] + ]; + if (alpha) { + start.push(alpha[0]); + diff.push(alpha[1] - alpha[0]); + } + for (var i = 0; i < shades; i++) { + var inc = 1 / + Math.max(shades - 1, 1); + var color = [ + Math.round(start[0] + i * diff[0] * inc), + Math.round(start[1] + i * diff[1] * inc), + Math.round(start[2] + i * diff[2] * inc), + alpha ? start[3] + i * diff[3] * inc : 1 + ]; + rgba.push(color); + } + return rgba; +} +exports.createColors = createColors; + + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var createColors_1 = __webpack_require__(0); +/** + * Create colors with specified color map. + */ +function createColorsFromMap(colormap, shades, alpha) { + if (shades < colormap.length) { + throw new Error("Requires at least " + colormap.length + " shades."); + } + var result = []; + var steps = []; + for (var i = 0; i < colormap.length; i++) { + steps.push(Math.round(colormap[i].index * shades)); + } + for (var i = 0; i < colormap.length - 1; i++) { + var n = steps[i + 1] - steps[i]; + var from = colormap[i].rgb; + var to = colormap[i + 1].rgb; + result.push.apply(result, createColors_1.createColors(from, to, n, alpha)); + } + return result; +} +exports.createColorsFromMap = createColorsFromMap; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +/** + * Convert `RGB` to `#rgb` + * JavaScript note: no check for array length, use it properly. + */ +function rgbHex(rgb) { + var hex = '#'; + for (var i = 0; i < 3; i++) { + hex += d2h(rgb[i]); + } + return hex; +} +exports.rgbHex = rgbHex; +function d2h(d) { + var s = (+d).toString(16); + return s.length < 2 ? '0' + s : s; +} + + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +function rgbaString(rgba) { + return 'rgba(' + rgba.join(',') + ')'; +} +exports.rgbaString = rgbaString; + + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +__export(__webpack_require__(0)); +__export(__webpack_require__(1)); +__export(__webpack_require__(2)); +__export(__webpack_require__(3)); + + +/***/ }) +/******/ ]); +//# sourceMappingURL=color-map.es5.js.map \ No newline at end of file diff --git a/dist/color-map.es5.js.map b/dist/color-map.es5.js.map new file mode 100644 index 0000000..9795c4c --- /dev/null +++ b/dist/color-map.es5.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/bootstrap 3914ad92625b4322de56","webpack:////color-map/createColors.ts","webpack:////color-map/createColorsFromMap.ts","webpack:////color-map/rgbHex.ts","webpack:////color-map/rgbaString.ts","webpack:////color-map/index.ts"],"names":[],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA,mDAA2C,cAAc;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;AC9DA,sBAA6B,IAAS,EAAE,EAAO,EAAE,MAAc,EAAE,KAAa;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AC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IACD,MAAM,CAAC,GAAG;AACZ,CAAC;AAND,wBAMC;AAED,aAAa,CAAS;IACpB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;IACzB,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;AACnC,CAAC;;;;;;;;;ACfD,oBAA2B,IAAU;IACnC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AACxC,CAAC;AAFD,gCAEC;;;;;;;;;;;;ACJD,iCAA8B;AAC9B,iCAAqC;AAErC,iCAAwB;AACxB,iCAA4B","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\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// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\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// 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 \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 4);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 3914ad92625b4322de56","import { RGB, RGBA, Alpha } from './interfaces'\n\nexport function createColors(from: RGB, to: RGB, shades: number, alpha?: Alpha): RGBA[] {\n const rgba: any[] = []\n const start = [...from]\n const diff = [\n to[0] - from[0],\n to[1] - from[1],\n to[2] - from[2]\n ]\n if (alpha) {\n start.push(alpha[0])\n diff.push(alpha[1] - alpha[0])\n }\n for (let i = 0; i < shades; i++) {\n const inc = 1 /\n Math.max(shades - 1, 1)\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 alpha ? start[3] + i * diff[3] * inc : 1\n ]\n rgba.push(color)\n }\n return rgba\n}\n\n\n\n// WEBPACK FOOTER //\n// /color-map/createColors.ts","import { ColorMap, Alpha, RGBA, RGB } from './interfaces'\nimport { createColors } from './createColors'\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: RGB = 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\n\n\n// WEBPACK FOOTER //\n// /color-map/createColorsFromMap.ts","import { RGB } 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) {\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\n\n\n// WEBPACK FOOTER //\n// /color-map/rgbHex.ts","import { RGBA } from './interfaces'\n\nexport function rgbaString(rgba: RGBA) {\n return 'rgba(' + rgba.join(',') + ')';\n}\n\n\n\n// WEBPACK FOOTER //\n// /color-map/rgbaString.ts","export * from './createColors'\nexport * from './createColorsFromMap'\nexport * from './interfaces'\nexport * from './rgbHex'\nexport * from './rgbaString'\n\n\n\n// WEBPACK FOOTER //\n// /color-map/index.ts"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 56e1950..3d54556 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "color-map", "description": "Color map generator", - "version": "0.5.4", + "version": "0.5.5", "main": "dist/es5/index.js", "module": "dist/es2015/index.js", "typings": "dist/es5/index.d.ts",