Metodo HTML canvas arc()
Esempio
Crea una cerchia:
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() | 4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
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.
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, 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. |
❮ Oggetto Tela