有帮助?打赏吧!

createjs mask 填坑过程

 

 

createjs 的mask必须使用 shape  (不算坑)

作为遮罩的shape不能被 addChild  (上一次 自己居然躲过了,这次被巨坑)

 

 

var S=this;
var shape = new createjs.Shape();
shape.graphics.f("#FF0000").s().p("AkCKYQhcifgZkAQgyjvgEjaQgDg3gpgyQgSgGgQACQgQADgQAIIiUBBQgeAOg8gwQgng6ADgyQAvhOB1ANQAzAFBZAxQBlhdBHgxQAwgtA0gXQA1g2gDg1QAdgXAMAeIBjBhQAdAVAagWIBNhxQAiglAnAdQBNAkAtAlQB9BVBABSQBUAlAfgkQCWg7AUAKQAxAKALA4QAGAdhKBFQg8BLhBAAQhAAAh2hdQAFIZgRDuIgmBwQgzB9gcATQheBNi9AZQjagLhDhDg");
shape.setTransform(87.4,84.7);


var ld = new createjs.LoadQueue(false)
ld.addEventListener("fileload", loadedF);
ld.addEventListener("complete", loadComF);
function loadedF(e)
{
    if (e.item.type == "image")
    {
        var img = new createjs.Bitmap(e.result)
        img.scaleX=175/img.image.width;
        img.scaleY=175/img.image.height;
        img.x=img.y=0;

        S.addChild(img)
        img.mask=shape    

    };
}
function loadComF(e)
{
}
ld.loadFile("testImg.jpg")

 

posted @ 2016-07-28 18:30  luoeeyang  Views(1166)  Comments(0Edit  收藏  举报