ImageParticle constructor

ImageParticle({
  1. required Image image,
  2. Paint? paint,
  3. Vector2? size,
  4. double? lifespan,
})

Implementation

ImageParticle({
  required this.image,
  Paint? paint,
  Vector2? size,
  super.lifespan,
}) : paint = paint ?? Paint() {
  final srcWidth = image.width.toDouble();
  final srcHeight = image.height.toDouble();
  final destWidth = size?.x ?? srcWidth;
  final destHeight = size?.y ?? srcHeight;

  src = Rect.fromLTWH(0, 0, srcWidth, srcHeight);
  dest =
      Rect.fromLTWH(-destWidth / 2, -destHeight / 2, destWidth, destHeight);
}