diff --git a/Gruntfile.js b/Gruntfile.js index 6f8cb7cb..58814269 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -40,9 +40,9 @@ module.exports = function(grunt) { 'src/filters/Brighten.js', 'src/filters/Invert.js', 'src/filters/Blur.js', - 'src/filters/Mask.js'/*, - 'src/filters/Colors.js', - 'src/filters/Convolution.js'*/ + 'src/filters/Mask.js', + 'src/filters/ColorPack.js', + 'src/filters/ConvolvePack.js' ]; var unitTestFiles = [ diff --git a/src/filters/Colors.js b/src/filters/ColorPack.js similarity index 93% rename from src/filters/Colors.js rename to src/filters/ColorPack.js index cec8992b..dfc17464 100644 --- a/src/filters/Colors.js +++ b/src/filters/ColorPack.js @@ -80,13 +80,14 @@ }; /** - * shift hue + * Shift Hue Filter. * @function * @memberof Kinetic.Filters * @param {Object} imageData + * @author ippo615 */ Kinetic.Filters.ShiftHue = function(imageData) { - shift_hue(imageData,this.getFilterHueShiftDeg()); + shift_hue(imageData, this.getFilterHueShiftDeg() % 360 ); }; Kinetic.Node.addFilterGetterSetter(Kinetic.Image, 'filterHueShiftDeg', 0); @@ -106,10 +107,12 @@ /** - * colorizes the image so that it is just varying shades of the specified color + * Colorize Filter. + * colorizes the image so that it is just varying shades of the specified color * @function * @memberof Kinetic.Filters * @param {Object} imageData + * @author ippo615 */ Kinetic.Filters.Colorize = function(imageData) { var data = imageData.data; @@ -119,7 +122,7 @@ hsl = rgb_to_hsl(color[0],color[1],color[2]), hue = hsl[0]; - // Color it red + // Color it red, by removing green and blue for(var i = 0; i < data.length; i += 4) { data[i + 1] = 0; data[i + 2] = 0; @@ -146,3 +149,4 @@ */ })(); + diff --git a/src/filters/Convolution.js b/src/filters/Convolution.js deleted file mode 100644 index 92af8566..00000000 --- a/src/filters/Convolution.js +++ /dev/null @@ -1,393 +0,0 @@ -(function() { - - var convolve_internal = function(imageData,matrix){ - // Input data - var pixels = imageData.data, - imageSizeX = imageData.width, - imageSizeY = imageData.height, - nPixels = imageSizeX*imageSizeY, - pixel; - - // An array for storing the result - var result = []; - result.length = imageSizeX*imageSizeY*4; - - // Determine the size and demsionality of the matrix - // Note: it should be square and odd (3,5,7,9 etc...) - var is2D = (matrix[0].length > 0) || 0, - matrixSizeX = matrix.length, - matrixSizeY = matrix.length; - - // Make sure we don't try to access pixels outside the image - var xMax = Math.floor(imageSizeX - matrixSizeX/2), - xMin = Math.floor(matrixSizeX/2), - yMax = Math.floor(imageSizeY - matrixSizeY/2), - yMin = Math.floor(matrixSizeY/2); - - // Accumlators and positions for iterating - var r,g,b,a, x, y, pos, i,j; - - // Handle the 2D matrix - if( is2D ){ - for( y=yMin; y0)?px:-px; + py = (y+i-matrixMidY) % imageSizeY; + py = (py>0)?py:-py; + + // get the pixel and convolve + pos = (py*imageSizeX + px)*4; + r += matrix[j][i]*pixels[pos+0]; + g += matrix[j][i]*pixels[pos+1]; + b += matrix[j][i]*pixels[pos+2]; + //a += matrix[j][i]*pixels[pos+3]; + } + } + + // Store the result + pos = (y*imageSizeX+x)*4; + result[pos+0] = r; + result[pos+1] = g; + result[pos+2] = b; + //result[pos+3] = a; + } + } + + // copy the result to the original canvas + var lastPos = nPixels*4; + for( pos=0; pos + + + + + + + + + + + + diff --git a/tests/html/index.html b/tests/html/index.html index b50d21de..602b29a8 100644 --- a/tests/html/index.html +++ b/tests/html/index.html @@ -4,12 +4,13 @@

KineticJS Test Suite

atomated test counts updated on 08-10-2013

- \ No newline at end of file + diff --git a/tests/html/performanceTests.html b/tests/html/performanceTests.html index 4660670c..d743d56e 100644 --- a/tests/html/performanceTests.html +++ b/tests/html/performanceTests.html @@ -8,7 +8,7 @@ - +