html5教程调用绘图api画简单的圆形代码分享

(编辑:jimmy 日期: 2024/11/11 浏览:2)


复制代码代码如下:
<!DOCTYPE html><head>
<meta charset=utf-8>
<title>HTML5画圆形</title>
<script src="/UploadFiles/2021-03-30/<a href="></head>
<script>
$(document).ready(function(){
var c=document.getElementById("drawbox");
var draw=c.getContext("2d"); //获取2d内容的引用,调用绘图API</p> <p>draw.fillStyle="red"; //颜色
draw.beginPath(); //从新画
draw.arc(50,50,50,0,Math.PI*2,true); //圆心x坐标|圆心y坐标|直径|始|PI为圆周率,Math.PI*2为画圆|true为时针方向:逆时针,0为顺时针,
draw.closePath(); //结束
draw.fill();
})
</script>
</body>
<canvas id="drawbox" width="500" height="500"></canvas>
</body>
</html>


效果图

html5教程调用绘图api画简单的圆形代码分享