首页 > 其他 > 详细

大神帮忙找错。。

时间:2015-06-02 17:38:36      阅读:234      评论:0      收藏:0      [点我收藏+]

 

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<h2>lineTo示例</h2>
<canvas id="mc" width="400" height="380" style="border:1px solid black"></canvas>
<script type="text/javascript">
function createStar(context, n, dx, dy, size)
{
context.beginPath();
var dig = Math.PI / n * 4;
for (var i = 0; i < n; i++)
{
var x = Math.sin(i * dig);
var y = Math.cos(i * dig);
context.lineTo(x.size + dx, y * size + dy);
}
context.closePath();
}
var canvas = document.getElementById(‘mc‘);
var ctx = canvas.getContext(‘2d‘);
createStar(ctx, 3, 60, 60, 50);
ctx.fillStyle = "#f0f";
ctx.fill();
createStar(ctx, 5, 160, 60, 50);
ctx.fillStyle = "#00f";
ctx.fill();
createStar(ctx, 7, 260, 60, 50);
ctx.fillStyle = "#f00";
ctx.fill();
createStar(ctx, 9, 360, 60, 50);
ctx.fillStyle = "#ff0";
ctx.fill();
</script>
</body>
</html>

和预料效果不一样啊

大神帮忙找错。。

原文:http://www.cnblogs.com/xiaotiange/p/4546855.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!