feat: docs, adde particles docs

fix: doc/examples/particles, added web to .gitignore
feat: doc/examples/particles, added more examples,
refactor: Particle does not extend Component
refactor: Particle subclasses in separate folder
refactor: ParticleComponent is now simple container
fix: SingleChildParticle, asserts for child existing
feat: AnimationParticle for Flame Animation
feat: ComponentParticle for Flame Component
feat: SpriteParticle for Flame Sprite
This commit is contained in:
Ivan Cherepanov
2019-11-28 18:01:31 +03:00
parent ce0b99ecbd
commit ff425afa26
26 changed files with 1828 additions and 165 deletions

View File

@ -0,0 +1,43 @@
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 renders its child with certain [Paint]
/// Could be used for applying composite effects.
/// Be aware that any composite operation is relatively expensive, as involves
/// copying portions of GPU memory. The less pixels copied - the faster it'll be.
class PaintParticle extends CurvedParticle with SingleChildParticle {
@override
Particle child;
final Paint paint;
/// Defines Canvas layer bounds
/// for applying this particle composite effect.
/// Any child content outside this bounds will be clipped.
final Rect bounds;
PaintParticle({
@required this.child,
@required this.paint,
// Reasonably large rect for most particles
this.bounds = const Rect.fromLTRB(-50, -50, 50, 50),
double lifespan,
Duration duration,
}) : super(
lifespan: lifespan,
duration: duration,
);
@override
void render(Canvas canvas) {
canvas.saveLayer(bounds, paint);
super.render(canvas);
canvas.restore();
}
}