简体   繁体   English

使用createJS时如何避免弄脏画布?

[英]How to avoid a tainted canvas when using createJS?

我看到三个地方表明我想要一个crossOrigin图像:对createjs.LoadQueue的第三个参数(文档中已弃用)使用true,设置loadItem.crossOrigin属性(分配“ Anonymous”或使用LoadItem.set({ .. crossOrigin:true ..}),以及LoadQueue getResult返回的图像的crossOrigin属性(始终看起来为null),我找不到设置的组合来避免画布变脏。

From my tests, CORS works fine. 根据我的测试,CORS可以正常工作。

Here is a quick sample using 0.6.2 from the CDN. 这是使用CDN中的0.6.2的快速示例。

var queue = new createjs.LoadQueue(false);
queue.on("complete", handleComplete);
queue.loadFile({src:"http://playpen.createjs.com/CORS/awesome.jpg", crossOrigin:true, id:"image"});
function handleComplete(event) {
    var img = queue.getResult("image");
    console.log(img.crossOrigin); // anonymous
}

You can see it working in this demo, where the image is added to a bitmap on stage, and then a click listener added: 您可以在此演示中看到它的运行,在演示中将图像添加到舞台上的位图,然后添加了单击侦听器:

http://jsfiddle.net/od727g2q/ http://jsfiddle.net/od727g2q/

Here is a variation using the (deprecated, but still functional) argument on LoadQueue constructor: http://jsfiddle.net/od727g2q/1/ 这是在LoadQueue构造函数上使用(不推荐使用,但仍可运行)参数的一种变体: http : //jsfiddle.net/od727g2q/1/

Just for sanity, here is a version using the latest NEXT in GitHub: http://jsfiddle.net/od727g2q/2/ 仅出于理智考虑,以下是使用GitHub中最新NEXT的版本: http : //jsfiddle.net/od727g2q/2/

Cheers. 干杯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM