• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Canvas and animation.

 
pawan chopra
Ranch Hand
Posts: 417
jQuery Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Global variables will destroy you any time.

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


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic