Allow colors in styles to be strings or arrays

This commit is contained in:
Tom Payne
2013-11-13 21:42:53 +01:00
parent 47820440ed
commit 1ae0e845f8
4 changed files with 16 additions and 11 deletions
+3 -2
View File
@@ -4,6 +4,7 @@
goog.provide('ol.render.canvas.Immediate');
goog.require('goog.asserts');
goog.require('ol.color');
goog.require('ol.extent');
goog.require('ol.render.IRender');
goog.require('ol.style.fill');
@@ -270,13 +271,13 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle =
var state = this.state_;
if (!ol.style.fill.equals(state.fillStyle, fillStyle)) {
if (goog.isDefAndNotNull(fillStyle)) {
context.fillStyle = fillStyle.color;
context.fillStyle = ol.color.asString(fillStyle.color);
}
state.fillStyle = fillStyle;
}
if (!ol.style.stroke.equals(state.strokeStyle, strokeStyle)) {
if (goog.isDefAndNotNull(strokeStyle)) {
context.strokeStyle = strokeStyle.color;
context.strokeStyle = ol.color.asString(strokeStyle.color);
context.lineWidth = strokeStyle.width;
}
state.strokeStyle = strokeStyle;
+3 -2
View File
@@ -6,6 +6,7 @@ goog.provide('ol.render.canvas.ReplayGroup');
goog.require('goog.array');
goog.require('goog.asserts');
goog.require('goog.object');
goog.require('ol.color');
goog.require('ol.extent');
goog.require('ol.geom.flat');
goog.require('ol.render.IRender');
@@ -138,12 +139,12 @@ ol.render.canvas.Replay.prototype.draw = function(context, transform) {
} else if (type == ol.render.canvas.Instruction.SET_FILL_STYLE) {
goog.asserts.assert(goog.isObject(instruction[1]));
var fillStyle = /** @type {ol.style.Fill} */ (instruction[1]);
context.fillStyle = fillStyle.color;
context.fillStyle = ol.color.asString(fillStyle.color);
++i;
} else if (type == ol.render.canvas.Instruction.SET_STROKE_STYLE) {
goog.asserts.assert(goog.isObject(instruction[1]));
var strokeStyle = /** @type {ol.style.Stroke} */ (instruction[1]);
context.strokeStyle = strokeStyle.color;
context.strokeStyle = ol.color.asString(strokeStyle.color);
context.lineWidth = strokeStyle.width;
++i;
} else if (type == ol.render.canvas.Instruction.STROKE) {