I found this CanvasRenderingContext2D and i played around a little bit with it. I was able to scale and to rotate my Image using this context:
crop: function () {
var canvas = document.createElement("canvas");
var context = canvas.getContext("2d");
canvas.width = this.options.width / this.scale;
canvas.height = this.options.height / this.scale;
var currWidth = this.imgWidth * this.scale;
var currHeight = this.imgHeight * this.scale;
var correctX = (currWidth - this.imgWidth) / 2;
var correctY = (currHeight - this.imgHeight) / 2;
var sourceX = (this.posX - correctX) / this.scale;
var sourceY = (this.posY - correctY) / this.scale;
context.translate(sourceX, sourceY);
context.translate(this.imgWidth / 2, this.imgHeight / 2);
context.rotate(this.rotate * Math.PI / 180);
context.drawImage(this.imgFull, this.imgWidth / 2 * -1, this.imgHeight / 2 * -1);
this.options.modal.remove();
this.promise.resolve(canvas);
},
Unfortunately i could not find any function to flip the canvas vertically or horizontally. In code i thought i could do something like:
if(self.flipV) {
context.rotateY(180);
}
if(self.flipH) {
context.rotateX(180);
}
But i could not find any methods for rotating on the y- or x-axis. Is there any way i could perform my flip transformation here?