Skip to content

Instantly share code, notes, and snippets.

@topgenorth
Created May 1, 2014 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save topgenorth/b9ad2e9de6bb35cc13b1 to your computer and use it in GitHub Desktop.
Save topgenorth/b9ad2e9de6bb35cc13b1 to your computer and use it in GitHub Desktop.
Code for drawing the "circle"
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