Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)drawRect:(CGRect)rect
- {
- //// General Declarations
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
- CGContextRef context = UIGraphicsGetCurrentContext();
- //// Color Declarations
- UIColor* fillColor = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 1];
- UIColor* color = [UIColor colorWithRed: 0.919 green: 0.919 blue: 0.919 alpha: 1];
- CGFloat colorRGBA[4];
- [color getRed: &colorRGBA[0] green: &colorRGBA[1] blue: &colorRGBA[2] alpha: &colorRGBA[3]];
- UIColor* strokeColor = [UIColor colorWithRed: (colorRGBA[0] * 0.5 + 0.5) green: (colorRGBA[1] * 0.5 + 0.5) blue: (colorRGBA[2] * 0.5 + 0.5) alpha: (colorRGBA[3] * 0.5 + 0.5)];
- UIColor* playerSelected = [UIColor colorWithRed: 1 green: 0.41 blue: 0.114 alpha: 1];
- //// Gradient Declarations
- NSArray* gradientColors = [NSArray arrayWithObjects:
- (id)color.CGColor,
- (id)[UIColor colorWithRed: 0.959 green: 0.959 blue: 0.959 alpha: 1].CGColor,
- (id)fillColor.CGColor, nil];
- CGFloat gradientLocations[] = {0, 0.08, 1};
- CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)gradientColors, gradientLocations);
- //// Subframes
- CGRect group = self.bounds;
- //// Abstracted Attributes
- CGRect rectangleRect = CGRectMake(CGRectGetMinX(group) + floor(CGRectGetWidth(group) * 0.00595) + 0.5, CGRectGetMinY(group) + floor(CGRectGetHeight(group) * 0.00862) + 0.5, floor(CGRectGetWidth(group) * 0.99405) - floor(CGRectGetWidth(group) * 0.00595), floor(CGRectGetHeight(group) * 0.99138) - floor(CGRectGetHeight(group) * 0.00862));
- //// Group
- {
- //// Rectangle Drawing
- UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRect: rectangleRect];
- CGContextSaveGState(context);
- [rectanglePath addClip];
- CGContextDrawLinearGradient(context, gradient,
- CGPointMake(CGRectGetMidX(rectangleRect) + 6.28 * CGRectGetWidth(rectangleRect) / 83, CGRectGetMidY(rectangleRect) + -4.95 * CGRectGetHeight(rectangleRect) / 57),
- CGPointMake(CGRectGetMidX(rectangleRect) + 8.86 * CGRectGetWidth(rectangleRect) / 83, CGRectGetMidY(rectangleRect) + 78.16 * CGRectGetHeight(rectangleRect) / 57),
- kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
- CGContextRestoreGState(context);
- [strokeColor setStroke];
- rectanglePath.lineWidth = 0.5;
- CGFloat rectanglePattern[] = {1, 1, 1, 1};
- [rectanglePath setLineDash: rectanglePattern count: 4 phase: 0];
- [rectanglePath stroke];
- //// Icon Drawing
- UIBezierPath* iconPath = [UIBezierPath bezierPath];
- [iconPath moveToPoint: CGPointMake(CGRectGetMinX(group) + 0.54481 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.68629 * CGRectGetHeight(group))];
- [iconPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.31744 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.68629 * CGRectGetHeight(group))];
- [iconPath addCurveToPoint: CGPointMake(CGRectGetMinX(group) + 0.36583 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.59828 * CGRectGetHeight(group)) controlPoint1: CGPointMake(CGRectGetMinX(group) + 0.31744 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.63718 * CGRectGetHeight(group)) controlPoint2: CGPointMake(CGRectGetMinX(group) + 0.31340 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.61012 * CGRectGetHeight(group))];
- [iconPath addCurveToPoint: CGPointMake(CGRectGetMinX(group) + 0.44345 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.53242 * CGRectGetHeight(group)) controlPoint1: CGPointMake(CGRectGetMinX(group) + 0.41715 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.58669 * CGRectGetHeight(group)) controlPoint2: CGPointMake(CGRectGetMinX(group) + 0.46780 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.57633 * CGRectGetHeight(group))];
- [iconPath addCurveToPoint: CGPointMake(CGRectGetMinX(group) + 0.50037 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.32852 * CGRectGetHeight(group)) controlPoint1: CGPointMake(CGRectGetMinX(group) + 0.37129 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.40229 * CGRectGetHeight(group)) controlPoint2: CGPointMake(CGRectGetMinX(group) + 0.42288 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.32852 * CGRectGetHeight(group))];
- [iconPath addCurveToPoint: CGPointMake(CGRectGetMinX(group) + 0.55729 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.53242 * CGRectGetHeight(group)) controlPoint1: CGPointMake(CGRectGetMinX(group) + 0.57637 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.32852 * CGRectGetHeight(group)) controlPoint2: CGPointMake(CGRectGetMinX(group) + 0.63512 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.40191 * CGRectGetHeight(group))];
- [iconPath addCurveToPoint: CGPointMake(CGRectGetMinX(group) + 0.51816 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.62052 * CGRectGetHeight(group)) controlPoint1: CGPointMake(CGRectGetMinX(group) + 0.53839 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.56412 * CGRectGetHeight(group)) controlPoint2: CGPointMake(CGRectGetMinX(group) + 0.51816 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.59137 * CGRectGetHeight(group))];
- [iconPath addCurveToPoint: CGPointMake(CGRectGetMinX(group) + 0.54481 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.68629 * CGRectGetHeight(group)) controlPoint1: CGPointMake(CGRectGetMinX(group) + 0.51816 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.64594 * CGRectGetHeight(group)) controlPoint2: CGPointMake(CGRectGetMinX(group) + 0.52830 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.66908 * CGRectGetHeight(group))];
- [iconPath closePath];
- [iconPath moveToPoint: CGPointMake(CGRectGetMinX(group) + 0.68338 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.62052 * CGRectGetHeight(group))];
- [iconPath addCurveToPoint: CGPointMake(CGRectGetMinX(group) + 0.61632 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.68618 * CGRectGetHeight(group)) controlPoint1: CGPointMake(CGRectGetMinX(group) + 0.68338 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.65679 * CGRectGetHeight(group)) controlPoint2: CGPointMake(CGRectGetMinX(group) + 0.65335 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.68618 * CGRectGetHeight(group))];
- [iconPath addCurveToPoint: CGPointMake(CGRectGetMinX(group) + 0.54926 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.62052 * CGRectGetHeight(group)) controlPoint1: CGPointMake(CGRectGetMinX(group) + 0.57928 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.68618 * CGRectGetHeight(group)) controlPoint2: CGPointMake(CGRectGetMinX(group) + 0.54926 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.65679 * CGRectGetHeight(group))];
- [iconPath addCurveToPoint: CGPointMake(CGRectGetMinX(group) + 0.61632 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.55486 * CGRectGetHeight(group)) controlPoint1: CGPointMake(CGRectGetMinX(group) + 0.54926 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.58426 * CGRectGetHeight(group)) controlPoint2: CGPointMake(CGRectGetMinX(group) + 0.57928 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.55486 * CGRectGetHeight(group))];
- [iconPath addCurveToPoint: CGPointMake(CGRectGetMinX(group) + 0.68338 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.62052 * CGRectGetHeight(group)) controlPoint1: CGPointMake(CGRectGetMinX(group) + 0.65335 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.55486 * CGRectGetHeight(group)) controlPoint2: CGPointMake(CGRectGetMinX(group) + 0.68338 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.58426 * CGRectGetHeight(group))];
- [iconPath closePath];
- [iconPath moveToPoint: CGPointMake(CGRectGetMinX(group) + 0.65753 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.61050 * CGRectGetHeight(group))];
- [iconPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.62850 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.61050 * CGRectGetHeight(group))];
- [iconPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.62850 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.58208 * CGRectGetHeight(group))];
- [iconPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.60608 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.58208 * CGRectGetHeight(group))];
- [iconPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.60608 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.61050 * CGRectGetHeight(group))];
- [iconPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.57706 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.61050 * CGRectGetHeight(group))];
- [iconPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.57706 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.63245 * CGRectGetHeight(group))];
- [iconPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.60608 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.63245 * CGRectGetHeight(group))];
- [iconPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.60608 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.66087 * CGRectGetHeight(group))];
- [iconPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.62850 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.66087 * CGRectGetHeight(group))];
- [iconPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.62850 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.63245 * CGRectGetHeight(group))];
- [iconPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.65753 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.63245 * CGRectGetHeight(group))];
- [iconPath addLineToPoint: CGPointMake(CGRectGetMinX(group) + 0.65753 * CGRectGetWidth(group), CGRectGetMinY(group) + 0.61050 * CGRectGetHeight(group))];
- [iconPath closePath];
- iconPath.miterLimit = 4;
- [playerSelected setFill];
- [iconPath fill];
- }
- //// Cleanup
- CGGradientRelease(gradient);
- CGColorSpaceRelease(colorSpace);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement