wmrisgood
wmrisgood

Reputation: 41

Having problem with npm package called "canvas"

Here is my code:

if(data.queryresult.pods[0]){
  ctx.fillText(data.queryresult.pods[0].title)
  var img = await loadImage(data.queryresult.pods[0].subpods[0].img.src)
  ctx.drawImage(img, 0, 0)
  let file = new MessageAttachment(canvas.toBuffer(), 'output.png')
  message.channel.send({
    files: [file]
  })
}

My problem is that ctx.fillText(data.queryresult.pods[0].title) does not write anything. How can I fix this?

Link to npm package: https://www.npmjs.com/package/canvas

Upvotes: 0

Views: 221

Answers (1)

Timothy
Timothy

Reputation: 50

As far as I understand, in the function ctx.fillText() you are supposed to pass three arguments (example from the page you attached):

ctx.fillText('Hello World', 50, 80)

Just like in ctx.drawImage()

Try adding those two arguments, it should start working.

Upvotes: 1

Related Questions