From 7cf433eb68532d07220ce0c9fc22c5329ad81da7 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 8 Mar 2016 09:03:49 -0700 Subject: [PATCH] Remove unused ol.color.blend() --- src/ol/color/color.js | 42 -------------------------------------- test/spec/ol/color.test.js | 27 ------------------------ 2 files changed, 69 deletions(-) diff --git a/src/ol/color/color.js b/src/ol/color/color.js index 183cf2339f..cd64a0cefb 100644 --- a/src/ol/color/color.js +++ b/src/ol/color/color.js @@ -54,48 +54,6 @@ ol.color.rgbaColorRe_ = /^(?:rgba)?\((0|[1-9]\d{0,2}),\s?(0|[1-9]\d{0,2}),\s?(0|[1-9]\d{0,2}),\s?(0|1|0\.\d{0,10})\)$/i; -/** - * @param {ol.Color} dst Destination. - * @param {ol.Color} src Source. - * @param {ol.Color=} opt_color Color. - * @return {ol.Color} Color. - */ -ol.color.blend = function(dst, src, opt_color) { - // http://en.wikipedia.org/wiki/Alpha_compositing - // FIXME do we need to scale by 255? - var out = opt_color ? opt_color : []; - var dstA = dst[3]; - var srcA = src[3]; - if (dstA == 1) { - out[0] = (src[0] * srcA + dst[0] * (1 - srcA) + 0.5) | 0; - out[1] = (src[1] * srcA + dst[1] * (1 - srcA) + 0.5) | 0; - out[2] = (src[2] * srcA + dst[2] * (1 - srcA) + 0.5) | 0; - out[3] = 1; - } else if (srcA === 0) { - out[0] = dst[0]; - out[1] = dst[1]; - out[2] = dst[2]; - out[3] = dstA; - } else { - var outA = srcA + dstA * (1 - srcA); - if (outA === 0) { - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 0; - } else { - out[0] = ((src[0] * srcA + dst[0] * dstA * (1 - srcA)) / outA + 0.5) | 0; - out[1] = ((src[1] * srcA + dst[1] * dstA * (1 - srcA)) / outA + 0.5) | 0; - out[2] = ((src[2] * srcA + dst[2] * dstA * (1 - srcA)) / outA + 0.5) | 0; - out[3] = outA; - } - } - goog.asserts.assert(ol.color.isValid(out), - 'Output color of blend should be a valid color'); - return out; -}; - - /** * Return the color as an array. This function maintains a cache of calculated * arrays which means the result should not be modified. diff --git a/test/spec/ol/color.test.js b/test/spec/ol/color.test.js index 66c1845f3c..b0403f3fb2 100644 --- a/test/spec/ol/color.test.js +++ b/test/spec/ol/color.test.js @@ -3,33 +3,6 @@ goog.provide('ol.test.color'); describe('ol.color', function() { - describe('ol.color.blend', function() { - it('blends red (a=1) and blue (a=1) to blue (a=1)', function() { - var red = [255, 0, 0, 1]; - var blue = [0, 0, 255, 1]; - var blended = ol.color.blend(red, blue); - expect(blended).to.eql([0, 0, 255, 1]); - }); - it('blends red (a=1) and blue (a=0) to red (a=1)', function() { - var red = [255, 0, 0, 1]; - var blue = [0, 0, 255, 0]; - var blended = ol.color.blend(red, blue); - expect(blended).to.eql([255, 0, 0, 1]); - }); - it('blends red (a=0.5) and blue (a=0.5) to purple (a=0.75)', function() { - var red = [255, 0, 0, 0.5]; - var blue = [0, 0, 255, 0.5]; - var blended = ol.color.blend(red, blue); - expect(blended).to.eql([85, 0, 170, 0.75]); - }); - it('blends red (a=0.5) and blue (a=0) to red (a=0.5)', function() { - var red = [255, 0, 0, 0.5]; - var blue = [0, 0, 255, 0]; - var blended = ol.color.blend(red, blue); - expect(blended).to.eql([255, 0, 0, 0.5]); - }); - }); - describe('ol.color.fromString', function() { before(function() {