merryZhang

运行效果:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <canvas id="drawing" width="600" height="600">A drawing of someing!</canvas>
    <script type="text/javascript">
   var drawing = document.getElementById(\'drawing\');
        if(drawing.getContext) {
            //绘制太极图
            var context = drawing.getContext(\'2d\');
            context.fillStyle = \'Lavender\';
            context.fillRect(0, 0, 600, 400);
            //画外面的两个大半圆
            context.fillStyle = \'#000\';
            context.beginPath();
            context.arc(200, 200, 180, 0.5*Math.PI, 1.5*Math.PI, false);
            context.closePath();
            context.fill();
            context.fillStyle = \'#fff\';
            context.beginPath();
            context.arc(200, 200, 180, 1.5*Math.PI, 0.5*Math.PI, false);
            context.closePath();
            context.fill();
            //画里面的两个小半圆
            context.beginPath();
            context.arc(200, 110, 90, 0.5*Math.PI, 1.5*Math.PI, false);
            context.closePath();
            context.fill();
            context.fillStyle = \'#000\';
            context.beginPath();
            context.arc(200, 290, 90, 1.5*Math.PI, 0.5*Math.PI, false);
            context.closePath();
            context.fill();
            //画里面的两个小圆
            context.beginPath();
            context.arc(200, 110, 20, 0, 2*Math.PI, false);
            context.closePath();
            context.fill();
            context.fillStyle = \'#fff\';
            context.beginPath();
            context.arc(200, 290, 20, 0, 2*Math.PI, false);
            context.closePath();
            context.fill();
        }

    </script>
</body>
</html>

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
  • 2021-10-29
  • 2021-10-08
  • 2021-05-31
  • 2021-11-13
猜你喜欢
  • 2021-05-12
  • 2021-12-23
  • 2021-06-07
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案