xxxxxxxxxx
function solution(image) {
let result = [];
for (let i = 0; i < image.length - 2; i++) {
let row = [];
for (let j = 0; j < image[i].length - 2; j++) {
let sum = 0;
for (let k = 0; k < 3; k++) {
for (let l = 0; l < 3; l++) {
sum += image[i + k][j + l];
}
}
row.push(Math.floor(sum / 9));
}
result.push(row);
}
return result;
}
xxxxxxxxxx
var form = document.getElementById("form");
form.addEventListener("focus", function( event ) {
event.target.style.background = "pink";
}, true);
form.addEventListener("blur", function( event ) {
event.target.style.background = "green";
}, true);
xxxxxxxxxx
What is blur () method?
blur() method removes keyboard focus from the current element.
xxxxxxxxxx
float red = 0;
float green = 0;
float blue = 0;
int N = 0;
for ( int x = -1 ; x < 2 ; x++ ) {
for ( int y = -1 ; y < 2 ; y++ ) {
if (i + x >= 0 && i + x < width && j + y >= 0 && j + y < height){
red += image[i+x][j+y].rgbtRed;
N++;
}
}
}
outputimage[j][i].rgbtRed = red / N;