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

Method hexToRgba

src/openlayers/core/StyleUtils.js:558–574  ·  view source on GitHub ↗

* @function StyleUtils.hexToRgba * @description 十六进制转 RGBA 格式。 * @param {Object} hex - 十六进制格式参数。 * @param {number} opacity -Alpha 参数。 * @returns {string} 生成的 RGBA 格式。

(hex, opacity)

Source from the content-addressed store, hash-verified

556 * @returns {string} 生成的 RGBA 格式。
557 */
558 static hexToRgba(hex, opacity) {
559 var color = [], rgba = [];
560 hex = hex.replace(/#/, "");
561 if (hex.length == 3) {
562 var tmp = [];
563 for (let i = 0; i < 3; i++) {
564 tmp.push(hex.charAt(i) + hex.charAt(i));
565 }
566 hex = tmp.join("");
567 }
568 for (let i = 0; i < 6; i += 2) {
569 color[i] = "0x" + hex.substr(i, 2);
570 rgba.push(parseInt(Number(color[i])));
571 }
572 rgba.push(opacity);
573 return "rgba(" + rgba.join(",") + ")";
574 }
575
576 /**
577 * @function StyleUtils.getDefaultStyle

Callers 5

UtilSpec.jsFile · 0.80
UtilSpec.jsFile · 0.80
StyleUtils2Spec.jsFile · 0.80
_createHeatLayerMethod · 0.80

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected