为什么fabric.js导出的尺寸与画布尺寸不同?

时间:2017-05-30 04:47:10

标签: javascript html5 canvas fabricjs

我有一张带有 canvas.toDataURL({ format: 'png' }) 的1500x1500画布。在检查员上,我可以看到1500x1500画布,还有750x750画布。

enter image description here

然后,当我跑:

setWidth()

返回的图像的分辨率为750x750。难道不是1500x1500的图片吗?我尝试通过缩放返回的图像来补偿它,但1500和750之间的比率会随着不同的设备而变化。

我错过了什么?如果在构造函数上设置画布的宽度和高度,或者在使用setHeight()// Will use the cors-anywhere proxy if jQuery supports it and crossDomain option is passed in. $.ajaxPrefilter( function (options) { if (options.crossDomain && jQuery.support.cors) { var http = (window.location.protocol === 'http:' ? 'http:' : 'https:'); options.url = http + '//cors-anywhere.herokuapp.com/' + options.url; // options.url = "http://cors.corsproxy.io/url=" + options.url; } }); // Use ajax requests as normal. $.ajax({ type: 'get', async: false, crossDomain: true, beforeSend: function(xhr){ xhr.setRequestHeader('Authorization', 'Basic encodedusername:passwordhere'); }, url: "https://api.pingdom.com/api/2.0/checks", success: function(Data) { console.log(Data); }, error: function(Data) { } }); 创建画布后,它没有区别。

0 个答案:

没有答案