在 EaselJS 中将矢量绘制到位图
我正在开发一个 EaselJS 程序,该程序不断绘制数千个向量。不用说,短时间后,性能就会下降。为了在 Flash 中解决这个问题,我会在矢量后面创建一个位图,并定期将矢量绘制到该位图上,并将它们从显示列表中删除。
我在 EaselJS 中执行此操作时遇到困难,即使看起来所有部分都已就位。如何创建一个空的 Bitmap() 并将 Container() 的内容绘制到其中?
I'm working on an EaselJS program that continually draws thousands of vectors. Needless to say, after a short amount of time, performance drops. To solve this in Flash, I would have created a Bitmap behind the vectors and periodically draw the vectors to that Bitmap and remove them from the display list.
I'm having trouble doing this in EaselJS, even though it seems like all the pieces are in place. How can I create an empty Bitmap() and draw the contents of my Container() to it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你可以将所有内容放入容器中并缓存它。
但是,请获取最新的未标记版本,因为当前版本存在错误并且无法正确缓存容器。
I think you can just put everything in a container and cache it.
However get the newest untagged build as the current release has a bug and doesn't cache container properly.
我还向向量添加了“snapToPixel = true”,因为我读到它应该在某些浏览器中有所帮助。因此,在上面的示例代码中,我将在进行缓存的最后一行之前添加以下行。
请查看缓存和对齐像素设置演示来了解一个活生生的例子。
在我设置的特定浏览器中,捕捉到像素实际上并不会改变性能,但在我阅读文档时,它似乎应该改变。
I've also been adding the 'snapToPixel = true' to vectors because I've read it is supposed to help in some browsers. So, in your example code above, I would add the following line right before the last line where you do your caching.
Check out this demo of cache and snap to pixel settings to see a live example.
In my particular browser set up, the snap to pixel does not actually change the performance, but in my reading of the docs it seems like it should.