html5 canvas“图形持久性”重新定位/调整大小时
我注意到,当您移动画布或调整画布大小时,里面的所有内容都会被擦除。我记得在 C# 的 Windows 窗体应用程序中也遇到过类似的问题。 不管怎样,即使在移动等之后,将图形保留在画布上的最佳方法是什么? (使用javascript)
我一直在使用canvas和websockets进行绘画,你可以在这里看到我的问题: http://students.info.uaic.ro/~tudor.berechet/(只需转到 Coboards,选择画笔工具,在画布上单击多次,然后调整窗口大小或放大窗口画布)
我注意到的另一件事是,在我的硬盘上运行该网站时,不会出现此问题。这让我想知道某个地方是否存在一些奇怪的错误。
我绝对需要一个持久的画布,因为我必须使用手动工具来移动它......
你怎么说?
I noticed that when you move a canvas around or when you resize it, everything inside gets erased. I remember having a similar problem in windows forms applications in C#.
Anyway, what's the best way to keep the graphics on canvas, even after it moves etc.? (using javascript)
I've been working on a paint using canvas and websockets, you can see my problem here: http://students.info.uaic.ro/~tudor.berechet/ (just go to Coboards, select the Brush tool, click a bunch of times on canvas and then resize the window or enlarge the canvas)
One more thing I noticed, running the site off my HDD, this problem doesn't occur. which makes me wonder if there's some strange error somewhere.
I definitely need a persistent canvas, because I'm gonna have to implement the hand tool to move it around...
What say you?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
稍微清理一下我的代码后,问题似乎就消失了。我仍然不知道是什么原因造成的,但即使在我移动/调整画布大小之后,画布绘图现在仍然保持不变。
请确认。 [编辑]已确认。
关键是,我最初认为画布图形不持久的假设似乎是错误的。很可能存在一些编码错误“擦除”了我的画布。
The problem seems to have gone after cleaning up my code a bit. I still don't know what was causing it, but it seems that the canvas drawings now remain intact even after I move/resize the canvas.
Please confirm. [EDIT] confirmed.
The point is, my original assumption that canvas graphics are not persistent seems to have been wrong. There was most likely some coding error that was "erasing" my canvas.