• canvas画圆


    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    
    </head>
    <body>
      <canvas id="canvas" style="border:1px solid #ccc;display:block;">
        当前浏览器不支持canvas,请更换浏览器后在试。
      </canvas>
    
    <script>
      window.onload = function () {
        var canvas = document.getElementById('canvas');
        var context = canvas.getContext('2d');
    
        canvas.width = 1200;
        canvas.height = 800;
    
        context.lineWidth = 5;
        context.strokeStyle = 'black';
        for (var i = 0; i < 10; i++) {
          context.beginPath();
          context.arc(50 + i * 100, 60, 40, 0 , 0.2 * (i + 1) * Math.PI);
          // context.arc(圆心x轴坐标,圆心y轴坐标,半径,起始点,终点,[顺时针/逆时针,true为逆时针,默认为false]);
          context.closePath();
          context.stroke();
        };
    
        for (var i = 0; i < 10; i++) {
          context.beginPath();
          context.arc(50 + i * 100, 200, 40, 0 , 0.2 * (i + 1) * Math.PI);
          context.stroke();
        };
    
        for (var i = 0; i < 10; i++) {
          context.beginPath();
          context.arc(50 + i * 100, 400, 40, 0 , 0.2 * (i + 1) * Math.PI, true);
          context.closePath();
          context.stroke();
        };
    
        context.fillStyle = 'orange';
        for (var i = 0; i < 10; i++) {
          context.beginPath();
          context.arc(50 + i * 100, 600, 40, 0 , 0.2 * (i + 1) * Math.PI, true);
          context.stroke();
          context.fill();
        };
    
      }
    </script>
    </body>
    </html>
  • 相关阅读:
    String的几种初始化方法的区别
    Java编程思想之字符串
    树图 广度优先算法和深度优先算法
    bzoj1047: [HAOI2007]理想的正方形
    bzoj3124: [Sdoi2013]直径
    bzoj3930: [CQOI2015]选数
    bzoj1222: [HNOI2001]产品加工
    bzoj3578: GTY的人类基因组计划2
    bzoj4444: [Scoi2015]国旗计划
    bzoj1040: [ZJOI2008]骑士
  • 原文地址:https://www.cnblogs.com/lxcong/p/4844633.html
Copyright © 2020-2023  润新知