用画布画圆

<!DOCTYPE html>

<html>

<head lang="en">

    <meta charset="UTF-8">

    <title>圆</title>

</head>

<body>

<canvas id="cavsElem" width='400' height="300">

</canvas>

<script>

    var context = document.getElementById('cavsElem').getContext('2d');

    context.beginPath();//开始路径

    context.arc(100,100,100,0,2*Math.PI,true);

    context.closePath();//关闭路径

    context.fillStyle = 'green';//设置填充颜色

    context.fill();//填充

    context.beginPath();//开始路径

    context.strokeStyle = "#fff";//设置描边颜色

    context.lineWidth = 5;//设置线的粗细


    context.arc(100,150,25,Math.PI/6,5*Math.PI/6,false);

    context.stroke();

    context.beginPath();//开始路径

    context.strokeStyle = "#fff";//设置描边颜色

    context.lineWidth = 5;//设置线的粗细


    context.arc(50,60,25,  Math.PI/400, 5*Math.PI/1,  true);

    context.stroke();//描边

    context.beginPath();//开始路径

    context.strokeStyle = "#fff";//设置描边颜色

    context.lineWidth = 5;//设置线的粗细

    context.arc(150,60,25,  Math.PI/400, 5*Math.PI/1,  true);

    context.stroke();//描边



</script>

</body>

</html>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容