namespace UglyToad.PdfPig.Geometry
{
using System.Diagnostics;
///
/// A point in a PDF file.
///
///
/// 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).
///
public struct PdfPoint
{
///
/// The origin of the coordinates system.
///
public static PdfPoint Origin { get; } = new PdfPoint(0m, 0m);
///
/// The X coordinate for this point. (Horizontal axis).
///
public decimal X { get; }
///
/// The Y coordinate of this point. (Vertical axis).
///
public decimal Y { get; }
///
/// Create a new at this position.
///
[DebuggerStepThrough]
public PdfPoint(decimal x, decimal y)
{
X = x;
Y = y;
}
///
/// Create a new at this position.
///
[DebuggerStepThrough]
public PdfPoint(int x, int y)
{
X = x;
Y = y;
}
///
/// Create a new at this position.
///
[DebuggerStepThrough]
public PdfPoint(double x, double y)
{
X = (decimal)x;
Y = (decimal)y;
}
///
/// Creates a new which is the current point moved in the x direction relative to its current position by a value.
///
/// The distance to move the point in the x direction relative to its current location.
/// A new point shifted on the x axis by the given delta value.
public PdfPoint MoveX(decimal dx)
{
return new PdfPoint(X + dx, Y);
}
///
/// Creates a new which is the current point moved in the y direction relative to its current position by a value.
///
/// The distance to move the point in the y direction relative to its current location.
/// A new point shifted on the y axis by the given delta value.
public PdfPoint MoveY(decimal dy)
{
return new PdfPoint(X, Y + dy);
}
internal PdfVector ToVector()
{
return new PdfVector(X, Y);
}
///
/// Get a string representation of this point.
///
public override string ToString()
{
return $"(x:{X}, y:{Y})";
}
}
}