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() | Yes | 9.0 | Yes | Yes | Yes |
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*Matematik.PI,1.5*Matematik.PI)Başlangıç açısı
yay(100,75,50, 0 ,1.5*Math.PI)Bitiş açısı
yay(100,75,50,0*Matematik.PI, 1.5* Matematik.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. |
❮ HTML Kanvas Referansı