From 47820440ed1e0a484bd4b6288eec99d5a2ee3f83 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 13 Nov 2013 21:41:38 +0100 Subject: [PATCH] Add ol.color.stringOrColorEquals --- src/ol/color/color.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ol/color/color.js b/src/ol/color/color.js index d1f2882cbc..f50c852634 100644 --- a/src/ol/color/color.js +++ b/src/ol/color/color.js @@ -279,3 +279,22 @@ ol.color.transform = function(color, transform, opt_color) { result[3] = color[3]; return ol.color.normalize(result, result); }; + + +/** + * @param {ol.Color|string} color1 Color2. + * @param {ol.Color|string} color2 Color2. + * @return {boolean} Equals. + */ +ol.color.stringOrColorEquals = function(color1, color2) { + if (color1 === color2 || color1 == color2) { + return true; + } + if (goog.isString(color1)) { + color1 = ol.color.fromString(color1); + } + if (goog.isString(color2)) { + color2 = ol.color.fromString(color2); + } + return ol.color.equals(color1, color2); +};