码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2017-06-08 21:31:47      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:css3   字体   圆角   close   style   onload   head   net   element   

<!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>

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

标签:css3   字体   圆角   close   style   onload   head   net   element   

原文地址:http://www.cnblogs.com/YoogaChan/p/6964725.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!