src/libraries/img/process.js
function (inData, outData, width, height, options) {
        options = defaultOptions(options, {amount: 1, angle: 0});
        var i, n = width * height * 4,
            amount = options.amount,
            angle = options.angle,
            x = Math.cos(-angle) * amount,
            y = Math.sin(-angle) * amount,

            a00 = -x - y,
            a10 = -x,
            a20 = y - x,
            a01 = -y,
            a21 = y,
            a02 = -y + x,
            a12 = x,
            a22 = y + x,

            tmpData = [];

        convolve3x3(inData, tmpData, width, height,
            [
                [a00, a01, a02],
                [a10, 0, a12],
                [a20, a21, a22]
            ]);

        for (i = 0; i < n; i += 4) {
            outData[i] = 128 + tmpData[i];
            outData[i + 1] = 128 + tmpData[i + 1];
            outData[i + 2] = 128 + tmpData[i + 2];
            outData[i + 3] = inData[i + 3];
        }
    }
function (inData, outData, width, height, options) {
        options = defaultOptions(options, {amount: 1, angle: 0});
        var i, n = width * height * 4,
            amount = options.amount,
            angle = options.angle,
            x = Math.cos(-angle) * amount,
            y = Math.sin(-angle) * amount,

            a00 = -x - y,
            a10 = -x,
            a20 = y - x,
            a01 = -y,
            a21 = y,
            a02 = -y + x,
            a12 = x,
            a22 = y + x,

            tmpData = [];

        convolve3x3(inData, tmpData, width, height,
            [
                [a00, a01, a02],
                [a10, 0, a12],
                [a20, a21, a22]
            ]);

        for (i = 0; i < n; i += 4) {
            outData[i] = 128 + tmpData[i];
            outData[i + 1] = 128 + tmpData[i + 1];
            outData[i + 2] = 128 + tmpData[i + 2];
            outData[i + 3] = inData[i + 3];
        }
    }
function ( inData , outData , width , height , options ) { options = defaultOptions ( options , { amount : 1 , angle : 0 } ) ; var i , n = width * height * 4 , amount = options . amount , angle = options . angle , x = Math . cos ( - angle ) * amount , y = Math . sin ( - angle ) * amount , a00 = - x - y , a10 = - x , a20 = y - x , a01 = - y , a21 = y , a02 = - y + x , a12 = x , a22 = y + x , tmpData = [ ] ; convolve3x3 ( inData , tmpData , width , height , [ [ a00 , a01 , a02 ] , [ a10 , 0 , a12 ] , [ a20 , a21 , a22 ] ] ) ; for ( i = 0 ; i < n ; i += 4 ) { outData [ i ] = 128 + tmpData [ i ] ; outData [ i + 1 ] = 128 + tmpData [ i + 1 ] ; outData [ i + 2 ] = 128 + tmpData [ i + 2 ] ; outData [ i + 3 ] = inData [ i + 3 ] ; } }
3x3 directional emboss
3x3 directional emboss