Created
November 22, 2017 17:04
-
-
Save codeaholicguy/e396300348a0fcaaf71bd1ff5bc29f47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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