(width, height)
| 555 | document.removeEventListener("keyup", this.keyHandlerBound, true) |
| 556 | } |
| 557 | setSize(width, height) { |
| 558 | width = parseInt(width) |
| 559 | height = parseInt(height) |
| 560 | |
| 561 | if (width == this.width && height == this.height) { |
| 562 | return |
| 563 | } |
| 564 | |
| 565 | let windowWidth = window.innerWidth |
| 566 | if (window.innerWidth > 700) { // keep in sync with main.css: @media screen and (max-width: 700px) {..} |
| 567 | // the tools are on the sides, so max size is smaller |
| 568 | let controlsLeft = this.popup.querySelector(".editor-controls-left") |
| 569 | let controlsRight = this.popup.querySelector(".editor-controls-right") |
| 570 | let controlsLeftWidth = parseInt(getComputedStyle(controlsLeft).width) |
| 571 | let controlsRightWidth = parseInt(getComputedStyle(controlsRight).width) |
| 572 | windowWidth = windowWidth - controlsLeftWidth - controlsRightWidth - 80 // extra padding |
| 573 | } |
| 574 | |
| 575 | var max_size = Math.min(parseInt(windowWidth * 0.9), width, 768) |
| 576 | this.containerScale = max_size / width |
| 577 | let containerWidth = (this.containerScale * width).toFixed() |
| 578 | let containerHeight = (this.containerScale * height).toFixed() |
| 579 | this.width = parseInt(width) |
| 580 | this.height = parseInt(height) |
| 581 | |
| 582 | this.container.style.width = containerWidth + "px" |
| 583 | this.container.style.height = containerHeight + "px" |
| 584 | |
| 585 | Object.values(this.layers).forEach((layer) => { |
| 586 | layer.canvas.width = width |
| 587 | layer.canvas.height = height |
| 588 | }) |
| 589 | |
| 590 | if (this.inpainter) { |
| 591 | this.saveImage() // We've reset the size of the image so inpainting is different |
| 592 | } |
| 593 | this.setBrush() |
| 594 | this.history.clear() |
| 595 | } |
| 596 | get tool() { |
| 597 | var tool_id = this.getOptionValue("tool") |
| 598 | return IMAGE_EDITOR_TOOLS.find((t) => t.id == tool_id) |
no test coverage detected