function imgonLoad()...{ var w =this.width; var h =this.height; var i =this.i; //alert(w+'=='+h+'====='+i); if(125*h/w>130)...{ document.getElementById('pic'+i).height=130; document.getElementById('pic'+i).width=125*w/h; } } function imgLoad(index,path)...{ try...{ var imgT =new Image(); imgT.i=index; imgT.onload = imgonLoad; imgT.src = path; }catch(e)...{ } }
function draw() ...{ var ctx = document.getElementById('canvas').getContext('2d'); var img =new Image(); img.src ='images/rhino.jpg'; img.onload =function()...{ for (i=0;i<4;i++)...{ for (j=0;j<3;j++)...{ ctx.drawImage(img,j*50,i*38,50,38); } } } }