import json

input_file = open("blenderLogo.json", "r+")
input_data = input_file.read()
input_file.close()

input_data_json = json.loads(input_data)

sumX = 0
sumY = 0

for point in input_data_json:
    sumX += point[0]
    sumY += point[1]

avgX = sumX/len(input_data_json)
avgY = sumY/len(input_data_json)


output_data = []
for pointIndex in range(len(input_data_json)):
    output_data.append([input_data_json[pointIndex]
                        [0]-avgX, input_data_json[pointIndex][1]-avgY])

output_file = open("outputPoints.json", "w+")
output_file.write(str(output_data))
output_file.close()
