我正在使用辅助功能绘制栅格:
const icon = new Raster({
source: getBase64Icon(source,
position: new Point(x, y)
});
icon.scale(scale);
它确实起作用,并且我以正确的比例将图标放置在正确的位置。问题是当我尝试使用clear()
方法清除栅格时。我什至尝试在缩放后显式添加icon.clear();
,但它不起作用。没有错误,登录到控制台icon.clear
确实显示了功能代码。
也许要提到这些图标是在特定图层上绘制的。
谢谢您的帮助
[我认为您正在寻找item.remove()
方法,该方法将项目从场景图中移走,从而使其消失。这是演示解决方案的sketch。
// 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);