javascript - how to add more than 1 picture into canvas -
hi i'n new programming , tried out html5 , wondering, how add more 1 picture canvas. tried making 2 canvas on top of each other, not work. after tried not use canvas put images right beside each other. thought putting code putting image canvas 2 times not seem work
<!doctype html> <html> <body> <img src="mancala-game_bg_combined3.png" id=base usemap="canvas" img style="display:none"> <img src="mancala-game_marble.png" id=pit1marble1 img style="display:none"> <img src="mancala-game_marble.png" id=pit1marble2 img style="display:none"> <img src="mancala-game_marble.png" id=pit1marble3 img style="display:none"> <img src="mancala-game_marble.png" id=pit1marble4 img style="display:none"> <img src="mancala-game_marble.png" id=pit1marble5 img style="display:none"> <img src="mancala-game_marble.png" id=pit1marble6 img style="display:none"> <img src="mancala-game_marble.png" id=pit2marble1 img style="display:none"> <img src="mancala-game_marble.png" id=pit2marble2 img style="display:none"> <canvas id=canvasbackground width="1024" height="479" style="border:3px solid #d3d3d3;" > </canvas> <script type="text/javascript"> window.onload = function(){ var c= document.getelementbyid('canvasbackground'); var ctx = c.getcontext("2d"); var img = document.getelementbyid("base"); ctx.drawimage(img,0,0); var img = document.getelementbyid("pit1marble1"); ctx.drawimage(img,10,0); } </script> <canvas id=mycanvas width="1024" height="479" style="border:3px solid #d3d3d3;" > </canvas> <script type="text/javascript"> window.onload = function(){ var c= document.getelementbyid('mycanvas'); var ctx = c.getcontext("2d"); var img = document.getelementbyid("pit1marble1"); ctx.drawimage(img,0,0); } </script> <map name="canvas"> <area shape="rect" coords="172,50,269,176" href="sun.htm" alt="sun" id=pit1> <area shape="rect" coords="286,50,383,176" href="sun.htm" alt="sun" id=pit2> <area shape="rect" coords="400,50,497,176" href="sun.htm" alt="sun" id=pit3> <area shape="rect" coords="528,50,625,176" href="sun.htm" alt="sun" id=pit4> <area shape="rect" coords="651,50,748,176" href="sun.htm" alt="sun" id=pit5> <area shape="rect" coords="757,50,864,176" href="sun.htm" alt="sun" id=pit6> <area shape="rect" coords="172,58,269,166" href="sun.htm" alt="sun"> <area shape="rect" coords="286,58,383,166" href="sun.htm" alt="sun"> <area shape="rect" coords="400,58,497,166" href="sun.htm" alt="sun"> <area shape="rect" coords="528,58,625,166" href="sun.htm" alt="sun"> <area shape="rect" coords="651,58,748,166" href="sun.htm" alt="sun"> <area shape="rect" coords="757,58,864,166" href="sun.htm" alt="sun"> </map> </body> </html>
Comments
Post a Comment