mxgraph 畫布


畫布自動擴大/縮小計算:

//得到所拖拽圖形相對於畫布的位置(-880,-100)
var x = Math.ceil(bounds.x / this.view.scale - this.view.translate.x);
var y = Math.ceil(bounds.y / this.view.scale - this.view.translate.y);
//根據縮放比例拿到長寬
var w = Math.floor(bounds.width / this.view.scale);
var h = Math.floor(bounds.height / this.view.scale);
		
//計算左上角相對於原始畫布大小的比例
var x0 = Math.floor(x / size.width);
var y0 = Math.floor(y / size.height);
//計算右下角相對於原始畫布大小的比例
var w0 = Math.ceil((x + w) / size.width) - x0;
var h0 = Math.ceil((y + h) / size.height) - y0;
//(-2,-1,3,2)
return new mxRectangle(x0, y0, w0, h0);  

  

放大/縮小后圖形位置計算:

//paddingLeft 加上相對於畫布的x乘以縮放的n
X = left + x*n 

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM