From a1ff8ea98565cc83797a4721698ba78d59cd7dc4 Mon Sep 17 00:00:00 2001 From: agamemnus Date: Sun, 2 Jul 2017 14:38:44 -0400 Subject: [PATCH] Join ends of peaks (#1142) * Join ends of peaks I'm not entirely sure that the peaks are joined at the ends. When I zoomed all the way in, it seemed that there were gaps... * Update drawer.multicanvas.js * Update drawer.multicanvas.js --- src/drawer.multicanvas.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/drawer.multicanvas.js b/src/drawer.multicanvas.js index 0a0bb1de3..0b17403e3 100644 --- a/src/drawer.multicanvas.js +++ b/src/drawer.multicanvas.js @@ -247,14 +247,11 @@ WaveSurfer.util.extend(WaveSurfer.Drawer.MultiCanvas, { if (!ctx) { return; } var length = peaks.length / 2; + var scale = (this.params.fillParent && this.width != length) ? this.width / length : 1; - var scale = 1; - if (this.params.fillParent && this.width != length) { - scale = this.width / length; - } - - var first = Math.round(length * entry.start), - last = Math.round(length * entry.end); + var first = Math.round(length * entry.start); + // Use one more peak value to make sure we join peaks at ends -- unless, of course, this is the last canvas. + var last = Math.round(length * entry.end) + 1; if (first > end || last < start) { return; } var canvasStart = Math.max(first, start); var canvasEnd = Math.min(last, end);