add image faster (without canvas save+reload) if we have no rotation

This commit is contained in:
raphael 2020-06-02 18:11:52 +02:00
parent bbb55eb2b8
commit f102739d49
1 changed files with 9 additions and 6 deletions

View File

@ -987,12 +987,15 @@ const whiteboard = {
var img = document.createElement("img");
img.onload = function () {
rotationAngle = rotationAngle ? rotationAngle : 0;
_this.ctx.save();
_this.ctx.translate(left + width / 2, top + height / 2);
_this.ctx.rotate(rotationAngle);
_this.ctx.drawImage(img, -(width / 2), -(height / 2), width, height);
_this.ctx.restore();
//_this.ctx.drawImage(img, left, top, width, height);
if (rotationAngle === 0) {
_this.ctx.drawImage(img, left, top, width, height);
} else {
_this.ctx.save();
_this.ctx.translate(left + width / 2, top + height / 2);
_this.ctx.rotate(rotationAngle);
_this.ctx.drawImage(img, -(width / 2), -(height / 2), width, height);
_this.ctx.restore();
}
if (doneCallback) {
doneCallback();
}