Home  >  Q&A  >  body text

javascript - How to set the z-index of drawImage in canvas

For example, I want the first drawImage picture to be drawn above the second one. Is there any way?
(without changing the position order of the two lines of code)
ctx.drawImage(bg, 0 , 0, w, h);
ctx.drawImage(jp, 0, 0, boxWidth, boxHeight);


Currently covering the prize

过去多啦不再A梦过去多啦不再A梦2710 days ago1049

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-05-19 10:36:14

    The canvas has no structure, no hierarchy, only first come, first served, and the later ones cover the previous ones.
    If the hierarchical function is provided, it will only make the painting more confusing. .

    reply
    0
  • Cancelreply