1 Pluspunkt 0 Minuspunkte
Wie kann ich nur bestimmte Teile eines Polygon mit Farbe füllen mit Windows Graphics?
von  

2 Antworten

0 Pluspunkte 0 Minuspunkte

Indem du der Funktion FillPolygon nur die Punkte übergibst die es füllen soll.

// Fülle nur bestimmte Bereiche des Polygons mit Farbe
Brush brush = new SolidBrush(Color.Red);

// Beispiel: Fülle nur den Bereich zwischen Punkt 1 und Punkt 2 des Polygons
PointF fillPoint1 = _points[0];
PointF fillPoint2 = _points[1];
PointF fillPoint3 = new PointF(fillPoint1.X + 10, fillPoint2.Y + 10); // Beispiel: Ein zusätzlicher Punkt

PointF[] fillPoints = { fillPoint1, fillPoint2, fillPoint3 };
e.Graphics.FillPolygon(brush, fillPoints);
von (706 Punkte)  
0 Pluspunkte 0 Minuspunkte

Wenn du ein Viereck hast.

PointF[] Points = new PointF[]
{
    new PointF(-50, -50),
    new PointF(-50, 50),
    new PointF(50, 50),
    new PointF(50, -50)
};

Dann kannst du die Hälfte davon füllen indem du 3 Punkte an die Methode FillPolygon übergibst.

PointF[] halfPoints = { Points[0], Points[1], Points[2] };
FillPolygon(Brushes.Red, halfPoints);
von (716 Punkte)