JavaScript Uma maneira mais fácil de centralizar o retângulo na tela
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var width = 130, height = 80;//Dimensions of rectangle
var x = canvas.Width/2, y = canvas.Height/2;//Center coordinates of rectangle
ctx.rect(x - width/2, y - height/2, width, height);
ctx.stroke();
Aggressive Aardvark