Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
Canvas is not loading multiple images from for loop

I have a array that stores path to images in javascript

var imagearray=[path1,path2,path3];

Now when I use html canvas to print all the images using for loop, it shows only one image.

  • I change coordinates after every iteration.
  • I am also using a different function to call draw image function.
  • also the path is correct as I am able to load one image successfully from the same directory.

Here is the code for the same:

function drawImages(src, x1, y1, width, height){

            var imageObj = new Image();
            
            
            imageObj.onload=function(){
                downloadcontext1.drawImage(imageObj, x1, y1, width, height);
    
            }
            imageObj.src = src;
             
        }
        

for(index in imagearray){
  drawImages(imagearray[index],x,0,100,100);
  x=x+120;
}

Can you please help me out if I am making any mistake in the above code.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!