Permalink
Browse files

Draw concentric circles

  • Loading branch information...
1 parent 67e06a4 commit bc043affe8f9c4d46243e923971d4ed91b3005c0 @paulcbetts committed Jul 9, 2012
Showing with 6 additions and 9 deletions.
  1. +1 −6 Hypnosister/Hypnosister/AppDelegate.cs
  2. +5 −3 Hypnosister/Hypnosister/HypnosisView.cs
@@ -28,14 +28,9 @@ public override bool FinishedLaunching (UIApplication app, NSDictionary options)
// create a new window instance based on the screen size
window = new UIWindow (UIScreen.MainScreen.Bounds);
- var viewFrame = new RectangleF(160, 240, 100, 150);
- var view = new HypnosisView() { Frame = viewFrame };
+ var view = new HypnosisView() { Frame = window.Bounds };
window.AddSubview(view);
- var anotherFrame = new RectangleF(20, 30, 50, 50);
- var anotherView = new HypnosisView() { Frame = anotherFrame };
- view.AddSubview(anotherView);
-
window.BackgroundColor = UIColor.White;
// make the window visible
@@ -18,13 +18,15 @@ public override void Draw (RectangleF rect)
var center = new PointF(Bounds.X + Bounds.Width / 2.0f, Bounds.Y + Bounds.Height / 2.0f);
- var maxRadius = distance(Bounds.Width, Bounds.Height) / 4.0f;
+ var maxRadius = distance(Bounds.Width, Bounds.Height) / 2.0f;
ctx.SetLineWidth(10);
ctx.SetRGBStrokeColor(0.6f, 0.6f, 0.6f, 1.0f);
- ctx.AddArc(center.X, center.Y, maxRadius, 0.0f, (float)Math.PI * 2.0f, true);
- ctx.StrokePath();
+ for (float currentRadius = maxRadius; currentRadius > 0; currentRadius -= 20.0f) {
+ ctx.AddArc(center.X, center.Y, currentRadius, 0.0f, (float)Math.PI * 2.0f, true);
+ ctx.StrokePath();
+ }
}
// In the book they call the C function hypot()

0 comments on commit bc043af

Please sign in to comment.