html5 canvas "graphics persistence" on reposition/resize

1k views Asked by At

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?

1

There are 1 answers

2
Spectraljump On BEST ANSWER

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.