绘制正多边形

作者: CGPointZero | 来源:发表于2017-03-17 10:56 被阅读62次
-(void)drawShapeWithCenterXpos:(CGFloat)x ypos:(CGFloat)y raduis:(CGFloat)raduis numberOfsides:(NSInteger)n context:(CGContextRef)ctx{

    CGContextMoveToPoint(ctx, x+raduis, y);
    for(inti=1;i<=n;i++){

         //计算顶点的位置
         CGPointp=CGPointMake(x+raduis*cos(2*M_PI*i/n), y+raduis*sin(2*M_PI*i/n));
         //连线
         CGContextAddLineToPoint(ctx, p.x, p.y);
    }
}

@end

相关文章

网友评论

    本文标题:绘制正多边形

    本文链接:https://www.haomeiwen.com/subject/ifcenttx.html