Get your CodeRanch badge!*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Canvas and animation." Watch "Canvas and animation." New topic
Author

Canvas and animation.

pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 408

Hi,

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
SCJP - DuMmIeS mInD
Eric Pascarello
author
Rancher

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

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


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Canvas and animation.
 
Similar Threads
animation in java
how to move a string
Eclipse plugin development resources
MIDP Canvas problem!!!
Flickering of Canvas