From ac3258f3cc1f9dd64b5bc03ac375fb34f49272df Mon Sep 17 00:00:00 2001 From: Jon Lippincott Date: Wed, 6 Nov 2019 03:26:03 +0100 Subject: [PATCH] Remove deps on canvas, which we don't need or want --- lib/render.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/render.js b/lib/render.js index 8105064..e15359d 100644 --- a/lib/render.js +++ b/lib/render.js @@ -87,8 +87,8 @@ module.exports = function render (url, options, cb) { return cb(new Error('Baseline must be smaller than waveform height')) } - var canvas = new Canvas(options.width, options.height) - var canvasContext = canvas.getContext('2d') + //var canvas = new Canvas(options.width, options.height) + //var canvasContext = canvas.getContext('2d') var data = [] getPcmData(url, null, function (sample, channel) { @@ -105,10 +105,10 @@ module.exports = function render (url, options, cb) { var ratio = options.baseline / options.height var vals = [] - canvasContext.fillStyle = options.backgroundColor - canvasContext.fillRect(0, 0, options.width, options.height) + //canvasContext.fillStyle = options.backgroundColor + //canvasContext.fillRect(0, 0, options.width, options.height) - canvasContext.fillStyle = options.waveColor + //canvasContext.fillStyle = options.waveColor for (var i = 0; i < options.width; i += options.barWidth) { var position = i * step @@ -149,17 +149,17 @@ module.exports = function render (url, options, cb) { } if (options.waveAlpha < 1) { - canvasContext.clearRect(x, options.baseline, w, upperHeight) - canvasContext.clearRect(x, options.baseline, w, -lowerHeight) - canvasContext.globalAlpha = options.waveAlpha + //canvasContext.clearRect(x, options.baseline, w, upperHeight) + //canvasContext.clearRect(x, options.baseline, w, -lowerHeight) + //canvasContext.globalAlpha = options.waveAlpha } - canvasContext.fillRect(x, options.baseline, w, upperHeight) - canvasContext.fillRect(x, options.baseline, w, -lowerHeight) + //canvasContext.fillRect(x, options.baseline, w, upperHeight) + //canvasContext.fillRect(x, options.baseline, w, -lowerHeight) }) if (options.baselineWidth >= 1) { - canvasContext.fillStyle = options.baselineColor - canvasContext.fillRect(0, options.baseline - (options.baselineWidth / 2), options.width, options.baselineWidth) + //canvasContext.fillStyle = options.baselineColor + //canvasContext.fillRect(0, options.baseline - (options.baselineWidth / 2), options.width, options.baselineWidth) } cb(null, canvas.toBuffer())