MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / formatRGB

Method formatRGB

src/openlayers/core/StyleUtils.js:943–958  ·  view source on GitHub ↗

* @function StyleUtils.formatRGB * @description 将颜色数组转换成标准的rgb颜色格式 * @param {Array} colorArray - 颜色数组 * @returns {string} 'rgb(0,0,0)'或者 'rgba(0,0,0,0)'

(colorArray)

Source from the content-addressed store, hash-verified

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

Callers 2

StyleUtils2Spec.jsFile · 0.80
setColorToCanvasMethod · 0.80

Calls 1

forEachMethod · 0.80

Tested by

no test coverage detected