gpt4 book ai didi

iphone - 如何将CGContextAddArc(CGContextRef)中的所有点存储到NSMUtableArray

转载 作者:行者123 更新时间:2023-12-03 18:47:59 28 4
gpt4 key购买 nike

如何将 CGContextAddArc 中的所有像素点存储到 NSMutableArray. 或 CGContextRef 到 NSMutable Array

static inline float radians(double degrees) 
{
return degrees * PI / 180;
}

- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect parentViewBounds = self.bounds;
CGFloat x = CGRectGetWidth(parentViewBounds)/2;
CGFloat y = CGRectGetHeight(parentViewBounds)/2;
UIColor *rbg=[UIColor redColor];
CGContextSetFillColor(context, CGColorGetComponents( [rbg CGColor]));
CGContextMoveToPoint(context, x, y);
CGContextAddArc(context, x, y,100,radians(35),radians(105),0);
CGContextClosePath(context);
CGContextFillPath(context);
// here I want to store All points Containing in the Arc to NSMutableArray


NSMutableArray *pointsArray=????
}

图片enter image description here

最佳答案

存储或者当你想在NSValue中的CGPoint数组中添加点时,

NSValue *point = [NSValue valueWithCGPoint:CGPointMake(your_X, your_Y)];
[pointsArray addObject:point];

现在在检索时,您将如何从数组中的 NSVaule stroe 读取 CGPoint,

NSValue *getPoint = [pointsArray objectAtIndex:i];
CGPoint thePoint = [getPoint CGPointValue];

thePoint 将是您的答案。

关于iphone - 如何将CGContextAddArc(CGContextRef)中的所有点存储到NSMUtableArray,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11445159/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com