<!DOCTYPE HTML>
<html>
<title>Canvas直线</title>
<body>
<canvas id="myCanvas" width="200" height="200" style="border:#06F solid 2px">
您的浏览器不支持 Canvas
</canvas>
<script type="text/javascript">
var c = document.getElementById("myCanvas");
var cxt = c.getContext("2d");
cxt.beginPath();
cxt.moveTo(70,140);
cxt.lineTo(140,70);
cxt.stroke();
</script>
</body>
</html>
效果如下图:
【HTML5 Canvas 又很强的绘图能力,小弟初学,先从直线画起。第一篇文章,后台编辑器还不知怎么用,先这么着吧。】