HTML canvas arc() Yöntem
Örnek
Bir daire oluşturun:
JavaScript:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(100, 75, 50, 0, 2 * Math.PI);
ctx.stroke();
Tarayıcı Desteği
Tablodaki sayılar, yöntemi tam olarak destekleyen ilk tarayıcı sürümünü belirtir.
Method | |||||
---|---|---|---|---|---|
arc() | 4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
Tanım ve Kullanım
arc() yöntemi bir yay/eğri oluşturur (daireler veya daire parçaları oluşturmak için kullanılır).
İpucu: arc() ile bir daire oluşturmak için: Başlangıç açısını 0'a ve bitiş açısını 2*Math.PI'ye ayarlayın.
İpucu: Yayı tuval üzerine gerçekten çizmek için vuruş () veya fill() yöntemini kullanın.
merkez
ark( 100, 75 , 50, 0 * Math.PI, 1.5 * Math.PI)Başlangıç açısı
ark(100, 75, 50, 0 , 1.5 * Math.PI)Bitiş açısı
ark(100, 75, 50, 0 * Math.PI, 1.5 * Math.PI )
JavaScript sözdizimi: | bağlam .arc( x, y, r, sAngle, eAngle, saat yönünün tersine ); |
---|
Parametre Değerleri
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. |
❮ Tuval Nesnesi