namespace UglyToad.PdfPig.Graphics.Operations.PathConstruction { using System.IO; using PdfPig.Core; /// /// /// Append a cubic Bezier curve to the current path. /// The curve extends from the current point to the point (x3, y3), using (x1, y1) and (x3, y3) as the Bezier control points /// public class AppendEndControlPointBezierCurve : IGraphicsStateOperation { /// /// The symbol for this operation in a stream. /// public const string Symbol = "y"; /// public string Operator => Symbol; /// /// The x coordinate of the first control point. /// public decimal X1 { get; } /// /// The y coordinate of the first control point. /// public decimal Y1 { get; } /// /// The x coordinate of the end point. /// public decimal X3 { get; } /// /// The y coordinate of the end point. /// public decimal Y3 { get; } /// /// Create a new . /// /// Control point 1 x coordinate. /// Control point 1 y coordinate. /// Control point 2/End x coordinate. /// Control point 2/End y coordinate. public AppendEndControlPointBezierCurve(decimal x1, decimal y1, decimal x3, decimal y3) { X1 = x1; Y1 = y1; X3 = x3; Y3 = y3; } /// public void Run(IOperationContext operationContext) { var controlPoint1 = operationContext.CurrentTransformationMatrix.Transform(new PdfPoint(X1, Y1)); var end = operationContext.CurrentTransformationMatrix.Transform(new PdfPoint(X3, Y3)); operationContext.CurrentSubpath.BezierCurveTo(controlPoint1.X, controlPoint1.Y, end.X, end.Y, end.X, end.Y); operationContext.CurrentPosition = end; } /// public void Write(Stream stream) { stream.WriteDecimal(X1); stream.WriteWhiteSpace(); stream.WriteDecimal(Y1); stream.WriteWhiteSpace(); stream.WriteDecimal(X3); stream.WriteWhiteSpace(); stream.WriteDecimal(Y3); stream.WriteWhiteSpace(); stream.WriteText(Symbol); stream.WriteNewLine(); } /// public override string ToString() { return $"{X1} {Y1} {X3} {Y3} {Symbol}"; } } }