您的位置:首页 > Web前端 > HTML5

Html5 舞动的雨伞

2015-01-04 09:00 204 查看
原文:Html5 舞动的雨伞HMTL5的学习断断续续,方法不用又生疏了,昨天做的一个雨伞的Demo,先看看效果

function drawTop(ctx,fillStyle) {
ctx.fillStyle = fillStyle;
ctx.beginPath();
ctx.arc(0, 0, 30, 0, Math.PI, true);
ctx.closePath();
ctx.fill();
}

function drawGrip(ctx) {
ctx.save();
ctx.fillStyle = "blue";
ctx.fillRect(-1.5, 0, 1.5, 40);
ctx.beginPath();
ctx.strokeStyle = "blue";
ctx.arc(-5, 40, 4, Math.PI, Math.PI * 2, true);
ctx.stroke();
ctx.closePath();
ctx.restore();
}

function draw() {
var ctx = document.getElementById("myCanve").getContext("2d");
ctx.translate(150, 150);
for (var i = 0; i < 10; i++) {
ctx.save();
ctx.rotate(Math.PI * (2 / 4 + i / 4));
ctx.translate(0, -100);
//ctx.translate(70 * i, 0);
drawTop(ctx, "rgb(" + (30 * i) + "," + (255 - 30 * i) + ",255)");
drawGrip(ctx);
ctx.restore();
}
}

window.onload=function() {
draw();
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: