You can use FillPolygon
and specify 3 triangle points.
e.Graphics.FillPolygon(Brushes.Aquamarine, new Point[] { new Point(150, 100), new Point(100, 200), new Point(200, 200) });
Or you can create a FillTriangle
extension method
public static class Extensions
{
public static void FillTriangle(this Graphics g, PaintEventArgs e, Point p, int size)
{
e.Graphics.FillPolygon(Brushes.Aquamarine, new Point[] { p, new Point(p.X - size, p.Y + (int)(size * Math.Sqrt(3))), new Point(p.X + size, p.Y + (int)(size * Math.Sqrt(3))) });
}
}
And call like this
e.Graphics.FillTriangle(e, new Point(150, 100), 500);
For right triangle use this
e.Graphics.FillPolygon(Brushes.Aquamarine, new Point[] { p, new Point(p.X, p.Y + size * 2), new Point(p.X + size, p.Y + size * 2) });
For obtuse this
e.Graphics.FillPolygon(Brushes.Aquamarine, new Point[] { p, new Point(p.X - size, p.Y + height), new Point(p.X + size, p.Y + height) });
This code will output this
e.Graphics.FillRightTriangle(e, new Point(50, 20), 100);
e.Graphics.FillTriangle(e, new Point(400, 20), 70);
e.Graphics.FillObtuseTriangle(e, new Point(230, 200), 50, 130);
