Canvas automatic expansion / reduction calculation:
// get the position (-880, -100) with respect to the dragged canvas graphics var X = Math.ceil (bounds.x / this.view.scale - this.view.translate.x); var Y = the Math. ceil (bounds.y / this.view.scale - this.view.translate.y); // get the aspect ratio according to the scaling var Math.floor W = (bounds.width / this.view.scale); var H Math.floor = (bounds.height / this.view.scale); // calculate the ratio of the upper left corner of the original size of the canvas var Math.floor X0 = (X / Size.Width); var Math.floor yO = (Y / Size.Height); // calculate the ratio of the lower right corner of the original size of the canvas var Math.ceil W0 = ((X + W) / Size.Width) - X0; var Math.ceil H0 = ((Y + H) / Size.Height) - yO; // (- 2, 1,3,2) return new new mxRectangle (X0, yO, W0, H0);
Enlarging / reducing the pattern position calculation:
// paddingLeft coupled with respect to x multiplied by the scaling canvas n- X-left + = x * n-