标签:
在书上看到用<canvas>绘制图像就动手试试,刚开始,我的代码是这样的:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>canvas绘图</title>
</head>
<body>
<canvas id="drawimg" width="500" height="500" style="border:1px solid black;">A drawimg of something.</canvas>
<img id="image" src="01.jpg" style="display:none" />
<script>
var drawimg = document.getElementById("drawimg");
var image=document.getElementById("image");
var context = drawimg.getContext("2d");
context.drawImage(image,10,10);
</script>
</body>
</html>
<script>
window.onload=function(){
var drawimg = document.getElementById("drawimg");
var image=document.getElementById("image");
var context = drawimg.getContext("2d");
context.drawImage(image,10,10);
}
</script>
标签:
原文地址:http://www.cnblogs.com/bluey/p/4875716.html