Reputation: 2103
In my Android Studio project, I rotate the canvas simply as following
canvas.rotate(angle, cx, cy);
with cx and cy the center of the screen (i.e. the pivot). But in Flutter, there's only a single rotate method:
canvas.rotate(double radians)
and as you can see, when I tested the pivot it uses by drawing some rectangles and rotating it
and it uses top-left as pivot point. Is there a way to instruct Flutter to use my own provided pivot point?
Upvotes: 2
Views: 2949
Reputation: 591
canvas.translate(cx, cy);
canvas.rotate(angle);
canvas.translate(-cx, -cy);
it's possible I have lines 1 and 3 reversed. Fixed.
Upvotes: 2