Frage

I'm trying draw canvas on a new one but not only to draw it, I also need to rotate it. The angle is not divisible by Math.PI / 2 and the new canvas is getting more and more blurry (after each rotation). When I changed the rotation to be just with angles which are divisible by Math.PI / 2 everything was alright.

Is there any solution to that problem?

Thank you in advance!

War es hilfreich?

Lösung

Because you're drawing an image onto a canvas each time., that image just so happens to be another canvas.

Since it has to approximate pixels because you're rotating, you're losing information each time.

If you need this to be exact then you can't do it the way you are. Instead of doing a bunch of stuff on Canvas A and then rotating Canvas B and drawing Canvas A atop, you need to instead:

  1. Remember all the drawing commands used on Canvas A Rotate Canvas B
  2. (Re)commit those drawing commands on the Canvas B that has had a rotation transformation.
  3. Remember in your stack of commands that rotation, so that when you do more things on Canvas B you'll be able to draw those perfectly as well to an eventual Canvas C.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top