Skip to content

Commit

Permalink
Merge pull request #192 from crmtestresco/191-text-is-cut-off-when-en…
Browse files Browse the repository at this point in the history
…tered-on-zoomed-image

Fix cutting off part of text when adding text to zoomed image
  • Loading branch information
ivictbor authored Oct 19, 2023
2 parents d202116 + 08ff961 commit ace8b7b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions js/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,17 @@ export default class TextTool {
apply() {
const origBorder = this.input.style.border;
const scale = this.main.getScale();

this.input.style.border = 'none';
domtoimage.toPng(this.input, {
const domToImageConfig = {
style: {
'transform-origin': 'top left',
transform: `scale(${scale})`
},
width: this.input.clientWidth * scale,
height: this.input.clientHeight * scale,
})
width: this.input.clientWidth * (scale < 1 ? (1 / scale) : scale),
height: this.input.clientHeight * (scale < 1 ? (1 / scale) : scale),
};
domtoimage.toPng(this.input, domToImageConfig)
.then((dataUrl) => {
const img = new Image();
img.src = dataUrl;
Expand Down

0 comments on commit ace8b7b

Please sign in to comment.