File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Canvas and animation. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Canvas and animation." Watch "Canvas and animation." New topic

Canvas and animation.

pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 415


I was trying to create a sample paint application using HTML 5 canvas. Then I added a button to redraw what user had drawn earlier. I am not sure what I am doing wrong or may be completely wrong. When I click redraw button multiple times it generates some magical animation by drawing lines all over. Even though if I log the starting point of drawing the image its same every time.

Here is the demo: Demo

Steps to reproduce:

Draw some circle or rectangle or something by clicking the mouse and dragging it on the rectangular box. Then click reset and redraw , click redraw couple of times after that and see the result.

I am not sure what I have done. I have not read a lot about Canvas. But I am curious to know what is going on here. Thanks.

Pawan Chopra
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
Global variables will destroy you any time.

What you need to do is say on the button click is

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Canvas and animation.
It's not a secret anymore!