Permalink
Browse files

The best graphics you've ever seen

  • Loading branch information...
1 parent a0c65b2 commit 03ea61146ad64514d5559d6d4dce6cfaeccb1472 Ryan Blunden committed Jan 14, 2013
Showing with 60 additions and 0 deletions.
  1. +12 −0 Hypnosister/Hypnosister/HypnosisView.h
  2. +48 −0 Hypnosister/Hypnosister/HypnosisView.m
@@ -0,0 +1,12 @@
+//
+// Created by rblunden on 1/14/13.
+//
+// To change the template use AppCode | Preferences | File Templates.
+//
+
+
+#import <Foundation/Foundation.h>
+
+
+@interface HypnosisView : UIView
+@end
@@ -0,0 +1,48 @@
+//
+// Created by rblunden on 1/14/13.
+//
+// To change the template use AppCode | Preferences | File Templates.
+//
+
+
+#import "HypnosisView.h"
+
+
+@implementation HypnosisView
+- (id)initWithFrame:(CGRect)frame {
+ self = [super initWithFrame:frame];
+ if (self) {
+ [self setBackgroundColor:[UIColor redColor]];
+ }
+ return self;
+}
+
+- (void)drawRect:(CGRect)dirtyRect {
+ CGContextRef ctx = UIGraphicsGetCurrentContext();
+ CGRect bounds = [self bounds];
+
+ // Figure out the center of the bounds rectangle
+ CGPoint center;
+ center.x = bounds.origin.x + bounds.size.width / 2.0;
+ center.y = bounds.origin.y + bounds.size.height / 2.0;
+
+ // The radius of the circle should be nearly as big as the view
+ float maxRadius = hypot(bounds.size.width, bounds.size.height) / 2.0;
+
+ // The thickness of the line should be 10 points wide
+ CGContextSetLineWidth(ctx, 10);
+
+ // The color of the line should be gray (red/ green/ blue = 0.6, alpha = 1.0);
+// CGContextSetRGBStrokeColor(ctx, 0.6, 0.6, 0.6, 1.0);
+ [[UIColor blueColor] setStroke];
+
+ // DRaw concentric circles from the outside in
+ for (float currentRadius = maxRadius; currentRadius > 0; currentRadius -= 20) {
+ // Add a path to the context
+ CGContextAddArc(ctx, center.x, center.y, currentRadius, 0.0, M_PI * 2.0, YES);
+
+ // Perform drawing instruction; removes path
+ CGContextStrokePath(ctx);
+ }
+}
+@end

0 comments on commit 03ea611

Please sign in to comment.