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

Method convert

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

* @function LevelRenderer.Tool.Color.prototype.convert * @description 颜色格式转化。 * @param {Array} data - 颜色值数组。 * @param {string} format - 格式,默认'rgb' * @returns {string} 颜色。

(color, format)

Source from the content-addressed store, hash-verified

470 * @returns {string} 颜色。
471 */
472 convert(color, format) {
473 if (!this.isCalculableColor(color)) {
474 return color;
475 }
476 var data = this.getData(color);
477 var alpha = data[3];
478 if (typeof alpha === 'undefined') {
479 alpha = 1;
480 }
481
482 if (color.indexOf('hsb') > -1) {
483 data = this._HSV_2_RGB(data);
484 } else if (color.indexOf('hsl') > -1) {
485 data = this._HSL_2_RGB(data);
486 }
487
488 if (format.indexOf('hsb') > -1 || format.indexOf('hsv') > -1) {
489 data = this._RGB_2_HSB(data);
490 } else if (format.indexOf('hsl') > -1) {
491 data = this._RGB_2_HSL(data);
492 }
493
494 data[3] = alpha;
495
496 return this.toColor(data, format);
497 }
498
499 /**
500 * @function LevelRenderer.Tool.Color.prototype.toRGBA

Callers 15

toRGBAMethod · 0.95
toRGBMethod · 0.95
toHexMethod · 0.95
toHSVAMethod · 0.95
toHSVMethod · 0.95
toHSBAMethod · 0.95
toHSBMethod · 0.95
toHSLAMethod · 0.95
toHSLMethod · 0.95
ColorUtilSpec.jsFile · 0.80
ColorSpec.jsFile · 0.80
MapFunction · 0.80

Calls 8

isCalculableColorMethod · 0.95
getDataMethod · 0.95
_HSV_2_RGBMethod · 0.95
_HSL_2_RGBMethod · 0.95
_RGB_2_HSBMethod · 0.95
_RGB_2_HSLMethod · 0.95
toColorMethod · 0.95
indexOfMethod · 0.80

Tested by

no test coverage detected