Skip to content

Instantly share code, notes, and snippets.

@marcoarment
Created April 29, 2014 21:07
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcoarment/2542cd28cb5df0aa97d8 to your computer and use it in GitHub Desktop.
Save marcoarment/2542cd28cb5df0aa97d8 to your computer and use it in GitHub Desktop.
Source for the Accidental Tech Podcast (ATP) T-Shirt
// Source for the Accidental Tech Podcast (ATP) T-Shirt:
// http://www.marco.org/2014/04/29/atp-shirts
//
// By Marco Arment, April 28, 2014. MIT license.
@implementation ATPLogoView
- (void)drawRect:(CGRect)rectIgnored
{
NSString *fontName = @"MyriadPro-Semibold";
NSString *title = NSLocalizedString(@"Accidental Tech Podcast", NULL);
NSString *initials = NSLocalizedString(@"ATP", NULL);
CGRect rect = { CGPointZero, self.bounds.size };
CGFloat w = rect.size.width;
CGFloat offsetY = w * -0.07f;
CGRect ringRect = CGRectInset(rect, w * 0.08f, w * 0.08f);
ringRect.origin.y += offsetY;
UIBezierPath *ring = [UIBezierPath bezierPathWithOvalInRect:ringRect];
ring.lineWidth = ceilf(w * 0.012f);
[[UIColor colorWithWhite:0.3f alpha:1.0f] setStroke];
[ring stroke];
CGRect innerRingRect = CGRectInset(rect, w * 0.21f, w * 0.21f);
innerRingRect.origin.y += offsetY;
UIBezierPath *inner = [UIBezierPath bezierPathWithOvalInRect:innerRingRect];
inner.lineWidth = ceilf(w * 0.007f);
[[UIColor colorWithWhite:0.7f alpha:1.0f] setStroke];
[inner stroke];
NSMutableParagraphStyle *pStyle = [[NSMutableParagraphStyle alloc] init];
pStyle.alignment = NSTextAlignmentCenter;
NSDictionary *titleAttributes = @{
NSFontAttributeName: [UIFont fontWithName:fontName size:w * 0.068f],
NSParagraphStyleAttributeName : pStyle,
NSForegroundColorAttributeName : [UIColor whiteColor],
NSKernAttributeName : @(w * 0.0037f)
};
NSString *t = [title uppercaseString];
CGRect titleRect = CGRectMake(0, w * 0.91f, w, w * 0.09f);
NSStringDrawingOptions o = NSStringDrawingUsesLineFragmentOrigin;
[t drawWithRect:titleRect options:o attributes:titleAttributes context:nil];
CGSize bs = CGSizeMake(w * 0.44f, w * 0.19f);
CGPoint bOrigin = CGPointMake((w - bs.width) / 2.0f, (w - bs.height) / 2.0f);
bOrigin.y += offsetY;
CGRect b = { bOrigin, bs };
CGFloat cX = CGRectGetMidX(b), cY = CGRectGetMidY(b);
CGAffineTransform transform = CGAffineTransformMakeTranslation(cX, cY);
transform = CGAffineTransformRotate(transform, 0.5236f);
transform = CGAffineTransformTranslate(transform, -cX, -cY);
CGContextConcatCTM(UIGraphicsGetCurrentContext(), transform);
[[UIColor colorWithRed:0.12f green:0.25f blue:0.4f alpha:1.0f] setFill];
[[UIBezierPath bezierPathWithRoundedRect:b cornerRadius:bs.height * 0.15f] fill];
NSMutableDictionary *a = [titleAttributes mutableCopy];
a[NSFontAttributeName] = [UIFont fontWithName:fontName size:bs.height * 0.84f];
a[NSKernAttributeName] = @(bs.height * 0.04f);
CGRect r = CGRectInset(b, 0, 0.17f * bs.height);
[initials drawWithRect:r options:o attributes:a context:nil];
}
@end
@michaelmcguire
Copy link

Discovering this after typing it up from the image makes me feel like https://www.youtube.com/watch?v=zdA__2tKoIU

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment