Skip to content

Commit

Permalink
Make ms-animation smoother by avoiding non-moving particles
Browse files Browse the repository at this point in the history
  • Loading branch information
miickel committed Jan 17, 2020
1 parent db7b85b commit 7ba819c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/particle_clock_fx.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class ParticleClockFx extends ClockFx {
var secFrac = DateTime.now().millisecond / 1000;

var vecSpeed = duration.compareTo(easingDelayDuration) > 0
? Curves.easeInOutSine.transform(1 - secFrac)
? max(.2, Curves.easeInOutSine.transform(1 - secFrac))
: 1;

var vecSpeedInv = Curves.easeInSine.transform(secFrac);

// Used to avoid emitting all particles at once.
var maxSpawnPerTick = 5;
var maxSpawnPerTick = 10;

particles.asMap().forEach((i, p) {
// Movement
Expand Down Expand Up @@ -72,7 +72,7 @@ class ParticleClockFx extends ClockFx {

// Make some of the particles ease back, for a jelly effect.
if (p.distribution >= jellyDistributionLmt) {
var r = Rnd.getDouble(.1, .6) * vecSpeedInv * (1 - p.lifeLeft);
var r = Rnd.getDouble(.1, .9) * vecSpeedInv * (1 - p.lifeLeft);
p.x += p.vx * r;
p.y += p.vy * r;
}
Expand Down

0 comments on commit 7ba819c

Please sign in to comment.