Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotating images #63

Open
aboodh95 opened this issue Oct 27, 2018 · 0 comments
Open

Rotating images #63

aboodh95 opened this issue Oct 27, 2018 · 0 comments

Comments

@aboodh95
Copy link

Hi,

is there a way that we can have rotating feature in the tool, I spend too much time on it, but I'm facing an issue with the drawing context, the points are moving, and I tried everything got in my mind to find a way to change the point (fromx, fromy, tox, toy) after doing the rotation,
` rotateCanvas: function () {
var self = this;
if (self.$textbox.is(':visible')) {
self.pushText();
}

  var baseCanvas = self.baseCanvas;
  var baseContext = self.baseContext;
  self.degree += 90;
  if (self.degree == 90 || self.degree == 270) {
    baseCanvas.width = self.img.height;
    baseCanvas.height = self.img.width;
  } else {
    baseCanvas.width = self.img.width;
    baseCanvas.height = self.img.height;
  }
  baseContext.clearRect(0, 0, baseCanvas.width, baseCanvas.height);
 var  NewX = 0;
  var NewY = 0;
  if (self.degree == 90 || self.degree == 270) {
    baseContext.translate(self.img.height / 2, self.img.width / 2);
  } else {
    baseContext.translate(self.img.width / 2, self.img.height / 2);
  }
  baseContext.rotate(self.degree * Math.PI / 180);
  baseContext.drawImage(self.img, -self.img.width / 2, -self.img.height / 2);
  if (self.degree == 360) {
    self.degree = 0
  }
}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant