Metodo HTML canvas arc()

❮ Riferimento tela HTML

Esempio

Crea una cerchia:

Il tuo browser non supporta il canvastag HTML5.

JavaScript:

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

Supporto browser

I numeri nella tabella specificano la prima versione del browser che supporta completamente il metodo.

Method
arc() Yes 9.0 Yes Yes Yes

Definizione e utilizzo

Il metodo arc() crea un arco/curva (usato per creare cerchi o parti di cerchi).

Suggerimento: per creare un cerchio con arc(): impostare l'angolo iniziale su 0 e l'angolo finale su 2*Math.PI.

Suggerimento: usa il metodo stroke() o fill() per disegnare effettivamente l'arco sulla tela.

Un arco

Centro
arco( 100,75 ,50,0*Math.PI,1.5*Math.PI)
Angolo iniziale
arco(100,75,50, 0 ,1.5*Math.PI)
Angolo finale
arc(100,75,50,0*Math.PI, 1.5*Math.PI )

sintassi JavaScript: contesto .arc( x,y,r,sAngle,eAngle,in senso antiorario );

Valori dei parametri

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.

❮ Riferimento tela HTML