我正在创建一个应用程序,我试图在其中获取当前触摸点的颜色,如果该点不是黑色,那么它将运行迭代/递归并将所有非黑色点存储在数组中。我正在使用这个函数进行迭代:
-(void)function:(CGFloat)positiveX:(CGFloat)positiveY:(CGFloat)negativeX:(CGFloat)negativeY
{
if (canDoPositiveX == YES)
{
//Checking in positive
if (![[NSString stringWithFormat:@"%@",[self colorOfPoint:CGPointMake(positiveX, positiveY)]] isEqualToString:@"UIDeviceRGBColorSpace 0 0 0 1"])
{
CGPoint point = CGPointMake(positiveX, positiveY);
[array addObject:[NSValue valueWithCGPoint:point]];
[self function:positiveX+1 :positiveY :negativeX :negativeY];
}
else
{
canDoPositiveX = NO;
}
}
if (canDoPositiveY == YES)
{
//Checking in positive
if (![[NSString stringWithFormat:@"%@",[self colorOfPoint:CGPointMake(positiveX, positiveY)]] isEqualToString:@"UIDeviceRGBColorSpace 0 0 0 0"])
{
CGPoint point = CGPointMake(positiveX, positiveY);
[array addObject:[NSValue valueWithCGPoint:point]];
[self function:positiveX :positiveY+1 :negativeX :negativeY];
}
else
{
canDoPositiveY = NO;
}
}
if (canDoNegativeX == YES)
{
//Checking in negative
if (![[NSString stringWithFormat:@"%@",[self colorOfPoint:CGPointMake(negativeX, negativeY)]] isEqualToString:@"UIDeviceRGBColorSpace 0 0 0 1"])
{
CGPoint point = CGPointMake(negativeX, negativeY);
[array addObject:[NSValue valueWithCGPoint:point]];
[self function:positiveX :positiveY :negativeX-1 :negativeY];
}
else
{
canDoNegativeX = NO;
}
}
if (canDoNegativeY == YES)
{
//Checking in negative
if (![[NSString stringWithFormat:@"%@",[self colorOfPoint:CGPointMake(negativeX, negativeY)]] isEqualToString:@"UIDeviceRGBColorSpace 0 0 0 1"])
{
negativeY -= 1;
CGPoint point = CGPointMake(negativeX, negativeY);
[array addObject:[NSValue valueWithCGPoint:point]];
[self function:positiveX :positiveY :negativeX :negativeY-1];
}
else
{
canDoNegativeY = NO;
}
}
NSLog(@"%u",[array count]);
}
现在,我正在更改数组中那些点的颜色,但它只为点的直线着色,而不是每个像素。任何帮助将不胜感激。谢谢!