CSS3-Canvas画布(图形-三角形)

<!DOCTYPE html5><html lang="en"><head>    <meta charset="UTF-8">    <title>CSS3-Canvas画布(图形-三角形)</title>    <script>        window.onload=function () {            var canvas=document.getElementById("canvas");//获取canvas对象            var ctx=canvas.getContext("2d"); //建立二维的绘图上下文对象            ctx.beginPath();            ctx.linewidth=20;            ctx.lineJoin="round"; //两条线交汇时的边角类型(miter 尖角默认  bevel斜角 round 圆角 )            ctx.moveTo(10,10);            ctx.lineTo(100,100);            ctx.lineTo(400,10);//          ctx.lineTo(10,10);            ctx.closePath(); //closePath() 关闭路径  闭合            ctx.strokeStyle="blue";// strokeStyle 只能填充该路径的颜色            ctx.fillStyle="red";// fillStyle 填充字体颜色、填充路径区域、图形区域            ctx.fill();// fill() 填充字体            ctx.stroke();        }    </script></head><body><h2>Canvas画布(图形)</h2><canvas id="canvas" width="500" height="500" style="border:1px solid red ">    浏览器不支持canvas</canvas></body></html>
相关文章
相关标签/搜索