how to make radial gradient in array code example

Example: how to make radial gradient in array

var grid = []
var gridWidth = 9
var gridHeight = 9

var euclideanDistance = (point1, point2) => {
  return Math.sqrt(
    Math.abs(Math.pow(point1.x - point2.x, 2)) +
    Math.abs(Math.pow(point1.y - point2.y, 2))
  )
}

var centrePoint = {x: Math.floor(gridWidth / 2), y: Math.floor(gridHeight / 2)}

var furthestDistanceFromCentre = euclideanDistance(
  {x: 0, y: 0}, centrePoint
)

for (var x = 0; x < gridWidth; x++) {
  grid[x] = []
  for (var y = 0; y < gridHeight; y++) {
    grid[x][y] = Math.floor(
      furthestDistanceFromCentre - euclideanDistance(
        {x: x, y: y}, centrePoint
      )
    )
  }
}