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

Method getStepColors

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

* @function LevelRenderer.Tool.Color.prototype.getStepColors * @description 获取两种颜色之间渐变颜色数组。 * @param {Object} start - 起始颜色对象。 * @param {Object} end - 结束颜色对象。 * @param {number} step - 渐变级数。 * @returns {Array} 颜色数组。

(start, end, step)

Source from the content-addressed store, hash-verified

337 * @returns {Array} 颜色数组。
338 */
339 getStepColors(start, end, step) {
340 start = this.toRGBA(start);
341 end = this.toRGBA(end);
342 start = this.getData(start);
343 end = this.getData(end);
344
345 var colors = [];
346 var stepR = (end[0] - start[0]) / step;
347 var stepG = (end[1] - start[1]) / step;
348 var stepB = (end[2] - start[2]) / step;
349 var stepA = (end[3] - start[3]) / step;
350 // 生成颜色集合
351 // fix by linfeng 颜色堆积
352 for (var i = 0, r = start[0], g = start[1], b = start[2], a = start[3]; i < step; i++) {
353 colors[i] = this.toColor([
354 this.adjust(Math.floor(r), [0, 255]),
355 this.adjust(Math.floor(g), [0, 255]),
356 this.adjust(Math.floor(b), [0, 255]),
357 a.toFixed(4) - 0
358 ], 'rgba');
359 r += stepR;
360 g += stepG;
361 b += stepB;
362 a += stepA;
363 }
364 r = end[0];
365 g = end[1];
366 b = end[2];
367 a = end[3];
368 colors[i] = this.toColor([r, g, b, a], 'rgba');
369 return colors;
370 }
371
372 /**
373 * @function LevelRenderer.Tool.Color.prototype.getGradientColors

Callers 2

getGradientColorsMethod · 0.95
ColorSpec.jsFile · 0.45

Calls 4

toRGBAMethod · 0.95
getDataMethod · 0.95
toColorMethod · 0.95
adjustMethod · 0.95

Tested by

no test coverage detected