GDI+ FillPolygon()
Jeg har en figur som jeg ønsker at fylde med farve.Men jeg kan ikke rigtig få metoden FillPolygon til at virke.
(Graphics.FillPolygon())
Figuren ser sådan her ud:
System.Drawing.Graphics formGraphics = null;
System.Drawing.Pen myPen;
formGraphics = pictureBox8.CreateGraphics();
myPen = new System.Drawing.Pen(System.Drawing.Color.Black,1);
formGraphics.DrawLine(myPen, 5, 20, 90, 20);
formGraphics.DrawLine(myPen, 5, 20, 5, 90);
formGraphics.DrawLine(myPen, 90, 20, 90, 90);
formGraphics.DrawLine(myPen, 5,90,30,115);
formGraphics.DrawLine(myPen, 90, 90, 65, 115);
formGraphics.DrawLine(myPen, 30, 115, 65, 115);
myPen.Dispose();
Men når jeg fylder farve i den, så virker det ikke:
SolidBrush GrayBrush = new SolidBrush(Color.Gray);
Point point1 = new Point(5, 20);
Point point2 = new Point(90, 20);
Point point3 = new Point(5, 20);
Point point4 = new Point(5, 90);
Point point5 = new Point(90, 20);
Point point6 = new Point(90, 90);
Point point7 = new Point(5, 90);
Point point8 = new Point(90, 90);
Point[] curvePoints = new Point[]
{
point1,
point2,
point3,
point4,
point5,
point6,
point7,
point8
};
formGraphics.FillPolygon(GrayBrush, curvePoints);
Nogen ideer?
