javascript - Which jQuery method of creating a canvas of a certain size has the best performance? -


what i'd create 15 15 pixel sized canvas jquery , looking elegant way it.

i create canvas jquery this:

var canvasnode = $('<canvas />', {   style:'display:block',   width:15, });  // canvasnode[0].width=15; canvasnode[0].height=15; 

an oddity width:15 in has no effect while commented out line below i'd do. tried style:'display:block;width:15px;' while displays canvas @ 15px width canvas stays @ large default size being scaled that's not seek.

note sending in object width property set css width 15px (basically scaling canvas), canvas still created default number of pixels in width if no width attribute specified, 300 pixels.

just set width , height attributes:

$('<canvas />', {   style:'display:block' }).attr('width', 15).attr('height', 15); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -