Sprache: C#
Die folgende Methode ermittelt die 4 Eckpunkte eines Rectangles und gibt diese in einem Array zurück.
Die Reihnfolge ist:
0: [b]TopLeft[/b]
1: [b]TopRight[/b]
2: [b]BottomLeft[/b]
3: [b]BottomRight[/b]
private Point[] GetBoundPoints(Rectangle bounds)
{
Point TopLeft = bounds.Location;
Point TopRight = bounds.Location;
Point BottomLeft = bounds.Location;
Point BottomRight = bounds.Location;
TopRight.Offset(bounds.Width, 0);
BottomLeft.Offset(0, bounds.Height);
BottomRight.Offset(bounds.Width, bounds.Height);
return new Point[] { TopLeft, TopRight, BottomLeft, BottomRight };
}
private Point[] GetBoundPoints(Rectangle bounds)
{
Point TopLeft = bounds.Location;
Point TopRight = bounds.Location;
Point BottomLeft = bounds.Location;
Point BottomRight = bounds.Location;
TopRight.Offset(bounds.Width, 0);
BottomLeft.Offset(0, bounds.Height);
BottomRight.Offset(bounds.Width, bounds.Height);
return new Point[] { TopLeft, TopRight, BottomLeft, BottomRight };
}
Alte URL:
/snippet/eckpunkte-eines-rectangles-ermitteln/3833