renderRotated method

void renderRotated(
  1. double angle,
  2. Vector2 rotationCenter,
  3. void fn(
    1. Canvas
    )
)

Utility method to render stuff rotated at specific angle.

It rotates the canvas around the center of rotation. The changes are reset after the fn is run.

Implementation

void renderRotated(
  double angle,
  Vector2 rotationCenter,
  void Function(Canvas) fn,
) {
  save();
  translateVector(rotationCenter);
  rotate(angle);
  translateVector(-rotationCenter);
  fn(this);
  restore();
}