class BlurEffect extends BasicEffect
constructor: (@_radius, @_ctx) ->
proceed: (target) ->
newImageData = @_ctx.createImageData(target)
w = target.width
h = target.height
for i in [0...w]
for j in [0...h]
total = {
red: 0
green: 0
blue: 0
}
for ky in [-@_radius...@_radius]
for kx in [-@_radius...@_radius]
pixel = @getPixel(target, i+kx, j+ky)
total.red+=pixel.red
total.green+=pixel.green
total.blue+=pixel.blue
newImageData.data[(j * w * 4) + (i * 4)] = total.red/ Math.pow(@_radius * 2 + 1, 2)
newImageData.data[(j * w * 4) + (i * 4) + 1] = total.green/ Math.pow(@_radius * 2 + 1, 2)
newImageData.data[(j * w * 4) + (i * 4) + 2] = total.blue/ Math.pow(@_radius * 2 + 1, 2)
newImageData.data[(j * w * 4) + (i * 4) + 3] = target.data[(j * w * 4) + (i * 4) + 3]
newImageData
for ky in [-@_radius...@_radius]
будет оверхед на определения направления