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

Method toArray

src/common/overlay/levelRenderer/Color.js:445–463  ·  view source on GitHub ↗

* @function LevelRenderer.Tool.Color.prototype.toArray * @description 颜色字符串转换为rgba数组。 * @param {string} color - 颜色。 * @returns {Array. } 颜色值数组。

(color)

Source from the content-addressed store, hash-verified

443 * @returns {Array.<number>} 颜色值数组。
444 */
445 toArray(color) {
446 color = this.trim(color);
447 if (color.indexOf('rgba') < 0) {
448 color = this.toRGBA(color);
449 }
450
451 var data = [];
452 var i = 0;
453 color.replace(/[\d.]+/g, function (n) {
454 if (i < 3) {
455 n = n | 0;
456 } else {
457 // Alpha
458 n = +n;
459 }
460 data[i++] = n;
461 });
462 return data;
463 }
464
465 /**
466 * @function LevelRenderer.Tool.Color.prototype.convert

Callers 1

createTrackClipMethod · 0.45

Calls 3

trimMethod · 0.95
toRGBAMethod · 0.95
indexOfMethod · 0.80

Tested by

no test coverage detected