javascript - Paperjs - 无法清除光栅
问题描述
我正在使用辅助函数绘制栅格,如下所示:
const icon = new Raster({
source: getBase64Icon(source,
position: new Point(x, y)
});
icon.scale(scale);
它确实有效,我在正确的位置以正确的比例获得了图标。问题是当我尝试使用该clear()
方法清除栅格时。我什至尝试icon.clear();
在缩放后显式添加,但它不起作用。没有错误,并且登录到控制台icon.clear
确实显示了功能代码。
也许重要的是要提到这些图标是在特定图层上绘制的。
谢谢您的帮助
解决方案
我认为您正在寻找item.remove()
将项目从场景图中取出并使其消失的方法。
这是演示解决方案的草图。
// Draw an image.
const raster = new Raster({
source: 'http://assets.paperjs.org/images/marilyn.jpg',
position: view.center
});
// Wait 4 seconds...
setTimeout(() => {
// ...then remove it.
raster.remove();
}, 4000);
推荐阅读
- android - 我的 Android 应用程序无法写入它在 android 重启后创建的文件
- node.js - nodejs环境下如何配置module.paths的内容
- .htaccess - 修改 .htaccess 以创建 301 重定向和 UNABLE_TO_VERIFY_LEAF_SIGNATURE 错误
- python - 可视化归并排序
- python - 删除反斜杠并保留标点符号
- java - 如何在 Windows 上通过文件关联运行 .sh 并从 Java 获取返回值
- android - Firebase firestore 空文档路径
- vb.net - 为什么我的组合框在被选中后不显示数据
- python - 如何将“男”或“女”改为“他”或“她”?
- java - 为什么不能在类外使用 lambda 表达式来实现函数式接口?