html中javascript画圆

来源:互联网 发布:中国电信监控下载软件 编辑:程序博客网 时间:2024/06/02 03:10
<!DOCTYPE html>   <head>   <meta charset="UTF-8">  <title>canvas元素示例</title>  <script >function draw(id) {      var canvas = document.getElementById(id);      if (canvas == null)          return false;      var context = canvas.getContext('2d');      context.fillStyle = "#EEEEFF";      context.fillRect(0, 0, 400, 300);                 context.beginPath();          context.arc( 100, 100, 75, 0, Math.PI * 2, true);          context.closePath();          context.fillStyle = 'rgba(255, 0, 0, 0.25)';          context.fill();          }</script>  </head>  <body onLoad="draw('canvas');">     <h1>canvas中画圆形</h1>  <canvas id="canvas" width="400" height="300" />  </body>  </html>