美文网首页
canvas画个笑脸

canvas画个笑脸

作者: 田帅奇 | 来源:发表于2018-11-02 11:30 被阅读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>
    

    相关文章

      网友评论

          本文标题:canvas画个笑脸

          本文链接:https://www.haomeiwen.com/subject/yobqxqtx.html