Always same format for color strings

This commit is contained in:
Éric Lemoine
2013-11-22 15:37:07 +01:00
parent b78bcce8ab
commit 6ca2fef0a3
3 changed files with 19 additions and 20 deletions

View File

@@ -1,16 +1,18 @@
goog.provide('ol.render.canvas');
/**
* @const {string}
*/
ol.render.canvas.defaultFillStyle = 'black';
goog.require('ol.color');
/**
* @const {string}
* @const {ol.Color}
*/
ol.render.canvas.defaultStrokeStyle = 'black';
ol.render.canvas.defaultFillStyle = ol.color.fromString('black');
/**
* @const {ol.Color}
*/
ol.render.canvas.defaultStrokeStyle = ol.color.fromString('black');
/**

View File

@@ -337,15 +337,14 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle =
function(fillStyle, strokeStyle) {
var state = this.state_;
if (!goog.isNull(fillStyle)) {
state.fillStyle = !goog.isNull(fillStyle.color) ?
ol.color.asString(fillStyle.color) : ol.render.canvas.defaultFillStyle;
state.fillStyle = ol.color.asString(!goog.isNull(fillStyle.color) ?
fillStyle.color : ol.render.canvas.defaultFillStyle);
} else {
state.fillStyle = undefined;
}
if (!goog.isNull(strokeStyle)) {
state.strokeStyle = !goog.isNull(strokeStyle.color) ?
ol.color.asString(strokeStyle.color) :
ol.render.canvas.defaultStrokeStyle;
state.strokeStyle = ol.color.asString(!goog.isNull(strokeStyle.color) ?
strokeStyle.color : ol.render.canvas.defaultStrokeStyle);
state.lineWidth = goog.isDef(strokeStyle.width) ?
strokeStyle.width : ol.render.canvas.defaultLineWidth;
} else {

View File

@@ -587,9 +587,8 @@ ol.render.canvas.LineStringReplay.prototype.setFillStrokeStyle =
goog.asserts.assert(!goog.isNull(this.state_));
goog.asserts.assert(goog.isNull(fillStyle));
goog.asserts.assert(!goog.isNull(strokeStyle));
this.state_.strokeStyle = !goog.isNull(strokeStyle.color) ?
ol.color.asString(strokeStyle.color) :
ol.render.canvas.defaultStrokeStyle;
this.state_.strokeStyle = ol.color.asString(!goog.isNull(strokeStyle.color) ?
strokeStyle.color : ol.render.canvas.defaultStrokeStyle);
this.state_.lineWidth = goog.isDef(strokeStyle.width) ?
strokeStyle.width : ol.render.canvas.defaultLineWidth;
};
@@ -737,15 +736,14 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyle =
goog.asserts.assert(!goog.isNull(fillStyle) || !goog.isNull(strokeStyle));
var state = this.state_;
if (!goog.isNull(fillStyle)) {
state.fillStyle = !goog.isNull(fillStyle.color) ?
ol.color.asString(fillStyle.color) : ol.render.canvas.defaultFillStyle;
state.fillStyle = ol.color.asString(!goog.isNull(fillStyle.color) ?
fillStyle.color : ol.render.canvas.defaultFillStyle);
} else {
state.fillStyle = undefined;
}
if (!goog.isNull(strokeStyle)) {
state.strokeStyle = !goog.isNull(strokeStyle.color) ?
ol.color.asString(strokeStyle.color) :
ol.render.canvas.defaultStrokeStyle;
state.strokeStyle = ol.color.asString(!goog.isNull(strokeStyle.color) ?
strokeStyle.color : ol.render.canvas.defaultStrokeStyle);
state.lineWidth = goog.isDef(strokeStyle.width) ?
strokeStyle.width : ol.render.canvas.defaultLineWidth;
} else {