html5实现画图

发布时间:2020-06-15 08:35:43 作者:魔法猫
来源:网络 阅读:515

<!doctype html>
<html>
<head>
<script type="text/javascript">
    function init(){
        var ctx=document.getElementById('c').getContext('2d');
    //ctx.beginPath()和ctx.closePath()
        ctx.beginPath();
    //ctx.strokeStyle,ctx.fillStyle设置路线的颜色
        ctx.strokeStyle="rgb(200,0,0)";
  

 //画半圆

        ctx.arc(200,200,50,0,Math.PI,true);Math.PI代表半圆
        ctx.arc(200,200,50,0,Math.PI,false); 

    //画圆
    //ctx.arc(200,200,50,0,2*Math.PI,true);
    //ctx.arc(200,200,50,0,2*Math.PI,false);
    ctx.arc(200,200,50,.5*Math.PI,2.5*Math.PI,false);


        ctx.fillStyle="rgb(200,0,0)";
        ctx.closePath();
    //stroke()生成的是空心线条,fill()为填充
    //ctx.stroke();
        ctx.fill();
        ctx.strokeStyle="rgb(255,0,0)";
        ctx.lineWidth=5;
        ctx.stroke();
    }
</script>
</head>
<body>
<body onload='init();'>
<canvas id="c" width="400" height="300">
Your brower doesn't support the HTML5 element canvas.
</canvas>
</body>
</html>

推荐阅读:
  1. html5 canvas 画图时的bug
  2. Html5 画图

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

canvas html5 画图

上一篇:prometheus基本概念用法记录

下一篇:springBoot(9):web开发-CORS支持

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》