@nextcloud/vue
Version:
Nextcloud vue components
1 lines • 4.36 kB
Source Map (JSON)
{"version":3,"file":"GenColors-8097de04.cjs","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,EAAGC,EAAGC,EAAG,CACvB,KAAK,EAAIF,EACT,KAAK,EAAIC,EACT,KAAK,EAAIC,CACV,CASA,SAASC,EAASC,EAAOC,EAAM,CAC9B,MAAMC,EAAO,IAAI,MAAM,CAAC,EACxB,OAAAA,EAAK,CAAC,GAAKD,EAAK,CAAC,EAAE,EAAIA,EAAK,CAAC,EAAE,GAAKD,EACpCE,EAAK,CAAC,GAAKD,EAAK,CAAC,EAAE,EAAIA,EAAK,CAAC,EAAE,GAAKD,EACpCE,EAAK,CAAC,GAAKD,EAAK,CAAC,EAAE,EAAIA,EAAK,CAAC,EAAE,GAAKD,EAC7BE,CACR,CAUA,SAASC,EAAWH,EAAOI,EAAQC,EAAQ,CAC1C,MAAMC,EAAU,CAAE,EAClBA,EAAQ,KAAKF,CAAM,EACnB,MAAMF,EAAOH,EAASC,EAAO,CAACI,EAAQC,CAAM,CAAC,EAC7C,QAASE,EAAI,EAAGA,EAAIP,EAAOO,IAAK,CAC/B,MAAMX,EAA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