jameszhao00
jameszhao00

Reputation: 7301

Html Canvas Intelligent Drawing

I'm currently implementing a HTML canvas based webapp that features panning. 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?

Upvotes: 3

Views: 2052

Answers (2)

slebetman
slebetman

Reputation: 113906

See my previous response to a related question: What is the fastest way to move a rectangular (pixel) region inside a HTML5 canvas element

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. 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.

Upvotes: 5

swampsjohn
swampsjohn

Reputation: 7046

Take a look at the pixel manipulation API. http://dev.w3.org/html5/2dcontext/#pixel-manipulation

Upvotes: 1

Related Questions