HTML5 cavas画布加载图片

HTML5 cavas画布加载图片


<!DOCTYPE HTML>
<html>

<body>

<canvas id="myCanvas" width="500" height="500" style="border:1px solid #c3c3c3;">
Your browser does not support the canvas element.
</canvas>

<script type="text/javascript">

var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
var img=new Image()
img.src="/img/flower.png";
img.onload = function () //确保图片已经加载完毕
{
    cxt.drawImage(img,100,100);
}

</script>

</body>
</html>


你可能感兴趣的:(c,html5,function,image,border,browser)