Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Thanks guys. So it turns out that the answer is a combination of your two answers (coob and Alex). Basically it seems like the CGDrawRadialGradient function only has aliasing at the starting circle, not the ending one. Since I want aliased "edges" on both, I first set the function to draw from the inside out which takes care of the first "edge", but produces the following:</p> <p><a href="http://www.expensivedna.com/pic2.png" rel="nofollow noreferrer">Step 1</a></p> <p>Then, I clip the image as suggested by coob and that gives a nice aliasing around the final edge of the bubble:</p> <p><a href="http://www.expensivedna.com/pic1.png" rel="nofollow noreferrer">Step 2</a></p> <p>Looks good enough for me!</p> <pre><code>- (void)drawInContext:(CGContextRef)theContext{ CGContextSetAllowsAntialiasing(theContext, true); CGContextSetShouldAntialias(theContext, true); size_t num_locations = 2; CGFloat locations[2] = { 0.0, 1.0 }; CGFloat components[8] = { 1.0, 1.0, 1.0, 0.0, // Start color 1.0, 1.0, 1.0, 0.5 }; // End color CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB(); CGGradientRef glossGradient = CGGradientCreateWithColorComponents(rgbColorspace, components, locations, num_locations); CGContextAddEllipseInRect(theContext, CGRectMake(5, 5, 40, 40)); CGContextClip(theContext); CGPoint topCenter = CGPointMake(25, 20); CGPoint midCenter = CGPointMake(25, 25); CGContextDrawRadialGradient(theContext, glossGradient, topCenter, 10, midCenter, 20, kCGGradientDrawsAfterEndLocation); </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload