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>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM