iOS-不会自行覆盖的画笔 [英] iOS - Brush that doesn't overlay itself

查看:136
本文介绍了iOS-不会自行覆盖的画笔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Photoshop中用画笔绘制时,它不会重叠,直到释放鼠标按钮并再次按下。

When you draw by a brush in Photoshop it doesn't overlap itself until you release mouse button and press it again.

我发现了这些图像,这让我更好地解释自己。
现在我的绘图以正确的方式工作,但我希望它们像左图那样工作。

I found these images, that let me explain myself better. Now my drawing works the right way, but i want them to work like the left one.

如果甚至有可能我希望即使用户松开手指并再次开始绘制后也不会覆盖自身,但是我将使用基本的类似于Photoshop的笔刷。

If it's even possible I wish It wouldn't overlay itself even after user releases finger and start drawing again, but I'll go with basic photoshop-like brush.

我猜在某种程度上,创建永不重叠的画笔与创建橡皮擦很相似,但是我可能错了。

I guess creating brush that never overlap itself is simmilar with creating an eraser, in some way, but i maybe wrong.

我需要swift / obj-c中的代码示例。

I need code examples in swift/obj-c.

推荐答案

实现此目的的主要思想是跟踪手指画的CGPath,并在每次更改时重新绘制整个图片。

The main idea to achieve this is to track a CGPath for a finger painting and redraw the whole picture every time it changes.

因此,您创建了CGPath并将其存储在内存中。然后,当用户绘制某些内容时,可以将此路径添加到现有路径中,然后重新绘制路径的整个新组合。这样一来,画笔就始终具有恒定的不透明度并可以自身覆盖。

So you create a CGPath and store it in memory. Then when user draws something you add this path to existing one and redraw the whole new combination of paths. This allows brush to always have constant opacity and overlay itself.

这篇关于iOS-不会自行覆盖的画笔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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