mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-15 19:54:52 +08:00
lazily evaluate centroid of rectangle
This commit is contained in:
@@ -33,7 +33,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Centroid point of the rectangle.
|
/// Centroid point of the rectangle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PdfPoint Centroid { get; }
|
public PdfPoint Centroid => new PdfPoint(TopLeft.X + (TopLeft.X - TopLeft.X) / 2, BottomLeft.Y + (TopLeft.Y - BottomLeft.Y) / 2);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Width of the rectangle.
|
/// Width of the rectangle.
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
public decimal Bottom => BottomRight.Y;
|
public decimal Bottom => BottomRight.Y;
|
||||||
|
|
||||||
internal PdfRectangle(PdfPoint point1, PdfPoint point2) : this(point1.X, point1.Y, point2.X, point2.Y) { }
|
internal PdfRectangle(PdfPoint point1, PdfPoint point2) : this(point1.X, point1.Y, point2.X, point2.Y) { }
|
||||||
internal PdfRectangle(short x1, short y1, short x2, short y2) : this((decimal) x1, y1, x2, y2) { }
|
internal PdfRectangle(short x1, short y1, short x2, short y2) : this((decimal)x1, y1, x2, y2) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="PdfRectangle"/>.
|
/// Create a new <see cref="PdfRectangle"/>.
|
||||||
@@ -110,14 +110,11 @@
|
|||||||
|
|
||||||
BottomLeft = new PdfPoint(left, bottom);
|
BottomLeft = new PdfPoint(left, bottom);
|
||||||
BottomRight = new PdfPoint(right, 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)
|
internal PdfRectangle(PdfVector topLeft, PdfVector topRight, PdfVector bottomLeft, PdfVector bottomRight)
|
||||||
: this(topLeft.ToPoint(), topRight.ToPoint(), bottomLeft.ToPoint(), bottomRight.ToPoint())
|
: this(topLeft.ToPoint(), topRight.ToPoint(), bottomLeft.ToPoint(), bottomRight.ToPoint())
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal PdfRectangle(PdfPoint topLeft, PdfPoint topRight, PdfPoint bottomLeft, PdfPoint bottomRight)
|
internal PdfRectangle(PdfPoint topLeft, PdfPoint topRight, PdfPoint bottomLeft, PdfPoint bottomRight)
|
||||||
@@ -127,8 +124,6 @@
|
|||||||
|
|
||||||
BottomLeft = bottomLeft;
|
BottomLeft = bottomLeft;
|
||||||
BottomRight = bottomRight;
|
BottomRight = bottomRight;
|
||||||
|
|
||||||
Centroid = new PdfPoint(topLeft.X + (topRight.X - topLeft.X) / 2, bottomLeft.Y + (topLeft.Y - bottomLeft.Y) / 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Reference in New Issue
Block a user