zoukankan      html  css  js  c++  java
  • 【一天一个canvas】填充一个圆形(六)

    圆形的用途很广,当然也包含了椭圆。

    <html>
        <head>
            <meta charset="UTF-8">
        </head>
        <style type="text/css">
            canvas{border:dashed 2px #CCC}
        </style>
        <script type="text/javascript">
            function $$(id){
                return document.getElementById(id);
            }
            function pageLoad(){
                var can = $$('can');
                var cans = can.getContext('2d');
                cans.beginPath();
                cans.arc(200,150,100,0,Math.PI*2,true);
                cans.closePath();
                cans.fillStyle = 'green';//本来这里最初使用的是red,截图一看,傻眼了,怕上街被爱国者打啊,其实你懂的~~
                cans.fill();
            }
        </script>
        <body onload="pageLoad();">
            <canvas id="can" width="400px" height="300px">4</canvas>
        </body>
    </html>

    这里的arc方法的用法是 arc(X,Y,Radius,startAngle,endAngle,anticlockwise),意思是(圆心X坐标,圆心Y坐标,半径,开始角度(弧度),结束角度弧度,是否按照顺时针画);

    arc中各参数比较:

    a、cans.arc(200,150,100,0,Math.PI,true);
    
    
    c、cans.arc(200,150,100,0,Math.PI/2,true);

    c、cans.arc(200,150,100,0,Math.PI/2,true);

    d、cans.arc(200,150,100,0,Math.PI/2,false);

  • 相关阅读:
    python3 装饰器
    Python3 迭代器与生成器
    Python3 循环
    Python3 条件控制
    Python3 字典
    Python3 元组
    Python3 列表
    08.HttpUrlconnection方式调用
    南海区行政审批管理系统接口规范v0.3(规划)
    day63-webservice 11.cxf整合spring
  • 原文地址:https://www.cnblogs.com/babysay123/p/4629684.html
Copyright © 2011-2022 走看看