Added consideration for the canvas not being at 0,0 on the window