Skip to content

Instantly share code, notes, and snippets.

@none53
Created September 22, 2014 23:07
Show Gist options
  • Select an option

  • Save none53/ce2ddd8a93df9f97c0da to your computer and use it in GitHub Desktop.

Select an option

Save none53/ce2ddd8a93df9f97c0da to your computer and use it in GitHub Desktop.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Point[] pts = {
new Point(100, 200), new Point(140, 100),
new Point(160, 100), new Point(200, 200),
new Point(120, 150), new Point(180, 150)
};
Pen pen = new Pen(Color.Black);
e.Graphics.DrawLine(pen, pts[0], pts[1]);
e.Graphics.DrawLine(pen, pts[1], pts[2]);
e.Graphics.DrawLine(pen, pts[2], pts[3]);
// e.Graphics.DrawLine(pen, pts[3], pts[4]);
e.Graphics.DrawLine(pen, pts[4], pts[5]);
Point[] rect0 = {
new Point(100, 200),
new Point(200, 200),
new Point(200, 100),
new Point(100, 100)
};
Point[] rect1 = {
new Point(100, 200+1),
new Point(200+1, 200+1),
new Point(200+1, 100),
new Point(100, 100)
};
Color col0 = Color.FromArgb(31, Color.Red);
Color col1 = Color.FromArgb(31, Color.Cyan);
SolidBrush brush0 = new SolidBrush(col0);
SolidBrush brush1 = new SolidBrush(col1);
e.Graphics.FillPolygon(brush0, rect0, FillMode.Alternate);
e.Graphics.FillPolygon(brush1, rect1, FillMode.Alternate);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment