mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-23 04:36:44 +08:00
Adding Centroid to PdfRectangle.
This commit is contained in:
@@ -30,6 +30,11 @@
|
||||
/// </summary>
|
||||
public PdfPoint BottomLeft { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Centroid point of the rectangle.
|
||||
/// </summary>
|
||||
public PdfPoint Centroid { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Width of the rectangle.
|
||||
/// </summary>
|
||||
@@ -105,15 +110,14 @@
|
||||
|
||||
BottomLeft = new PdfPoint(left, bottom);
|
||||
BottomRight = new PdfPoint(right, bottom);
|
||||
|
||||
Centroid = new PdfPoint(left + (right - left) / 2, bottom + (top - bottom) / 2);
|
||||
}
|
||||
|
||||
internal PdfRectangle(PdfVector topLeft, PdfVector topRight, PdfVector bottomLeft, PdfVector bottomRight)
|
||||
: this(topLeft.ToPoint(), topRight.ToPoint(), bottomLeft.ToPoint(), bottomRight.ToPoint())
|
||||
{
|
||||
TopLeft = topLeft.ToPoint();
|
||||
TopRight = topRight.ToPoint();
|
||||
|
||||
BottomLeft = bottomLeft.ToPoint();
|
||||
BottomRight = bottomRight.ToPoint();
|
||||
}
|
||||
|
||||
internal PdfRectangle(PdfPoint topLeft, PdfPoint topRight, PdfPoint bottomLeft, PdfPoint bottomRight)
|
||||
@@ -123,6 +127,8 @@
|
||||
|
||||
BottomLeft = bottomLeft;
|
||||
BottomRight = bottomRight;
|
||||
|
||||
Centroid = new PdfPoint(topLeft.X + (topRight.X - topLeft.X) / 2, bottomLeft.Y + (topLeft.Y - bottomLeft.Y) / 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user