Standardizing color ranges (see #129)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
goog.provide('ol.Color');
|
||||
|
||||
goog.require('goog.color');
|
||||
goog.require('goog.math');
|
||||
|
||||
|
||||
|
||||
@@ -9,29 +10,29 @@ goog.require('goog.color');
|
||||
* @param {number} r Red, 0 to 255.
|
||||
* @param {number} g Green, 0 to 255.
|
||||
* @param {number} b Blue, 0 to 255.
|
||||
* @param {number} a Alpha, 0 (fully transparent) to 255 (fully opaque).
|
||||
* @param {number} a Alpha, 0 (fully transparent) to 1 (fully opaque).
|
||||
*/
|
||||
ol.Color = function(r, g, b, a) {
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.r = r;
|
||||
this.r = goog.math.clamp(r, 0, 255);
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.g = g;
|
||||
this.g = goog.math.clamp(g, 0, 255);
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.b = b;
|
||||
this.b = goog.math.clamp(b, 0, 255);
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a = a;
|
||||
this.a = goog.math.clamp(a, 0, 1);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -618,7 +618,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
|
||||
frameState = {
|
||||
animate: false,
|
||||
backgroundColor: goog.isDef(backgroundColor) ?
|
||||
backgroundColor : new ol.Color(1, 1, 1, 1),
|
||||
backgroundColor : new ol.Color(255, 255, 255, 1),
|
||||
coordinateToPixelMatrix: this.coordinateToPixelMatrix_,
|
||||
extent: null,
|
||||
layersArray: layersArray,
|
||||
|
||||
@@ -138,7 +138,7 @@ ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) {
|
||||
backgroundColor.r.toFixed(0) + ',' +
|
||||
backgroundColor.g.toFixed(0) + ',' +
|
||||
backgroundColor.b.toFixed(0) + ')';
|
||||
context.globalAlpha = 1;
|
||||
context.globalAlpha = backgroundColor.a;
|
||||
context.fillRect(0, 0, size.width, size.height);
|
||||
|
||||
goog.array.forEach(frameState.layersArray, function(layer) {
|
||||
|
||||
@@ -490,7 +490,8 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
|
||||
gl.bindFramebuffer(goog.webgl.FRAMEBUFFER, null);
|
||||
|
||||
var clearColor = frameState.backgroundColor;
|
||||
gl.clearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
|
||||
gl.clearColor(clearColor.r / 255, clearColor.g / 255,
|
||||
clearColor.b / 255, clearColor.a);
|
||||
gl.clear(goog.webgl.COLOR_BUFFER_BIT);
|
||||
gl.enable(goog.webgl.BLEND);
|
||||
gl.viewport(0, 0, size.width, size.height);
|
||||
|
||||
Reference in New Issue
Block a user