Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8966567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:03:05+00:00 2026-06-15T17:03:05+00:00

I have a simple draw image for my canvas but it won’t display on

  • 0

I have a simple draw image for my canvas but it won’t display on the first frame.

It’s driving me mad i dunno why it won’t do it!!

This is my script:

img = new Image();
img.src = 'images/0.png'; //preLoad the image


window.requestAnimFrame = (function(){
  return  window.requestAnimationFrame       || 
          window.webkitRequestAnimationFrame || 
          window.mozRequestAnimationFrame    || 
          window.oRequestAnimationFrame      || 
          window.msRequestAnimationFrame     || 
          function( callback,  element){
            window.setTimeout(callback, 1000 / 60);
          };
})(); //frames per second


function gameUpdate(){ 
    previous = 0;
    requestAnimFrame( gameUpdate ); 
    draw(); 
}

Then the draw() function has this:

//doesn't display on first fame
canvas['canvas1'].ctx.drawImage(img, 100, 150); 

//displays on first frame           
canvas['canvas1'].ctx.fillStyle = "rgba(255, 255, 255, 0.8)";
canvas['canvas1'].ctx.fillRect (30, 30, 55, 50);

FillRect works fine but not the drawImage for the first frame, any ideas why this might be ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:03:06+00:00Added an answer on June 15, 2026 at 5:03 pm

    I think you should start the animation loop by calling requestAnimFrame outside of your gameUpdate function

    requestAnimFrame(gameUpdate)
    

    You might also need to make sure the image is actually loaded

    var img = new Image();
    img.onload = function() {
        // do the draw image here
    }
    img.src = 'images/0.png'; //preLoad the image
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple application that allows the user to draw in the canvas
I am writing a simple digital image processing program. To do this I have
I have this frame animation where each frame is called at every 1/30s. Canvas
I have a simple iPhone application which uses OpenGL ES (v1) to draw a
I have a developed a application that allows users to draw simple images on
I did not knew that this simple thing would be slightly complicated. I have
Im sure this has got to be something simple that I am overlooking, but
This program will have an infinite canvas (ie as long as the user scrolls,
I currently have a simple color picker that loads in a color gradient image
I need to know how I can draw an image on a canvas element,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.