Let (x, y)
be the coordinates of the center, as indicated in the image below:

Then you can actually calculate the coordinates in the following way:
/* Returns an array of arrays, each one corresponding to each point's
coordinates (x, y) */
function getCoordinatesSquare (distance_to_center, x, y)
{
var points = [];
var dx = distance_to_center * Math.sin(Math.PI / 4);
var dy = distance_to_center * Math.cos(Math.PI / 4);
points[0] = [x - dx, y - dy]; // (x1, y1)
points[1] = [x - dx, y + dy]; // (x2, y2)
points[2] = [x + dx, y + dy]; // (x3, y3)
points[3] = [x + dx, y - dy]; // (x4, y4)
return points;
}
/* Set the initial conditions. */
var distance_to_center = 10;
var x = 4;
var y = 5;
/* Calculate. */
var coordinates = getCoordinatesSquare (distance_to_center, x, y);
/* Test the results. */
for (var i = 0; i < coordinates.length; i++){
console.log ("(" + coordinates[i][0] + ", " + coordinates[i][1] + ") \n");
}
And in this case the output will be:
(-3.0710678118654746, -2.0710678118654755)
(-3.0710678118654746, 12.071067811865476)
(11.071067811865476, 12.071067811865476)
(11.071067811865476, -2.0710678118654755)
And plotting the points:
