canvas画个笑脸

2018-11-02  本文已影响0人  田帅奇

直接上代码

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <canvas id="canvas"></canvas>
  <script>
    var canvas = document.querySelector("canvas");
    if (canvas.getContext) {
      var ctx = canvas.getContext('2d');
      ctx.beginPath();
      ctx.arc(75,75,50,0,Math.PI*2,true); // 绘制
      ctx.moveTo(110,75);
      ctx.arc(75,75,35,0,Math.PI,false);
      ctx.moveTo(65,65);
      ctx.arc(60,65,5,0,Math.PI*2,true);
      ctx.moveTo(95,65);
      ctx.arc(90,65,5,0,Math.PI*2,true);
      ctx.stroke();
    }
  </script>
</body>
</html>
上一篇 下一篇

猜你喜欢

热点阅读