从拖动鼠标的画布上删除内容 [英] Erasing the content from canvas where mouse is being dragged

查看:81
本文介绍了从拖动鼠标的画布上删除内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发都市风格的类似油漆的应用程序.我想应用橡皮擦功能.那么,如何像在MS paint中一样,做一个这样的工具来从画布中擦除内容呢?

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.

推荐答案

要记住的重要一点是您没有在擦除".您在鼠标移动的区域上画了很少的像素.有100种不同的方法可以执行此操作,但是没有内置任何工具可以简化此操作.

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.

您可能需要检测鼠标(或手指)触摸的每个像素(或您选择的任何度量单位),并将白色Rectangle控件放置到页面上已经绘制的其他物体上.

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.

这主要是管理大量Rectangle对象并在适当的时间更改其颜色的游戏.如果您要擦除较大矩形的一部分,则应重新考虑您的方法.

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.

这篇关于从拖动鼠标的画布上删除内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆