mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 10:38:17 +08:00
fix: doc/example/particles/readme, attempt to embed webm preview fix: doc/example/particles better sample for chaining refactor: Particle, dropped duration support
38 lines
803 B
Dart
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();
|
|
}
|
|
}
|