All: fix zoomToBox to scale selection to fill 80% of the window

This commit is contained in:
David Banks 2018-10-14 13:34:52 +01:00
parent 8e799d6922
commit 296cd01f84
1 changed files with 15 additions and 1 deletions

View File

@ -206,7 +206,21 @@ function zoomToBox(xmin,xmax,ymin,ymax){
var ymid=(ymin+ymax)/2;
var x=(xmid+grChipOffsetX)/grChipSize*600;
var y=600-(ymid-grChipOffsetY)/grChipSize*600;
var zoom=5; // pending a more careful calculation
// Zoom to fill 80% of the window with the selection
var fillfactor=0.80;
var dx=xmax-xmin;
var dy=ymax-ymin;
if (dx < 1) dx=1;
if (dy < 1) dy=1;
var zx=(800/600)*fillfactor*grChipSize/dx;
var zy=fillfactor*grChipSize/dy;
var zoom=Math.min(zx,zy);
if (zoom < 1) {
zoom = 1;
}
if (zoom > grMaxZoom) {
zoom = grMaxZoom;
}
moveHere([x,y,zoom]);
}