Skip to content Skip to sidebar Skip to footer

Grid Drawn Using A Element Looking Stretched

I'm trying to draw a grid on a element with the ultimate goal of making a Go board. For some reason the grid is looking stretched, with the lines being thicker than

Solution 1:

I've found the problem. I was setting the dimensions of the <canvas> using CSS, when you actually have to set the width and height attributes. This was causing it to be stretched/skewed.

var canvas = $('<canvas/>').attr({width: cw, height: ch}).appendTo('body');

http://jsfiddle.net/h2yJn/66/

alt text

Solution 2:

Please try it outside jsfiddle, maybe jsfiddle is applying some linear transformation.

Also please make sure that you add 0.5 everywhere to both x and y coordinates. Alternatively, you can apply translate(0.5, 0.5) to shift all coordinates by half a pixel.

Post a Comment for "Grid Drawn Using A Element Looking Stretched"