Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lobrien/1439a7190f9f9bd05c7c to your computer and use it in GitHub Desktop.
Save lobrien/1439a7190f9f9bd05c7c to your computer and use it in GitHub Desktop.
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