namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction { using System.IO; using PdfPig.Core; /// /// /// Append a straight line segment from the current point to the point (x, y). /// public class AppendStraightLineSegment : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. /// public const string Symbol = "l"; /// public string Operator => Symbol; /// /// The x coordinate of the end point of the line. /// public decimal X { get; } /// /// The y coordinate of the end point of the line. /// public decimal Y { get; } /// /// Create a new . /// /// The x coordinate of the line's end point. /// The y coordinate of the line's end point. public AppendStraightLineSegment(decimal x, decimal y) { X = x; Y = y; } /// public void Run(IOperationContext operationContext) { var endPoint = operationContext.CurrentTransformationMatrix.Transform(new PdfPoint(X, Y)); operationContext.CurrentSubpath.LineTo(endPoint.X, endPoint.Y); operationContext.CurrentPosition = endPoint; } /// public void Write(Stream stream) { stream.WriteDecimal(X); stream.WriteWhiteSpace(); stream.WriteDecimal(Y); stream.WriteWhiteSpace(); stream.WriteText(Symbol); stream.WriteWhiteSpace(); } /// public override string ToString() { return $"{X} {Y} {Symbol}"; } } }