@nextcloud/vue
Version:
Nextcloud vue components
1 lines • 4.37 kB
Source Map (JSON)
{"version":3,"file":"GenColors-85cb6194.mjs","sources":["../../src/utils/GenColors.js"],"sourcesContent":["/**\n * @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\n/**\n * Originally taken from https://github.com/nextcloud/server/blob/master/core/js/placeholder.js\n */\n\n/**\n * @param {number} r The red value\n * @param {number} g The green value\n * @param {number} b The blue value\n */\nfunction Color(r, g, b) {\n\tthis.r = r\n\tthis.g = g\n\tthis.b = b\n}\n\n/**\n * Calculate the number of steps\n *\n * @param {number} steps The number of steps\n * @param {Array} ends The ends\n * @return {Array} Array containing the number of steps per color\n */\nfunction stepCalc(steps, ends) {\n\tconst step = new Array(3)\n\tstep[0] = (ends[1].r - ends[0].r) / steps\n\tstep[1] = (ends[1].g - ends[0].g) / steps\n\tstep[2] = (ends[1].b - ends[0].b) / steps\n\treturn step\n}\n\n/**\n * Create a color palette from two colors\n *\n * @param {number} steps The number of steps the palette has\n * @param {string} color1 The first color\n * @param {string} color2 The second color\n * @return {Array} The created palette array\n */\nfunction mixPalette(steps, color1, color2) {\n\tconst palette = []\n\tpalette.push(color1)\n\tconst step = stepCalc(steps, [color1, color2])\n\tfor (let i = 1; i < steps; i++) {\n\t\tconst r = parseInt(color1.r + step[0] * i, 10)\n\t\tconst g = parseInt(color1.g + step[1] * i, 10)\n\t\tconst b = parseInt(color1.b + step[2] * i, 10)\n\t\tpalette.push(new Color(r, g, b))\n\t}\n\treturn palette\n}\n\n/**\n * Generate colors from the official nextcloud color\n * You can provide how many colors you want (multiplied by 3)\n * if step = 6\n * 3 colors * 6 will result in 18 generated colors\n *\n * @param {number} [steps] Number of steps to go from a color to another\n * @return {object[]}\n */\nfunction GenColors(steps) {\n\tif (!steps) {\n\t\tsteps = 6\n\t}\n\n\tconst red = new Color(182, 70, 157)\n\tconst yellow = new Color(221, 203, 85)\n\tconst blue = new Color(0, 130, 201) // Nextcloud blue\n\n\tconst palette1 = mixPalette(steps, red, yellow)\n\tconst palette2 = mixPalette(steps, yellow, blue)\n\tconst palette3 = mixPalette(steps, blue, red)\n\n\treturn palette1.concat(palette2).concat(palette3)\n}\n\nexport default GenColors\n"],"names":["Color","r","g","b","stepCalc","steps","ends","step","mixPalette","color1","color2","palette","i","GenColors","red","yellow","blue","palette1","palette2","palette3"],"mappings":"AA+BA,SAASA,EAAMC,GAAGC,GAAGC,GAAG;AACvB,OAAK,IAAIF,GACT,KAAK,IAAIC,GACT,KAAK,IAAIC;AACV;AASA,SAASC,EAASC,GAAOC,GAAM;AAC9B,QAAMC,IAAO,IAAI,MAAM,CAAC;AACxB,SAAAA,EAAK,CAAC,KAAKD,EAAK,CAAC,EAAE,IAAIA,EAAK,CAAC,EAAE,KAAKD,GACpCE,EAAK,CAAC,KAAKD,EAAK,CAAC,EAAE,IAAIA,EAAK,CAAC,EAAE,KAAKD,GACpCE,EAAK,CAAC,KAAKD,EAAK,CAAC,EAAE,IAAIA,EAAK,CAAC,EAAE,KAAKD,GAC7BE;AACR;AAUA,SAASC,EAAWH,GAAOI,GAAQC,GAAQ;AAC1C,QAAMC,IAAU,CAAE;AAClBA,IAAQ,KAAKF,CAAM;AACnB,QAAMF,IAAOH,EAASC,GAAO,CAACI,GAAQC,CAAM,CAAC;AAC7C,WAASE,IAAI,GAAGA,IAAIP,GAAOO,KAAK;AAC/B,UAAMX,IA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