Skip to content

Commit

Permalink
return array when using getImage() (#1027)
Browse files Browse the repository at this point in the history
* return array when using getImage()

* return one canvas image data if not multiple canvases

* Update drawer.multicanvas.js

* updated getImage()

* add comments fir getImage()

* updated comments
  • Loading branch information
entonbiba authored and mspae committed Mar 6, 2017
1 parent aa7f3c2 commit 17ecdcb
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/drawer.multicanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ WaveSurfer.util.extend(WaveSurfer.Drawer.MultiCanvas, {
}
},

addCanvas: function () {
addCanvas: function () {
var entry = {},
leftOffset = this.maxCanvasElementWidth * this.canvases.length;

Expand Down Expand Up @@ -330,13 +330,18 @@ WaveSurfer.util.extend(WaveSurfer.Drawer.MultiCanvas, {
this.style(this.progressWave, { width: pos + 'px' });
},

/**
* Combine all available canvasses together.
*
* @param {String} type - an optional value of a format type. Default is image/png.
* @param {Number} quality - an optional value between 0 and 1. Default is 0.92.
*
*/
getImage: function(type, quality) {
// combine all available canvasses together
var availableCanvas = '';
for (var i in this.canvases) {
var getEntry = this.canvases[i].wave.getContext('2d');
availableCanvas += getEntry.canvas.toDataURL(type, quality);
}
return availableCanvas;
var availableCanvas = [];
this.canvases.forEach(function (entry) {
availableCanvas.push(entry.wave.toDataURL(type, quality));
});
return availableCanvas.length > 1 ? availableCanvas : availableCanvas[0];
}
});

0 comments on commit 17ecdcb

Please sign in to comment.