mannge
mannge

Reputation: 381

Strange Canvas dimension in Javascript (html 5/jquery)

I've just started to learn Canvas. But I've got a problem with my polygons.

My example/problem: http://jsfiddle.net/xCLX4/

I want with Javascript create/draw polygon/rectangles which can "replace" the CSS-rule. Later I want to transform those into another shape. (That's why I don't just use the CSS.)

But...I'm not there yet since the lines are not in the same dimension as the Canvas in some weird way.

Any kind of help would be really appreciated

Edit: See result at http://jsfiddle.net/xCLX4/3/

Upvotes: 2

Views: 80

Answers (1)

Prusse
Prusse

Reputation: 4315

With var $ctx = $( '<canvas />', {width:_width, height:_height } ); you set the style width and height but the canvas bitmap still have the default values (attr-canvas-width). Guess you really want to do something like:

var $ctx = $( '<canvas />');
$ctx[0].width = _width;
$ctx[0].height = _height;

Upvotes: 2

Related Questions