简体   繁体   English

Html Canvas智能绘图

[英]Html Canvas Intelligent Drawing

I'm currently implementing a HTML canvas based webapp that features panning. 我目前正在实现一个基于HTML画布的webapp,它具有平移功能。 Is there a way to use an auxiliary buffer to hold the presently visible area so when I pan I don't have to redraw the whole canvas and only have to draw the newly visible areas? 有没有办法使用辅助缓冲区来保持当前可见的区域,所以当我平移时,我不需要重绘整个画布,只需绘制新的可见区域?

See my previous response to a related question: What is the fastest way to move a rectangular (pixel) region inside a HTML5 canvas element 请参阅我之前对相关问题的回答: 在HTML5画布元素中移动矩形(像素)区域的最快方法是什么

Just draw the entire canvas in a div that has overflow:hidden and implement panning as re-positioning the top and left of the canvas within that div. 只需在具有溢出的div中绘制整个画布:隐藏并实现平移,将画布的顶部和左侧重新定位在该div中。 It is much faster. 它要快得多。 And don't worry about drawing canvases tens of thousands of pixels wide/tall, I've successfully used this on very-very large and complex HTML and SVG elements. 并且不用担心绘制数万像素宽/高的画布,我已成功地在非常大且复杂的HTML和SVG元素上使用它。

Take a look at the pixel manipulation API. 看一下像素操作API。 http://dev.w3.org/html5/2dcontext/#pixel-manipulation http://dev.w3.org/html5/2dcontext/#pixel-manipulation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM