renderSpriteByRadAngle function

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

Implementation

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