Wednesday, 11 September 2013

lineTo() method in a for loop

lineTo() method in a for loop

I am trying to draw a grid using two for loops, one for drawing 10
vertical lines, and another for 10 horizontal ones. Like this:
for(var i=1;i<10;i++){
context.moveTo(0,i*b/10);
context.lineTo(a,i*b/10);
context.stroke();
}
So the lines drawn are different widthes, blurry..I read adding 0.5 in
both moveTo() and lineTo() methods but that does not work either. There is
no proportional way of achieving all 10 lines being the same. First, why
is so and what could I do?
Thanks.

No comments:

Post a Comment