I have an array called Contorno
CONTORNO = [{
tipo: "m",
x: [0, 0]
},
{
tipo: "l",
x: [0.06, 0],
x: [0.06, 0.04],
x: [0.14, 0.04],
x: [0.14, 0],
x: [0.24, 0],
x: [0.24, 0.04],
x: [0.34, 0.04],
x: [0.34, 0],
x: [0.44, 0],
x: [0.44, 0.04],
x: [0.54, 0.04],
x: [0.54, 0],
x: [0.64, 0],
x: [0.64, 0.04],
x: [0.74, 0.04],
x: [0.74, 0],
x: [0.8, 0],
x: [0.8, 1],
x: [0.40, 0.55],
x: [0, 1]
}
]
and then I call in the function caminho()
defined here:
function caminho(c, a) {
c.beginPath();
for (var i = 0; i < a.length; i++) {
if (a[i].tipo === "m") {
c.moveTo(a[i].x[0], a[i].x[1]);
}else if (a[i].tipo === "l") {
c.lineTo(a[i].x[0], a[i].x[1]);
}
}
}
the problem is when I call him
var c = document.getElementById("acanvas").getContext("2d");
caminho(c,CONTORNO);
It is not drawing all the points but just one, I mean it is not passing all points in for loop.
What is the problem?