位图缓存作为图像源

时间:2018-08-08 13:23:51

标签: easeljs

是否可以创建形状的位图缓存并将其用于beginBitmapFill

现在我有了代码:

var shape = new createjs.Shape();

shape.graphics.beginStroke('red').moveTo(0, 0).lineTo(150, 0).lineTo(150, 150).lineTo(0, 150).lineTo(0, 0).moveTo(0, 50).lineTo(150, 50).moveTo(0, 100).lineTo(150, 100).moveTo(50, 0).lineTo(50, 150).moveTo(100, 0).lineTo(100, 150);
shape.cache(0, 0, 150, 150);
//shape.graphics.clear();
//shape.graphics.beginBitmapFill(img); //, "repeat", matrix)
shape.graphics.beginBitmapFill(shape.cacheCanvas);

stage.addChild(shape);

1 个答案:

答案 0 :(得分:0)

我找到了解决方法:

                var shape = new createjs.Shape();
                shape.graphics.beginStroke('red').moveTo(0, 0).lineTo(150, 0).lineTo(150, 150).lineTo(0, 150).lineTo(0, 0).moveTo(0, 50).lineTo(150, 50).moveTo(0, 100).lineTo(150, 100).moveTo(50, 0).lineTo(50, 150).moveTo(100, 0).lineTo(100, 150);
                shape.cache(0, 0, 150, 150);
                shape.graphics.clear().beginBitmapFill(shape.cacheCanvas).drawRect(0, 0, 300, 300);
                shape.cache(0, 0, 300, 300);
                stage.addChild(shape);