A <canvas> has its own width and height , which not only determine its physical size (except CSS), but also its logical size (the number of rows / columns of pixels on its drawing surface). When CSS resizes, the canvas stretches to fit, but does not change its logical size. In principle, pixels are also stretched, so the logical and physical coordinates no longer match.
To fix the problem, you can either do the math according to the coordinate backups, or use only the canvasβs own width / height for their size, or set the width and height properties of the canvas after the fact matches the width and height set by CSS.
chao Jan 02 '14 at 10:21 2014-01-02 22:21
source share