render method
void
render()
Implementation
void render(Canvas canvas, Vector2 position, double rotation, double scale, ScalingMode scalingMode, Vector2? size, Paint paint) {
size = size ?? this.size;
size = computeRenderSize(scalingMode, size);
final scaleX = trimSize.x / this.size.x;
final scaleY = trimSize.y / this.size.y;
final offsetX = trimOffset.x * (size.x / this.size.x) * scale;
final offsetY = trimOffset.y * (size.y / this.size.y) * scale;
canvas.save();
canvas.translate(position.x, position.y);
canvas.rotate(rotation);
canvas.translate(-size.x * scale / 2.0, -size.y * scale / 2.0);
canvas.drawImageRect(
image,
Rect.fromLTWH(this.position.x, this.position.y, this.trimSize.x, this.trimSize.y),
Rect.fromLTWH(offsetX, offsetY, scaleX * size.x * scale, scaleY * size.y * scale),
paint,
);
canvas.restore();
}