beginPath lienzo HTML método ()
Ejemplos
Dibuje dos caminos en el lienzo; verde y morado:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.lineWidth="5";
ctx.strokeStyle="green"; // Green path
ctx.moveTo(0,75);
ctx.lineTo(250,75);
ctx.stroke(); // Draw it
ctx.beginPath();
ctx.strokeStyle="purple"; // Purple path
ctx.moveTo(50,0);
ctx.lineTo(150,130);
ctx.stroke(); // Draw it
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.lineWidth="5";
ctx.strokeStyle="green"; // Green path
ctx.moveTo(0,75);
ctx.lineTo(250,75);
ctx.stroke(); // Draw it
ctx.beginPath();
ctx.strokeStyle="purple"; // Purple path
ctx.moveTo(50,0);
ctx.lineTo(150,130);
ctx.stroke(); // Draw it
Trate »
Soporte para el navegador
Internet Explorer 9, el método de Firefox, Opera, Chrome y Safari beginPath apoyo ().
Nota: 8 y versiones anteriores de Internet Explorer no son compatibles con el elemento <canvas>.
Definición y Uso
beginPath método () para iniciar un camino, o se restablece la ruta actual.
Consejo: Utilice estos métodos para crear rutas moveTo (), lineTo (), quadricCurveTo (), bezierCurveTo (), arcto () y el arco ().
Consejo: Utilice el accidente cerebrovascular () método para dibujar la ruta exacta en el lienzo.
la sintaxis de JavaScript: | contexto .beginPath (); |
---|