{"version":3,"file":"GenColors-Di5GSft7.cjs","sources":["../../src/utils/GenColors.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport { t } from '../l10n.js'\n\nexport class Color {\n\n\t/**\n\t * @param {number} r The red value\n\t * @param {number} g The green value\n\t * @param {number} b The blue value\n\t * @param {string} [name] The name of the color\n\t */\n\tconstructor(r, g, b, name) {\n\t\tthis.r = r\n\t\tthis.g = g\n\t\tthis.b = b\n\t\tif (name) {\n\t\t\tthis.name = name\n\t\t}\n\t}\n\n\tget color() {\n\t\tconst toHex = (num) => `00${num.toString(16)}`.slice(-2)\n\t\treturn `#${toHex(this.r)}${toHex(this.g)}${toHex(this.b)}`\n\t}\n\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 {Color} color1 The first color\n * @param {Color} 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 = Math.floor(color1.r + step[0] * i)\n\t\tconst g = Math.floor(color1.g + step[1] * i)\n\t\tconst b = Math.floor(color1.b + step[2] * i)\n\t\tpalette.push(new Color(r, g, b))\n\t}\n\treturn palette\n}\n\n/**\n * Like GenColor(4) but with labels\n */\nexport const defaultPalette = [\n\tnew Color(182, 70, 157, t('Purple')),\n\tnew Color(\n\t\t191, 103, 139,\n\t\tt('Rosy brown'), // TRANSLATORS: A color name for RGB(191, 103, 139)\n\t),\n\tnew Color(\n\t\t201, 136, 121,\n\t\tt('Feldspar'), // TRANSLATORS: A color name for RGB(201, 136, 121)\n\t),\n\tnew Color(\n\t\t211, 169, 103,\n\t\tt('Whiskey'), // TRANSLATORS: A color name for RGB(211, 169, 103)\n\t),\n\tnew Color(\n\t\t221, 203, 85,\n\t\tt('Gold'),\n\t),\n\tnew Color(\n\t\t165, 184, 114,\n\t\tt('Olivine'), // TRANSLATORS: A color name for RGB(165, 184, 114)\n\t),\n\tnew Color(\n\t\t110, 166, 143,\n\t\tt('Acapulco'), // TRANSLATORS: A color name for RGB(110, 166, 143)\n\t),\n\tnew Color(\n\t\t55, 148, 172,\n\t\tt('Boston Blue'), // TRANSLATORS: A color name for RGB(55, 148, 172)\n\t),\n\tnew Color(\n\t\t0, 130, 201,\n\t\tt('Nextcloud blue'),\n\t),\n\tnew Color(\n\t\t45, 115, 190,\n\t\tt('Mariner'), // TRANSLATORS: A color name for RGB(45, 115, 190)\n\t),\n\tnew Color(\n\t\t91, 100, 179,\n\t\tt('Blue Violet'), // TRANSLATORS: A color name for RGB(91, 100, 179)\n\t),\n\tnew Color(\n\t\t136, 85, 168,\n\t\tt('Deluge'), // TRANSLATORS: A color name for RGB(136, 85, 168)\n\t),\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 */\nexport function GenColors(steps) {\n\tif (!steps) {\n\t\tsteps = 6\n\t}\n\n\tif (steps === 4) {\n\t\treturn defaultPalette\n\t}\n\n\tconst red = new Color(182, 70, 157, t('Purple'))\n\tconst yellow = new Color(221, 203, 85, t('Gold'))\n\tconst blue = new Color(0, 130, 201, t('Nextcloud blue'))\n\n\tconst palette1 = mixPalette(steps, red, yellow)\n\tconst palette2 = mixPalette(steps, yellow, blue)\n\tconst palette3 = mixPalette(steps, blue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