canvans画圆

来源:互联网 发布:细说php pdf 百度网盘 编辑:程序博客网 时间:2024/06/05 15:20
<script type="text/javascript">
window.onload=function(){
draw0("myCanvas");
drawScreen("canvan");
}
//实心圆
function draw0(id) {
            var canvas = document.getElementById(id);
            if (canvas == null) {
                return false;
            }
            var context = canvas.getContext('2d');
            context.beginPath();
            context.arc(100, 100, 100, 0, Math.PI * 2, true);
            //不关闭路径路径会一直保留下去,当然也可以利用这个特点做出意想不到的效果
            context.closePath();
            context.fillStyle = 'rgba(0,255,0,0.25)';
            context.fill();
        }
//空心圆
function drawScreen(id) {
alert("114111");
var can = document.getElementById(id);
    var ctx = can.getContext("2d");
    ctx.beginPath();
    ctx.arc(75,75,50,0,Math.PI*2,true); // 外圈
    ctx.moveTo(110,75);

    ctx.stroke();      //使用ctx.fill();就是填充色;
}
</script>
0 0
原创粉丝点击