paint method
void
paint(
- Canvas canvas,
- Size size,
- WorldToScreen worldToScreen,
- ScreenToWorld screenToWorld,
- double scale,
override
Implementation
@override
void paint(
Canvas canvas,
Size size,
WorldToScreen worldToScreen,
ScreenToWorld screenToWorld,
double scale,
) {
final anchorPoint = worldToScreen(x, y);
final targetWidth = worldWidth * scale;
final targetHeight = targetWidth * image.height / image.width;
final leftPosition = anchorPoint.dx - targetWidth * (alignment.x + 1) / 2;
final topPosition = anchorPoint.dy - targetHeight * (alignment.y + 1) / 2;
final sourceRect = Rect.fromLTWH(
0,
0,
image.width.toDouble(),
image.height.toDouble(),
);
final destinationRect = Rect.fromLTWH(
leftPosition,
topPosition,
targetWidth,
targetHeight,
);
canvas.drawImageRect(
image,
sourceRect,
destinationRect,
Paint()..filterQuality = FilterQuality.medium,
);
}