public void gradient(Point[] points, PathGradientBrush pgbrush, Triangle tre, GraphicsPath brushPath)
{
Color[] mySurroundColor = { tre.v1.currColor, tre.v2.currColor, tre.v3.currColor};
pgbrush.SurroundColors = mySurroundColor;
int averageR = (tre.v1.currColor.R + tre.v2.currColor.R + tre.v3.currColor.R) / 3;
int averageG = (tre.v1.currColor.G + tre.v2.currColor.G + tre.v3.currColor.G) / 3;
int averageB = (tre.v1.currColor.B + tre.v2.currColor.B + tre.v3.currColor.B) / 3;
Color centerCol = Color.FromArgb((byte) averageR, (byte)averageG, (byte)averageB);
pgbrush.CenterColor = centerCol;
pgbrush.SetBlendTriangularShape(0.7f, 0.7f);
graphics.FillPolygon(pgbrush, points);
pgbrush.Dispose();
}