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);
解决方案
i found solution:
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);
推荐阅读
- spring-boot - 分别在每个 maven 模块的 ApplicationContext 中运行的中央 SpringBootTest
- django - 如何在我的 django forloop 中使用 if 和 else
- git - 如何删除以前的 git 提交?
- python - 变量 __cached__ 是做什么用的?
- django - Django没有记录任何低于警告的级别
- operating-system - 是否可以从主机访问虚拟机内存而不对虚拟机中的任何进程可见?
- c++ - 如何比较两个对象?
- python - 使用 random.sample,我如何让它打印相邻的字母
- npm - 在 package.json 中执行 bash 脚本
- amazon-web-services - 当查询超时值较高时,AWS 海王星抛出超时错误