2

我需要在 Windows 中创建一个类似于 Paint 应用程序的应用程序。请查看此链接中的视频

https://dl.dropboxusercontent.com/u/56721867/Screen%20Recording.mov

这就是我需要我的应用程序工作的方式。我可以使用UIBezierPathCGContext类来绘制线条并填充颜色,但是如何通过在封闭区域内点击来填充封闭区域内的颜色,如视频所示。请让我知道方法以及 iOS 中的哪个类可以使这成为可能。谢谢!

4

3 回答 3

2

这个工具被称为洪水填充:

您可以从以下站点找到有关洪水填充的信息:
洪水填充
Lode 的计算机图形教程洪水填充

如果您想要访问的 Objective-C 示例:UIImageScanlineFloodfill

于 2013-07-22T13:17:35.717 回答
1

我们有UIBezierPath房产containsPoint:

将以下代码添加到- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

if ([aPath containsPoint:touchloc1]) {
//then set a flag value.
            }

并在- (void)drawRect:(CGRect)rect方法中添加以下代码

if (flag){
   [[UIColor redColor] setFill];
    [yourPath fill];
}
else{
//Whatever code requires for your drawing.
}

希望它的工作。

于 2013-05-06T04:56:53.657 回答
0

正如 CRDAve 提到的,此链接对我帮助很大。请访问https://github.com/Chintan-Dave/UIImageScanlineFloodfill

并在您的 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 中使用以下代码

if (Fill_clicked==1) {

    UIImage *image1 = [paintingView.image floodFillFromPoint:lastPoint withColor:newcolor andTolerance:tolorance];
    paintingView.image=image1;
}

lastpoint 来自上述方法。我将 tolorance 设置为 10。

于 2014-05-25T01:59:10.043 回答