From 1686265a994afe61518329e31343e19ed111c2af Mon Sep 17 00:00:00 2001 From: Jelmer van der Linde Date: Thu, 31 Aug 2017 18:07:23 +0200 Subject: [PATCH] Better random initialisation --- index.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 082d952..ccdbf6a 100644 --- a/index.html +++ b/index.html @@ -122,7 +122,6 @@ class Sequence { constructor(seq) { - this.offset = Math.random(); this.setSequence(seq); } @@ -139,6 +138,8 @@ }); this.duration = this.steps.reduce((sum, step) => sum + step[1], 0); + + this.offset = Math.random() * this.duration; } isValid() { @@ -149,7 +150,7 @@ if (isNaN(this.duration)) return undefined; - let dt = this.offset + time % this.duration; + let dt = (this.offset + time) % this.duration; for (let i = 0; i < this.steps.length; ++i) { if (dt < this.steps[i][1])