HTML canvas arc() Metode

❮ HTML-doekverwysing

Voorbeeld

Skep 'n kring:

Jou blaaier ondersteun nie die HTML5-skerm nie.

JavaScript:

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(100, 75, 50, 0, 2 * Math.PI);
ctx.stroke();

Blaaierondersteuning

Die nommers in die tabel spesifiseer die eerste blaaierweergawe wat die metode ten volle ondersteun.

Method
arc() Yes 9.0 Yes Yes Yes

Definisie en gebruik

Die arc() metode skep 'n boog/kromme (gebruik om sirkels of dele van sirkels te skep).

Wenk: Om 'n sirkel met arc( te skep): Stel beginhoek op 0 en eindhoek na 2*Math.PI.

Wenk: Gebruik die stroke() of die fill() metode om werklik die boog op die doek te teken.

'n Boog

Sentrum
boog( 100,75 ,50,0*Math.PI,1.5*Math.PI)
Begin hoek
boog(100,75,50, 0 ,1.5*Math.PI)
Eindhoek
boog(100,75,50,0*Math.PI, 1.5*Math.PI )

JavaScript-sintaksis: konteks .arc( x,y,r,sAngle,eAngle,teenkloksgewys );

Parameterwaardes

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-doekverwysing