Skip to content

Commit

Permalink
Remove deps on canvas, which we don't need or want
Browse files Browse the repository at this point in the history
  • Loading branch information
drone1 committed Nov 6, 2019
1 parent 546ce03 commit ac3258f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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())

Expand Down

0 comments on commit ac3258f

Please sign in to comment.