renderSpriteByRadAngle function

void renderSpriteByRadAngle(
  1. Canvas canvas,
  2. double radAngle,
  3. Rect position,
  4. Sprite sprite, {
  5. Paint? overridePaint,
})

Implementation

void renderSpriteByRadAngle(
  Canvas canvas,
  double radAngle,
  Rect position,
  Sprite sprite, {
  Paint? overridePaint,
}) {
  canvas.save();
  canvas.translate(position.center.dx, position.center.dy);
  canvas.rotate(radAngle == 0.0 ? 0.0 : radAngle + (pi / 2));
  canvas.translate(-position.center.dx, -position.center.dy);
  sprite.render(
    canvas,
    position: position.positionVector2,
    size: position.sizeVector2,
    overridePaint: overridePaint,
  );
  canvas.restore();
}