今天被坑了一个早上。
用下面这种不行,
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.style.width = "100";
canvas.style.height = "100";
用这种也不行
canvas.setAttributeNS(null,"width","100");
上面的两种都有问题,出来的图片都是变形的。
唯独这样是行的,
canvas.width= 100;
记下 ,以后不要再犯错了。