Canvas画图的基本命令与操作
作者:互联网
最近接触了canvas,总结了下基本的命令,供大家参考!
首先如下,基本的代码,一个canvas标签。
<!doctype html> <html><head> <meta charset="utf-8"> <title>vanvas</title> <style> canvas{ border: 1px solid green; } </style> </head>
<body> <canvas height="1000" width="1000" id='canvas' ></canvas> </body>
</html>
<script>
var myCanvas = document.getElementById('canvas') var ctx = myCanvas.getContext('2d')
ctx.beginPath(); ctx.moveTo('100','100'); ctx.lineTo('200','100'); ctx.lineTo('200','200'); // ctx.lineTo('100','100');
ctx.closePath() ctx.strokeStyle='green' ctx.lineWidth='10'; ctx.stroke() // ctx.fill()
</script>
标签:200,Canvas,lineTo,ctx,画图,命令,myCanvas,canvas,100 来源: https://www.cnblogs.com/tzwbk/p/12614279.html