Skip to content

Instantly share code, notes, and snippets.

@codeaholicguy
Created November 22, 2017 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeaholicguy/e396300348a0fcaaf71bd1ff5bc29f47 to your computer and use it in GitHub Desktop.
Save codeaholicguy/e396300348a0fcaaf71bd1ff5bc29f47 to your computer and use it in GitHub Desktop.
// input (x, y)
const weights = [
[1, 4, 16, 4, 1],
[4, 16, 24, 16, 4],
[16, 24, 36, 24, 16],
[4, 16, 24, 16, 4],
[1, 4, 16, 4, 1],
];
let blur = 0;
let totalWeight = 0;
for (let i = 0; i < 5; i++) {
for (let j = 0; j < 5; j++) {
const weight = weights[i][j];
totalWeight += weight;
blur += weight * getPixelColor(x + i - 2, y + j -2);
}
}
blur /= totalWeight;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment