ImageParticle constructor

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

Implementation

ImageParticle({
  required this.image,
  Vector2? size,
  double? lifespan,
}) : super(lifespan: lifespan) {
  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);
}