Méthode HTML canvas moveTo()
Exemple
Commencez un chemin, déplacez-vous à la position 0, 0. Créez une ligne à la position 300, 150 :
JavaScript :
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(300, 150);
ctx.stroke();
Prise en charge du navigateur
Les nombres dans le tableau indiquent la première version du navigateur qui prend entièrement en charge la méthode.
Method | |||||
---|---|---|---|---|---|
moveTo() | 4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
Définition et utilisation
La méthode moveTo() déplace le chemin vers le point spécifié dans le canevas, sans créer de ligne.
Astuce : Utilisez la méthode stroke() pour tracer le chemin sur le canevas.
Syntaxe JavaScript : | contexte .moveTo( x, y ); |
---|
Valeurs des paramètres
Parameter | Description | Play it |
---|---|---|
x | The x-coordinate of where to move the path to | |
y | The y-coordinate of where to move the path to |
❮ Objet de toile