mirror of
https://github.com/trebonian/visual6502.git
synced 2025-01-02 21:30:07 +00:00
All: fix zoomToBox to scale selection to fill 80% of the window
This commit is contained in:
parent
8e799d6922
commit
296cd01f84
16
wires.js
16
wires.js
@ -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]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user