mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-25 23:03:15 +00:00
Fix problem with rotate-left bitmap operation
Spotted by @BurningTreeC - c0569849d2 (commitcomment-28211117)
This commit is contained in:
parent
1dc7647640
commit
f1b38c42f9
|
@ -194,8 +194,8 @@ EditBitmapWidget.prototype.changeCanvasSize = function(newWidth,newHeight) {
|
||||||
*/
|
*/
|
||||||
EditBitmapWidget.prototype.rotateCanvasLeft = function() {
|
EditBitmapWidget.prototype.rotateCanvasLeft = function() {
|
||||||
// Get the current size of the image
|
// Get the current size of the image
|
||||||
var origWidth = this.canvasDomNode.width,
|
var origWidth = this.currCanvas.width,
|
||||||
origHeight = this.canvasDomNode.height;
|
origHeight = this.currCanvas.height;
|
||||||
// Create and size a new canvas
|
// Create and size a new canvas
|
||||||
var newCanvas = this.document.createElement("canvas"),
|
var newCanvas = this.document.createElement("canvas"),
|
||||||
newWidth = origHeight,
|
newWidth = origHeight,
|
||||||
|
@ -203,9 +203,11 @@ EditBitmapWidget.prototype.rotateCanvasLeft = function() {
|
||||||
this.initCanvas(newCanvas,newWidth,newHeight);
|
this.initCanvas(newCanvas,newWidth,newHeight);
|
||||||
// Copy the old image
|
// Copy the old image
|
||||||
var ctx = newCanvas.getContext("2d");
|
var ctx = newCanvas.getContext("2d");
|
||||||
|
ctx.save();
|
||||||
ctx.translate(newWidth / 2,newHeight / 2);
|
ctx.translate(newWidth / 2,newHeight / 2);
|
||||||
ctx.rotate(-Math.PI / 2);
|
ctx.rotate(-Math.PI / 2);
|
||||||
ctx.drawImage(this.currCanvas,-origWidth / 2,-origHeight / 2);
|
ctx.drawImage(this.currCanvas,-origWidth / 2,-origHeight / 2);
|
||||||
|
ctx.restore();
|
||||||
// Set the new canvas as the current one
|
// Set the new canvas as the current one
|
||||||
this.currCanvas = newCanvas;
|
this.currCanvas = newCanvas;
|
||||||
// Set the size of the onscreen canvas
|
// Set the size of the onscreen canvas
|
||||||
|
|
Loading…
Reference in New Issue
Block a user