0

I'm trying to make high-resolution graphics dynamically. Unfortunately when I make arcs they look really fuzzy.

Why so fuzzy?

Here's my code

- (void)drawRect:(CGRect)rect
{
    [super drawRect:rect];

    CGContextRef context = UIGraphicsGetCurrentContext();

    CGRect bounds = [self bounds];
    CGPoint center = CGPointMake(bounds.size.width / 2.0, bounds.size.height / 2.0);

    CGFloat lineWidth = 30.0;
    CGFloat innerRadius = (bounds.size.width / 2.0) - lineWidth;
    CGFloat outerRadius = innerRadius + lineWidth;
    CGFloat startAngle = -((float)M_PI / 2.0);
    CGFloat endAngle = ((self.percent / 100.0) * 2 * (float)M_PI) + startAngle;

    UIBezierPath *processBackgroundPath = [UIBezierPath bezierPath];
    processBackgroundPath.lineWidth = lineWidth;
    CGFloat radius = (self.bounds.size.width - lineWidth) / 2.0;
    CGFloat fullAngle = (2.0 * (float)M_PI) + startAngle;
    [processBackgroundPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:fullAngle clockwise:YES];
    [[UIColor whiteColor] set];
    [processBackgroundPath stroke];

    CGMutablePathRef progressPath = CGPathCreateMutable();
    CGPathMoveToPoint(progressPath, NULL, center.x, center.y - innerRadius);
    CGPathAddArc(progressPath, NULL, center.x, center.y, innerRadius, startAngle, endAngle, YES);
    CGPathAddArc(progressPath, NULL, center.x, center.y, outerRadius, endAngle, startAngle, NO);
    CGPathCloseSubpath(progressPath);

    UIColor *aColor = [UIColor colorWithRed:0.941 green:0.776 blue:0.216 alpha:1.0];
    [aColor setFill];
    CGContextAddPath(context, progressPath);
    CGContextFillPath(context);

    CGPathRelease(progressPath);
}

What do I need to do to make the donut more crisp?

Legen Diary
  • 365
  • 3
  • 17
  • Not 100% certain but try the answer to this... http://stackoverflow.com/questions/1136110/any-quick-and-dirty-anti-aliasing-techniques-for-a-rotated-uiimageview – Fogmeister May 30 '13 at 15:44
  • I don't get it. That thing looks good to me. What are you expecting it to look like? – David Rönnqvist May 30 '13 at 17:49
  • @Fogmeister tried it, but it didn't make things better – Legen Diary May 30 '13 at 18:57
  • @DavidRönnqvist if you look at it closely the edges are jagged. I understand that it is a result of low resolution. How do I increase the resolution so that it creates a cleaner look? – Legen Diary May 30 '13 at 19:01

0 Answers0