Add alpha default value to ol.Color array form

This commit is contained in:
jonataswalker
2016-03-08 11:12:23 -03:00
parent 8c487d3036
commit 2564bb3e58
2 changed files with 7 additions and 2 deletions

View File

@@ -17,7 +17,8 @@ goog.require('ol.math');
/**
* A color represented as a short array [red, green, blue, alpha].
* red, green, and blue should be integers in the range 0..255 inclusive.
* alpha should be a float in the range 0..1 inclusive.
* alpha should be a float in the range 0..1 inclusive. If no alpha value is
* given then `1` will be used.
* @typedef {Array.<number>}
* @api
*/
@@ -293,7 +294,7 @@ ol.color.toString = function(color) {
if (b != (b | 0)) {
b = (b + 0.5) | 0;
}
var a = color[3];
var a = color[3] === undefined ? 1 : color[3];
return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
};