Reputation: 463
I am developing a paint like application in metro style. I want to apply a eraser functionality. So how can I make such a tool for erasing the content from canvas like we do in MS paint ?
I don't want to clear whole canvas, wherever I click or drag the pointer, the path traveled by the pointer should be erased.
Upvotes: 0
Views: 789
Reputation: 720
The important thing to remember is that you're not "erasing." You're painting with small while pixels over the area that the mouse has traveled. There's 100 different ways to do this, but there isn't anything built-in to make this easy.
You're likely going to need to detect every pixel (or whatever unit of measure you choose) that the mouse (or finger) touches, and place a white Rectangle control over whatever else has already been drawn to the page.
This is mostly a game of managing a large collection of Rectangle objects, and changing their colors at the appropriate time. If you are trying to erase part of a larger Rectangle, you should rethink your approach.
Upvotes: 1