* @function StyleUtils.formatRGB * @description 将颜色数组转换成标准的rgb颜色格式 * @param {Array} colorArray - 颜色数组 * @returns {string} 'rgb(0,0,0)'或者 'rgba(0,0,0,0)'
(colorArray)
| 941 | * @returns {string} 'rgb(0,0,0)'或者 'rgba(0,0,0,0)' |
| 942 | */ |
| 943 | static formatRGB(colorArray) { |
| 944 | let rgb; |
| 945 | if (colorArray.length === 3) { |
| 946 | rgb = 'rgb('; |
| 947 | colorArray.forEach(function (color, index) { |
| 948 | index === 2 ? rgb += color : rgb += color + ','; |
| 949 | }); |
| 950 | } else { |
| 951 | rgb = 'rgba('; |
| 952 | colorArray.forEach(function (color, index) { |
| 953 | index === 3 ? rgb += color : rgb += color + ','; |
| 954 | }); |
| 955 | } |
| 956 | rgb += ")" |
| 957 | return rgb; |
| 958 | } |
| 959 | |
| 960 | /** |
| 961 | * @function StyleUtils.getCanvasFromSVG |
no test coverage detected