javascript - drawImage() breaks on resized Canvas -
javascript - drawImage() breaks on resized Canvas -
i'm @ wits end on one. trying simple base of operations case of drawing image html5 canvas. canvas much larger image , dynamically sized. going tile several different images, simple drawimage() calls, can't image appear in canvas. simplified code see below, , still, image displays lot larger should. below, seek on drawimage @ time, none work.
image = new image(); image.onload = function() { canvas = document.getelementbyid("bigdynamiccanvas"); context = canvas.getcontext('2d'); context.drawimage(image, 0, 0); //nope context.drawimage(image, 0, 0, image.width, image.height); //nope context.drawimage(image, 0, 0, image.width, image.height, 0, 0, image.width, image.height);//nope }; image.src = "some.png";
this in firefox 24.6.0 on centos
edit: can images draw right size if canvas same size image , not resize it. oddly, canvas resized long before of above called. then, drawing canvas seems have effect if i'm drawing on it's original size , resizing after, isn't order in program, @ least.
i think forgot set var
before variables, therefor references image
instance don't work
fiddle: http://jsfiddle.net/ebjl2/4/
html
<canvas id="bigdynamiccanvas" width="250" height="300" style="border:1px solid #d3d3d3;"></canvas>
js
var image = new image(); image.onload = function() { var canvas = document.getelementbyid("bigdynamiccanvas"); var context = canvas.getcontext('2d'); context.drawimage(image, 0, 0); //nope context.drawimage(image, 0, 0, image.width, image.height); //nope context.drawimage(image, 0, 0, image.width, image.height, 0, 0, image.width, image.height);//nope }; image.src = "http://www.w3schools.com/tags/img_the_scream.jpg";
javascript html5 canvas
Comments
Post a Comment