Permalink
Browse files

improved the radial gradient radius code based on @marcosanson pull r…

…equest
  • Loading branch information...
1 parent 3415462 commit 963d03c5ec20d16f1ca68d03d44d2b914baba5e7 @kgn committed Oct 19, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 KGNoise.m
View
@@ -267,7 +267,7 @@ - (void)drawRect:(NSRect)dirtyRect{
CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, components, gradLocations, gradLocationsNum);
CGColorSpaceRelease(colorSpace), colorSpace = NULL;
CGPoint gradCenter= CGPointMake(round(CGRectGetMidX(bounds)), round(CGRectGetMidY(bounds)));
- CGFloat gradRadius = MIN(CGRectGetWidth(bounds), CGRectGetHeight(bounds));
+ CGFloat gradRadius = sqrt(pow((CGRectGetHeight(bounds)/2), 2) + pow((CGRectGetWidth(bounds)/2), 2));
CGContextDrawRadialGradient(context, gradient, gradCenter, 0, gradCenter, gradRadius, kCGGradientDrawsAfterEndLocation);
CGGradientRelease(gradient), gradient = NULL;
CGContextRestoreGState(context);

0 comments on commit 963d03c

Please sign in to comment.