canvas入门

    xiaoxiao2021-12-15  22

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> </head> <body> <canvas id="demo" width="600px" height="600px"> 你的浏览器不支持canvas,请升级浏览器 <!-- flash --> </canvas> <script> window.onload = function(){ var canvas = document.getElementById('demo'); var ctx = canvas.getContext("2d"); ctx.moveTo(100, 100);//画笔移动到100,100 ctx.lineTo(200, 100);//画直线到200,100 ctx.lineTo(100, 200); //ctx.lineTo(100, 100); ctx.closePath();//闭合路径 //设置线宽 ctx.lineWidth = 4; ctx.strokeStyle = 'rgba(233,233,233,.8)';//设置描边样式 ctx.stroke();//描边 ctx.fillStyle = "blue"; ctx.fill(); } </script> </body> </html>

    转载请注明原文地址: https://ju.6miu.com/read-1000259.html

    最新回复(0)