Overloading fill color (polygon or text) with CanvasPattern and CanvasGradient.
This commit is contained in:
@@ -3,6 +3,7 @@ goog.provide('ol.style.Circle');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.color');
|
||||
goog.require('ol.colorlike');
|
||||
goog.require('ol.has');
|
||||
goog.require('ol.render.canvas');
|
||||
goog.require('ol.style.Fill');
|
||||
@@ -340,7 +341,7 @@ ol.style.Circle.prototype.draw_ = function(renderOptions, context, x, y) {
|
||||
this.radius_, 0, 2 * Math.PI, true);
|
||||
|
||||
if (this.fill_) {
|
||||
context.fillStyle = ol.color.asString(this.fill_.getColor());
|
||||
context.fillStyle = ol.colorlike.asColorLike(this.fill_.getColor());
|
||||
context.fill();
|
||||
}
|
||||
if (this.stroke_) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
goog.provide('ol.style.Fill');
|
||||
|
||||
goog.require('ol.ColorLike');
|
||||
goog.require('ol.color');
|
||||
|
||||
|
||||
@@ -17,7 +18,7 @@ ol.style.Fill = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Color|string}
|
||||
* @type {ol.Color|ol.ColorLike}
|
||||
*/
|
||||
this.color_ = options.color !== undefined ? options.color : null;
|
||||
|
||||
@@ -31,7 +32,7 @@ ol.style.Fill = function(opt_options) {
|
||||
|
||||
/**
|
||||
* Get the fill color.
|
||||
* @return {ol.Color|string} Color.
|
||||
* @return {ol.Color|ol.ColorLike} Color.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Fill.prototype.getColor = function() {
|
||||
@@ -42,7 +43,7 @@ ol.style.Fill.prototype.getColor = function() {
|
||||
/**
|
||||
* Set the color.
|
||||
*
|
||||
* @param {ol.Color|string} color Color.
|
||||
* @param {ol.Color|ol.ColorLike} color Color.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Fill.prototype.setColor = function(color) {
|
||||
@@ -56,8 +57,15 @@ ol.style.Fill.prototype.setColor = function(color) {
|
||||
*/
|
||||
ol.style.Fill.prototype.getChecksum = function() {
|
||||
if (this.checksum_ === undefined) {
|
||||
this.checksum_ = 'f' + (this.color_ ?
|
||||
ol.color.asString(this.color_) : '-');
|
||||
if (
|
||||
this.color_ instanceof CanvasPattern ||
|
||||
this.color_ instanceof CanvasGradient
|
||||
) {
|
||||
this.checksum_ = goog.getUid(this.color_).toString();
|
||||
} else {
|
||||
this.checksum_ = 'f' + (this.color_ ?
|
||||
ol.color.asString(this.color_) : '-');
|
||||
}
|
||||
}
|
||||
|
||||
return this.checksum_;
|
||||
|
||||
@@ -3,6 +3,7 @@ goog.provide('ol.style.RegularShape');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.color');
|
||||
goog.require('ol.colorlike');
|
||||
goog.require('ol.has');
|
||||
goog.require('ol.render.canvas');
|
||||
goog.require('ol.style.AtlasManager');
|
||||
@@ -433,7 +434,7 @@ ol.style.RegularShape.prototype.draw_ = function(renderOptions, context, x, y) {
|
||||
}
|
||||
|
||||
if (this.fill_) {
|
||||
context.fillStyle = ol.color.asString(this.fill_.getColor());
|
||||
context.fillStyle = ol.colorlike.asColorLike(this.fill_.getColor());
|
||||
context.fill();
|
||||
}
|
||||
if (this.stroke_) {
|
||||
|
||||
Reference in New Issue
Block a user