Image Not Loading on Canvas

后端 未结 4 985
生来不讨喜
生来不讨喜 2021-01-19 07:30

My issue is that I am having problems loading locally hosted images on to the canvas. I have tried hosting the code on a web server, using XAMPP, and locally, and the LightB

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-19 08:07

    For me, putting the src after, makes things WORSE.. and here's the thing - in my case this is being updated every 25ms. Two needles first (not shown) then this little round cover over the needles.

    The needles work absolutely every time - the top appears when it sees fit.

      ctx.save();
      ctx.beginPath();
      ctx.translate(cX, cY);
      if (centre.complete) ctx.drawImage(centre, kn1, kn2, kn3, kn4); 
      else centre.onload = function () { ctx.drawImage(centre, kn1, kn2, kn3, kn4); } 
      ctx.restore();
    

提交回复
热议问题