Fix canvas image ratio (don't stretch or squash)

This commit is contained in:
JC Brand 2013-03-03 20:30:07 +02:00
parent daa31794d7
commit 4b670228ff

View File

@ -597,8 +597,8 @@
var ctx = this.$el.find('canvas').get(0).getContext('2d');
var img = new Image(); // Create new Image object
img.onload = function(){
// execute drawImage statements here
ctx.drawImage(img,0,0, 35, 35)
var ratio = img.width/img.height;
ctx.drawImage(img,0,0, 35*ratio, 35)
}
img.src = img_src;