Metode busur kanvas HTML ()
Contoh
Buat lingkaran:
JavaScript:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(100, 75, 50, 0, 2 * Math.PI);
ctx.stroke();
Dukungan Peramban
Angka-angka dalam tabel menentukan versi browser pertama yang sepenuhnya mendukung metode ini.
Method | |||||
---|---|---|---|---|---|
arc() | Yes | 9.0 | Yes | Yes | Yes |
Definisi dan Penggunaan
Metode arc() membuat busur/kurva (digunakan untuk membuat lingkaran, atau bagian dari lingkaran).
Tip: Untuk membuat lingkaran dengan arc(): Atur sudut awal ke 0 dan sudut akhir ke 2*Math.PI.
Tip: Gunakan metode stroke() atau fill() untuk benar-benar menggambar busur di kanvas.
Tengah
arc( 100,75 ,50,0*Math.PI,1.5*Math.PI)Mulai sudut
busur(100,75,50, 0,1,5 * Matematika.PI)Sudut akhir
arc(100,75,50,0*Math.PI, 1.5*Math.PI )
Sintaks JavaScript: | konteks .arc( x,y,r,sAngle,eAngle,berlawanan arah jarum jam ); |
---|
Nilai Parameter
Parameter | Description | Play it |
---|---|---|
x | The x-coordinate of the center of the circle | |
y | The y-coordinate of the center of the circle | |
r | The radius of the circle | |
sAngle | The starting angle, in radians (0 is at the 3 o'clock position of the arc's circle) | |
eAngle | The ending angle, in radians | |
counterclockwise | Optional. Specifies whether the drawing should be counterclockwise or clockwise. False is default, and indicates clockwise, while true indicates counter-clockwise. |
Referensi Kanvas HTML