1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Fix problem with rotate-left bitmap operation

Spotted by @BurningTreeC  - c0569849d2 (commitcomment-28211117)
This commit is contained in:
Jermolene 2018-03-22 10:46:57 +00:00
parent 1dc7647640
commit f1b38c42f9

View File

@ -194,8 +194,8 @@ EditBitmapWidget.prototype.changeCanvasSize = function(newWidth,newHeight) {
*/
EditBitmapWidget.prototype.rotateCanvasLeft = function() {
// Get the current size of the image
var origWidth = this.canvasDomNode.width,
origHeight = this.canvasDomNode.height;
var origWidth = this.currCanvas.width,
origHeight = this.currCanvas.height;
// Create and size a new canvas
var newCanvas = this.document.createElement("canvas"),
newWidth = origHeight,
@ -203,9 +203,11 @@ EditBitmapWidget.prototype.rotateCanvasLeft = function() {
this.initCanvas(newCanvas,newWidth,newHeight);
// Copy the old image
var ctx = newCanvas.getContext("2d");
ctx.save();
ctx.translate(newWidth / 2,newHeight / 2);
ctx.rotate(-Math.PI / 2);
ctx.drawImage(this.currCanvas,-origWidth / 2,-origHeight / 2);
ctx.restore();
// Set the new canvas as the current one
this.currCanvas = newCanvas;
// Set the size of the onscreen canvas