@@ -371,8 +371,8 @@ function recalcLayerScale(canvasdict) {
371371 "F" : "frontcanvas" ,
372372 "B" : "backcanvas"
373373 } [ canvasdict . layer ] ;
374- var width = document . getElementById ( canvasdivid ) . clientWidth * 2 ;
375- var height = document . getElementById ( canvasdivid ) . clientHeight * 2 ;
374+ var width = document . getElementById ( canvasdivid ) . clientWidth * devicePixelRatio ;
375+ var height = document . getElementById ( canvasdivid ) . clientHeight * devicePixelRatio ;
376376 var bbox = applyRotation ( pcbdata . edges_bbox ) ;
377377 var scalefactor = 0.98 * Math . min (
378378 width / ( bbox . maxx - bbox . minx ) ,
@@ -393,8 +393,8 @@ function recalcLayerScale(canvasdict) {
393393 canvas = canvasdict [ c ] ;
394394 canvas . width = width ;
395395 canvas . height = height ;
396- canvas . style . width = ( width / 2 ) + "px" ;
397- canvas . style . height = ( height / 2 ) + "px" ;
396+ canvas . style . width = ( width / devicePixelRatio ) + "px" ;
397+ canvas . style . height = ( height / devicePixelRatio ) + "px" ;
398398 }
399399}
400400
@@ -447,11 +447,11 @@ function handleMouseClick(e, layerdict) {
447447 var y = e . offsetY ;
448448 var t = layerdict . transform ;
449449 if ( layerdict . layer == "B" ) {
450- x = ( 2 * x / t . zoom - t . panx + t . x ) / - t . s ;
450+ x = ( devicePixelRatio * x / t . zoom - t . panx + t . x ) / - t . s ;
451451 } else {
452- x = ( 2 * x / t . zoom - t . panx - t . x ) / t . s ;
452+ x = ( devicePixelRatio * x / t . zoom - t . panx - t . x ) / t . s ;
453453 }
454- y = ( 2 * y / t . zoom - t . y - t . pany ) / t . s ;
454+ y = ( devicePixelRatio * y / t . zoom - t . y - t . pany ) / t . s ;
455455 var v = rotateVector ( [ x , y ] , - boardRotation ) ;
456456 var modules = bboxScan ( layerdict . layer , v [ 0 ] , v [ 1 ] ) ;
457457 if ( modules . length > 0 ) {
@@ -491,8 +491,8 @@ function handleMouseMove(e, layerdict) {
491491 e . stopPropagation ( ) ;
492492 var dx = e . offsetX - layerdict . transform . mousestartx ;
493493 var dy = e . offsetY - layerdict . transform . mousestarty ;
494- layerdict . transform . panx += 2 * dx / layerdict . transform . zoom ;
495- layerdict . transform . pany += 2 * dy / layerdict . transform . zoom ;
494+ layerdict . transform . panx += devicePixelRatio * dx / layerdict . transform . zoom ;
495+ layerdict . transform . pany += devicePixelRatio * dy / layerdict . transform . zoom ;
496496 layerdict . transform . mousestartx = e . offsetX ;
497497 layerdict . transform . mousestarty = e . offsetY ;
498498 if ( redrawOnDrag ) {
@@ -520,8 +520,8 @@ function handleMouseWheel(e, layerdict) {
520520 }
521521 t . zoom *= m ;
522522 var zoomd = ( 1 - m ) / t . zoom ;
523- t . panx += 2 * e . offsetX * zoomd ;
524- t . pany += 2 * e . offsetY * zoomd ;
523+ t . panx += devicePixelRatio * e . offsetX * zoomd ;
524+ t . pany += devicePixelRatio * e . offsetY * zoomd ;
525525 redrawCanvas ( layerdict ) ;
526526}
527527
0 commit comments