const m = [];
for (let i = 0; i < w; i++) {
m.push([]);
for (let j = 0; j < h; j++) {
m[i].push(0);
}
}
for (let i = 0; i < w; i++) {
for (let j = 0; j < h; j++) {
m[i][j] = Math.min(i,j,w-i,h-j)+1
}
}
console.log(m);