Nouman Yasin
Nouman Yasin

Reputation: 11

Crop image in HTML5

I am using below given fiddle to apply zoom in and zoom out on my canvas image, but when i zoom out my image it shows multiple images slices. This problem does not show in fiddle possibly because its image background is white. If any one knows how to solve this problem kindly give an idea about it. Thanks

Upvotes: 1

Views: 294

Answers (2)

Mohsin Aghyaz
Mohsin Aghyaz

Reputation: 1

context.clearRect(0, 0, canvas.width, canvas.height);

Note that for clearRect you need to either have an untransformed context, or keep track of your actual boundaries.

Upvotes: 0

Emil S. Jørgensen
Emil S. Jørgensen

Reputation: 6366

It sounds like you forget to clear your canvas between each draw:

http://www.w3schools.com/tags/canvas_clearrect.asp

Upvotes: 1

Related Questions