(layerdict, width, height)
| 634 | } |
| 635 | |
| 636 | function recalcLayerScale(layerdict, width, height) { |
| 637 | var flip = (layerdict.layer === "B"); |
| 638 | var bbox = applyRotation(pcbdata.edges_bbox, flip); |
| 639 | var scalefactor = 0.98 * Math.min( |
| 640 | width / (bbox.maxx - bbox.minx), |
| 641 | height / (bbox.maxy - bbox.miny) |
| 642 | ); |
| 643 | if (scalefactor < 0.1) { |
| 644 | scalefactor = 1; |
| 645 | } |
| 646 | layerdict.transform.s = scalefactor; |
| 647 | if (flip) { |
| 648 | layerdict.transform.x = -((bbox.maxx + bbox.minx) * scalefactor + width) * 0.5; |
| 649 | } else { |
| 650 | layerdict.transform.x = -((bbox.maxx + bbox.minx) * scalefactor - width) * 0.5; |
| 651 | } |
| 652 | layerdict.transform.y = -((bbox.maxy + bbox.miny) * scalefactor - height) * 0.5; |
| 653 | for (var c of ["bg", "fab", "silk", "highlight"]) { |
| 654 | canvas = layerdict[c]; |
| 655 | canvas.width = width; |
| 656 | canvas.height = height; |
| 657 | canvas.style.width = (width / devicePixelRatio) + "px"; |
| 658 | canvas.style.height = (height / devicePixelRatio) + "px"; |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | function redrawCanvas(layerdict) { |
| 663 | prepareLayer(layerdict); |
no test coverage detected