1 line
5.7 KiB
JSON
1 line
5.7 KiB
JSON
|
{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport { Color as RcColor } from '@rc-component/color-picker';\nimport { AggregationColor } from './color';\nexport const generateColor = color => {\n if (color instanceof AggregationColor) {\n return color;\n }\n return new AggregationColor(color);\n};\nexport const getRoundNumber = value => Math.round(Number(value || 0));\nexport const getColorAlpha = color => getRoundNumber(color.toHsb().a * 100);\n/** Return the color whose `alpha` is 1 */\nexport const genAlphaColor = (color, alpha) => {\n const hsba = color.toHsb();\n hsba.a = alpha || 1;\n return generateColor(hsba);\n};\n/**\n * Get percent position color. e.g. [10%-#fff, 20%-#000], 15% => #888\n */\nexport const getGradientPercentColor = (colors, percent) => {\n const filledColors = [{\n percent: 0,\n color: colors[0].color\n }].concat(_toConsumableArray(colors), [{\n percent: 100,\n color: colors[colors.length - 1].color\n }]);\n for (let i = 0; i < filledColors.length - 1; i += 1) {\n const startPtg = filledColors[i].percent;\n const endPtg = filledColors[i + 1].percent;\n const startColor = filledColors[i].color;\n const endColor = filledColors[i + 1].color;\n if (startPtg <= percent && percent <= endPtg) {\n const dist = endPtg - startPtg;\n if (dist === 0) {\n return startColor;\n }\n const ratio = (percent - startPtg) / dist * 100;\n const startRcColor = new RcColor(startColor);\n const endRcColor = new RcColor(endColor);\n return startRcColor.mix(endRcColor, ratio).toRgbString();\n }\n }\n // This will never reach\n /* istanbul ignore next */\n return '';\n};","map":{"version":3,"names":["_toConsumableArray","Color","RcColor","AggregationColor","generateColor","color","getRoundNumber","value","Math","round","Number","getColorAlpha","toHsb","a","genAlphaColor","alpha","hsba","getGradientPercentColor","colors","percent","filledColors","concat","length","i","startPtg","endPtg","startColor","endColor","dist","ratio","startRcColor","endRcColor","mix","toRgbString"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/antd/es/color-picker/util.js"],"sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport { Color as RcColor } from '@rc-component/color-picker';\nimport { AggregationColor } from './color';\nexport const generateColor = color => {\n if (color instanceof AggregationColor) {\n return color;\n }\n return new AggregationColor(color);\n};\nexport const getRoundNumber = value => Math.round(Number(value || 0));\nexport const getColorAlpha = color => getRoundNumber(color.toHsb().a * 100);\n/** Return the color whose `alpha` is 1 */\nexport const genAlphaColor = (color, alpha) => {\n const hsba = color.toHsb();\n hsba.a = alpha || 1;\n return generateColor(hsba);\n};\n/**\n * Get percent position color. e.g. [10%-#fff, 20%-#000], 15% => #888\n */\nexport const getGradientPercentColor = (colors, percent) => {\n const filledColors = [{\n percent: 0,\n color: colors[0].color\n }].concat(_toConsumableArray(colors), [{\n percent: 100,\n color: colors[colors.length - 1].color\n }]);\n for (let i = 0; i < filledColors.length - 1; i += 1) {\n const startPtg = filledColors[i].percent;\n const endPtg = filledColors[i + 1].percent;\n const startColor = filledColors[i].color;\n const endColor = filledColors[i + 1].color;\n if (startPtg <= percent && percent <= endPtg) {\n const dist = endPtg - startPtg;\n if (dist === 0) {\n return startColor;\n }\n const ratio = (percent - startPtg) / dist * 100;\n const startRcColor = new RcColor(startColor);\n const endRcColor = new RcColor(endColor);\n return startRcColor.mix(endRcColor, ratio).toRgbString();\n }\n }\n // This will never reach\n /* istanbul ignore next */\n return '';\n};"],"mappings":"AAAA,OAAOA,kBAAkB,MAAM,8CAA8C;AAC7E,SAASC,KAAK,IAAIC,OAAO,QAAQ,4BAA4B;AAC7D,SAASC,g
|