computeTransformation method
Computes the transformation parameters for rendering particles using this shape.
see Canvas.drawAtlas
Implementation
@override
(Image, Rect, RSTransform, Color) computeTransformation(
Particle particle, Image defaultShapes) {
const rect = Rect.fromLTWH(
0,
0,
Shape.defaultSpriteWidth,
Shape.defaultSpriteHeight,
);
final transform = RSTransform.fromComponents(
rotation: 0,
scale: min(
particle.size.width / Shape.defaultSpriteWidth,
particle.size.height / Shape.defaultSpriteHeight,
),
anchorX: Shape.defaultSpriteWidth / 2,
anchorY: Shape.defaultSpriteHeight / 2,
translateX: particle.position.dx,
translateY: particle.position.dy,
);
final color = particle.color;
return (defaultShapes, rect, transform, color);
}