canvas画布--绘制圆形
绘制圆形,利用context的方法,进行圆和弧的绘制。
context.arc(x,y,radius,startingAngle,endingAngle,anticlockwise);
x,y:表示圆心坐标。
radius:圆的半径。
startingAngle:绘制圆弧的起始位置(弧度制,比如0,0.5*Math.PI.....)。
endingAngle:绘制圆弧的终止位置。
anticlockwise:false和true,true表示逆时针,false表示顺时针。不写默认false。
脚本
<script type="text/javascript">
var mycan = document.getElementById("mycan");
mycan.width = 600;
mycan.height = 500;
var ctx = mycan.getContext("2d");
ctx.lineWidth=10;
//开始绘制路径
ctx.beginPath();
ctx.arc(200,200,150,0,2*Math.PI,true);
//绘制图形颜色样式
ctx.fillStyle = "red";
//调用样式
ctx.fill();
//绘制边框样式
ctx.strokeStyle = "black";
//调用样式
ctx.stroke();
//绘制完成关闭路径
ctx.closePath();
</script>效果

吐槽一下


评论列表 :共有5人吐槽