Files
flame/lib/particles/rotating_particle.dart
Ivan Cherepanov 0f98a8542d chore: format
fix: doc/example/particles/readme, attempt to embed webm preview
fix: doc/example/particles better sample for chaining
refactor: Particle, dropped duration support
2019-11-28 23:02:28 +03:00

38 lines
803 B
Dart

import 'dart:math';
import 'dart:ui';
import 'package:flutter/foundation.dart';
import '../components/mixins/single_child_particle.dart';
import '../particle.dart';
import 'curved_particle.dart';
/// A particle which rotates its child over the lifespan
/// between two given bounds in radians
class RotatingParticle extends CurvedParticle with SingleChildParticle {
@override
Particle child;
final double from;
final double to;
RotatingParticle({
@required this.child,
this.from = 0,
this.to = 2 * pi,
double lifespan,
}) : super(
lifespan: lifespan,
);
double get angle => lerpDouble(from, to, progress);
@override
void render(Canvas canvas) {
canvas.save();
canvas.rotate(angle);
super.render(canvas);
canvas.restore();
}
}