Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

The best graphics you've ever seen

  • Loading branch information...
commit 03ea61146ad64514d5559d6d4dce6cfaeccb1472 1 parent a0c65b2
Ryan Blunden authored
View
12 Hypnosister/Hypnosister/HypnosisView.h
@@ -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
View
48 Hypnosister/Hypnosister/HypnosisView.m
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.