使用路徑arc

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>使用路徑</title>
</head>
<body>
    <canvas id="ourCanvas" width="400" height="400" style="border:3px dashed #0094ff;" ></canvas>
<script>
    //arc(float x,float y,float radius,float startAngel,endAngel,booleancounterclockwise)counterclockwise逆時針
    //向Canvas的當前路徑添加一段弧。繪製以x、y爲圓心的,radius爲半徑,從startAngel角度開始,到endAngel角度結束的圓弧。startAngel和endAngel以弧度做爲單位。
    var canvas = document.getElementById("ourCanvas");
    var ctx = canvas.getContext("2d");
    //開始定義路徑
    ctx.beginPath();html

    //添加一段圓弧
    ctx.arc(166, 166, 90, 0,Math.PI*0.6, true);
  
    //關閉路徑
    ctx.closePath();canvas

    //設置填充顏色
    ctx.strokeStyle = "#f00";spa

    //設置填充寬度
    ctx.lineWidth = 10;xml

    //填充當前路徑
    ctx.stroke();htm


</script>
</body>
</html>blog

相關文章
相關標籤/搜索