Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

240
Visualizações
JavaScript: I'm trying to draw both text and image on a canvas in a loop, and then download it, but only the text shows in the canvas after download

I noticed that the image starts drawing to the canvas (onload image takes time) after the text has been drawn to the canvas (in a loop), how do I go about it, I want the text and image to be drawn, before running another.

(How I want it to be.)

(But how I get it.)

 Object.values(results).map(async listArray => {
      //clear to draw new data to the canvas
      ctx.clearRect(0, 0, canvas.width, canvas.height)
      ctx.drawImage(image, 0, 0, image.width, image.height)
      var im = []

      listArray.map(async data => {
        if (validBase64Image(data?.text)) {
          im = new Image()
          im.onload = () => ctx.drawImage(im, data?.x, data?.y, 100, 100)
          im.src = data.text
        }
        if (!validBase64Image(data?.text)) {
          ctx.fillText(data?.text, data?.x, data?.y)
        }
      })
      downLoadWithCsvTitle(canRef, listArray?.[0]?.text)// download canvas
    })
  }
     ```
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda