2018-01-11 03:49:32 +08:00
|
|
|
|
namespace UglyToad.PdfPig.Geometry
|
2017-11-23 02:41:34 +08:00
|
|
|
|
{
|
2017-12-31 02:02:59 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// A point in a PDF file.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// PDF coordinates are defined with the origin at the lower left (0, 0).
|
|
|
|
|
/// The Y-axis extends vertically upwards and the X-axis horizontally to the right.
|
|
|
|
|
/// Unless otherwise specified on a per-page basis, units in PDF space are equivalent to a typographic point (1/72 inch).
|
|
|
|
|
/// </remarks>
|
2017-11-23 02:41:34 +08:00
|
|
|
|
public struct PdfPoint
|
|
|
|
|
{
|
2017-12-31 02:02:59 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The origin of the coordinates system.
|
|
|
|
|
/// </summary>
|
2017-11-23 02:41:34 +08:00
|
|
|
|
public static PdfPoint Origin = new PdfPoint(0m, 0m);
|
|
|
|
|
|
2017-12-31 02:02:59 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The X coordinate for this point. (Horizontal axis).
|
|
|
|
|
/// </summary>
|
2017-11-23 02:41:34 +08:00
|
|
|
|
public decimal X { get; }
|
|
|
|
|
|
2017-12-31 02:02:59 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The Y coordinate of this point. (Vertical axis).
|
|
|
|
|
/// </summary>
|
2017-11-23 02:41:34 +08:00
|
|
|
|
public decimal Y { get; }
|
|
|
|
|
|
2018-01-07 20:37:48 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a new <see cref="PdfPoint"/> at this position.
|
|
|
|
|
/// </summary>
|
2017-11-23 02:41:34 +08:00
|
|
|
|
public PdfPoint(decimal x, decimal y)
|
|
|
|
|
{
|
|
|
|
|
X = x;
|
|
|
|
|
Y = y;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-07 20:37:48 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a new <see cref="PdfPoint"/> at this position.
|
|
|
|
|
/// </summary>
|
2017-11-23 02:41:34 +08:00
|
|
|
|
public PdfPoint(int x, int y)
|
|
|
|
|
{
|
|
|
|
|
X = x;
|
|
|
|
|
Y = y;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-07 20:37:48 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a new <see cref="PdfPoint"/> at this position.
|
|
|
|
|
/// </summary>
|
2017-11-23 02:41:34 +08:00
|
|
|
|
public PdfPoint(double x, double y)
|
|
|
|
|
{
|
|
|
|
|
X = (decimal)x;
|
|
|
|
|
Y = (decimal)y;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-07 20:37:48 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get a string representation of this point.
|
|
|
|
|
/// </summary>
|
2017-11-23 02:41:34 +08:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"(x:{X}, y:{Y})";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|