Created
May 1, 2014 02:42
-
-
Save topgenorth/b9ad2e9de6bb35cc13b1 to your computer and use it in GitHub Desktop.
Code for drawing the "circle"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class Hole | |
{ | |
public static readonly float LineWidth = 2f; | |
protected Hole(int radius) | |
{ | |
Radius = radius; | |
} | |
public PointF Point { get; set; } | |
public UIBezierPath Path { get; protected set; } | |
protected int Radius { get; private set; } | |
public virtual void Draw(RectangleF parentFrame) | |
{ | |
var rect = CalculateRectangleForHole(parentFrame); | |
Path = UIBezierPath.FromOval(rect); | |
SetStrokeColour(); | |
Path.LineWidth = LineWidth; | |
Path.Stroke(); | |
} | |
protected abstract void SetStrokeColour(); | |
protected virtual RectangleF CalculateRectangleForHole(RectangleF parentFrame) | |
{ | |
var offset = Radius; | |
var y = parentFrame.Height - Point.Y - offset; | |
var x = Point.X - offset; | |
var length = Radius * 2f; | |
return new RectangleF(x, y, length, length); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment