Change name from PdfPath to PdfSubpath

This commit is contained in:
BobLd
2020-04-02 16:12:39 +01:00
committed by Eliot Jones
parent f1be6634a7
commit ab6a0f11fc
21 changed files with 94 additions and 93 deletions

View File

@@ -8,17 +8,17 @@
/// <summary>
/// A path in a PDF document, used by glyphs and page content. Can contain multiple sub-paths.
/// </summary>
public class PdfPath
public class PdfSubpath
{
private readonly List<IPathCommand> commands = new List<IPathCommand>();
/// <summary>
/// The sequence of sub-paths which form this <see cref="PdfPath"/>.
/// The sequence of sub-paths which form this <see cref="PdfSubpath"/>.
/// </summary>
public IReadOnlyList<IPathCommand> Commands => commands;
/// <summary>
/// True if the <see cref="PdfPath"/> was originaly draw as a rectangle.
/// True if the <see cref="PdfSubpath"/> was originaly draw as a rectangle.
/// </summary>
public bool IsDrawnAsRectangle { get; internal set; }
@@ -63,7 +63,7 @@
}
/// <summary>
/// Get the <see cref="PdfPath"/>'s centroid point.
/// Get the <see cref="PdfSubpath"/>'s centroid point.
/// </summary>
public PdfPoint GetCentroid()
{
@@ -124,12 +124,12 @@
}
/// <summary>
/// Simplify this <see cref="PdfPath"/> by converting everything to <see cref="PdfLine"/>s.
/// Simplify this <see cref="PdfSubpath"/> by converting everything to <see cref="PdfLine"/>s.
/// </summary>
/// <param name="n">Number of lines required (minimum is 1).</param>
internal PdfPath Simplify(int n = 4)
internal PdfSubpath Simplify(int n = 4)
{
PdfPath simplifiedPath = new PdfPath();
PdfSubpath simplifiedPath = new PdfSubpath();
var startPoint = GetStartPoint(Commands.First());
simplifiedPath.MoveTo(startPoint.X, startPoint.Y);
@@ -315,7 +315,7 @@
}
/// <summary>
/// A command in a <see cref="PdfPath"/>.
/// A command in a <see cref="PdfSubpath"/>.
/// </summary>
public interface IPathCommand
{
@@ -332,7 +332,7 @@
}
/// <summary>
/// Close the current <see cref="PdfPath"/>.
/// Close the current <see cref="PdfSubpath"/>.
/// </summary>
public class Close : IPathCommand
{
@@ -363,7 +363,7 @@
}
/// <summary>
/// Move drawing of the current <see cref="PdfPath"/> to the specified location.
/// Move drawing of the current <see cref="PdfSubpath"/> to the specified location.
/// </summary>
public class Move : IPathCommand
{
@@ -707,11 +707,11 @@
}
/// <summary>
/// Compares two <see cref="PdfPath"/>s for equality. Paths will only be considered equal if the commands which construct the paths are in the same order.
/// Compares two <see cref="PdfSubpath"/>s for equality. Paths will only be considered equal if the commands which construct the paths are in the same order.
/// </summary>
public override bool Equals(object obj)
{
if (obj is PdfPath path)
if (obj is PdfSubpath path)
{
if (Commands.Count != path.Commands.Count) return false;

View File

@@ -54,7 +54,7 @@
/// Get the Alto (XML) string of the pages layout.
/// </summary>
/// <param name="document">The document to extract page layouts from.</param>
/// <param name="includePaths">Draw <see cref="PdfPath"/>s present in the page.</param>
/// <param name="includePaths">Draw PdfPaths present in the page.</param>
public string Get(PdfDocument document, bool includePaths = false)
{
var altoDocument = CreateAltoDocument("unknown");
@@ -67,7 +67,7 @@
/// <inheritdoc />
/// <summary>
/// Get the Alto (XML) string of the page layout. Excludes <see cref="T:UglyToad.PdfPig.Geometry.PdfPath" />s.
/// Get the Alto (XML) string of the page layout. Excludes <see cref="T:UglyToad.PdfPig.Geometry.PdfSubpath" />s.
/// </summary>
/// <param name="page">The page to export the XML layout for.</param>
public string Get(Page page) => Get(page, false);
@@ -76,7 +76,7 @@
/// Get the Alto (XML) string of the page layout.
/// </summary>
/// <param name="page">The page to export the XML layout for.</param>
/// <param name="includePaths">Whether the output should include the <see cref="PdfPath"/>s present in the page.</param>
/// <param name="includePaths">Whether the output should include the PdfPaths present in the page.</param>
public string Get(Page page, bool includePaths)
{
var document = CreateAltoDocument("unknown");
@@ -159,7 +159,7 @@
return altoPage;
}
private AltoDocument.AltoGraphicalElement ToAltoGraphicalElement(PdfPath pdfPath, double height)
private AltoDocument.AltoGraphicalElement ToAltoGraphicalElement(PdfSubpath pdfPath, double height)
{
graphicalElementCount++;

View File

@@ -47,7 +47,7 @@
/// Get the hOCR (HTML) string of the page layout.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="includePaths">Draw <see cref="PdfPath"/>s present in the page.</param>
/// <param name="includePaths">Draw PdfPaths present in the page.</param>
/// <param name="useHocrjs">Will add a reference to the 'hocrjs' script just before the closing 'body' tag, adding the
/// interface to a plain hOCR file.<para>See https://github.com/kba/hocrjs for more information.</para></param>
public string Get(PdfDocument document, bool includePaths = false, bool useHocrjs = false)
@@ -67,7 +67,7 @@
}
/// <summary>
/// Get the hOCR (HTML) string of the page layout. Excludes <see cref="PdfPath"/>s.
/// Get the hOCR (HTML) string of the page layout. Excludes PdfPaths.
/// </summary>
/// <param name="page">The page.</param>
public string Get(Page page)
@@ -80,7 +80,7 @@
/// </summary>
/// <param name="page">The page.</param>
/// <param name="imageName">The image name, if any.</param>
/// <param name="includePaths">Draw <see cref="PdfPath"/>s present in the page.</param>
/// <param name="includePaths">Draw PdfPaths present in the page.</param>
/// <param name="useHocrjs">Will add a reference to the 'hocrjs' script just before the closing 'body' tag, adding the interface to a plain hOCR file.<para>See https://github.com/kba/hocrjs for more information.</para></param>
public string Get(Page page, bool includePaths = false, string imageName = "unknown", bool useHocrjs = false)
{
@@ -129,7 +129,7 @@
/// </summary>
/// <param name="page"></param>
/// <param name="imageName"></param>
/// <param name="includePaths">Draw <see cref="PdfPath"/>s present in the page.</param>
/// <param name="includePaths">Draw PdfPaths present in the page.</param>
private string GetCode(Page page, bool includePaths, string imageName = "unknown")
{
pageCount++;
@@ -176,7 +176,7 @@
/// <param name="pageHeight"></param>
/// <param name="subPaths"></param>
/// <param name="level">The indent level.</param>
private string GetCode(PdfPath path, double pageHeight, bool subPaths, int level)
private string GetCode(PdfSubpath path, double pageHeight, bool subPaths, int level)
{
if (path == null) return string.Empty;

View File

@@ -57,14 +57,14 @@
/// Get the PAGE-XML (XML) string of the pages layout.
/// </summary>
/// <param name="document"></param>
/// <param name="includePaths">Draw <see cref="PdfPath"/>s present in the page.</param>
/// <param name="includePaths">Draw PdfPaths present in the page.</param>
public string Get(PdfDocument document, bool includePaths = false)
{
throw new NotImplementedException();
}
/// <summary>
/// Get the PAGE-XML (XML) string of the pages layout. Excludes <see cref="PdfPath"/>s.
/// Get the PAGE-XML (XML) string of the pages layout. Excludes PdfPaths.
/// </summary>
/// <param name="page"></param>
public string Get(Page page)
@@ -76,7 +76,7 @@
/// Get the PAGE-XML (XML) string of the pages layout.
/// </summary>
/// <param name="page"></param>
/// <param name="includePaths">Draw <see cref="PdfPath"/>s present in the page.</param>
/// <param name="includePaths">Draw PdfPaths present in the page.</param>
public string Get(Page page, bool includePaths)
{
lineCount = 0;
@@ -199,7 +199,7 @@
return pageXmlPage;
}
private PageXmlDocument.PageXmlLineDrawingRegion ToPageXmlLineDrawingRegion(PdfPath pdfPath, double height)
private PageXmlDocument.PageXmlLineDrawingRegion ToPageXmlLineDrawingRegion(PdfSubpath pdfPath, double height)
{
var bbox = pdfPath.GetBoundingRectangle();
if (bbox.HasValue)

View File

@@ -18,7 +18,7 @@
/// <summary>
/// The current path.
/// </summary>
public PdfPath Path { get; } = new PdfPath();
public PdfSubpath Path { get; } = new PdfSubpath();
/// <summary>
/// The current location of the active point.

View File

@@ -32,7 +32,7 @@
/// <param name="name">The name of the character to retrieve the CharString for.</param>
/// <param name="defaultWidthX">The default width for the glyph from the font's private dictionary.</param>
/// <param name="nominalWidthX">The nominal width which individual glyph widths are encoded as the difference from.</param>
/// <returns>A <see cref="PdfPath"/> for the glyph.</returns>
/// <returns>A <see cref="PdfSubpath"/> for the glyph.</returns>
public Type2Glyph Generate(string name, double defaultWidthX, double nominalWidthX)
{
Type2Glyph glyph;
@@ -223,7 +223,7 @@
/// <summary>
/// The path of the glyph.
/// </summary>
public PdfPath Path { get; }
public PdfSubpath Path { get; }
/// <summary>
/// The width of the glyph as a difference from the nominal width X for the font. Optional.
@@ -233,7 +233,7 @@
/// <summary>
/// Create a new <see cref="Type2Glyph"/>.
/// </summary>
public Type2Glyph(PdfPath path, double? width)
public Type2Glyph(PdfSubpath path, double? width)
{
Path = path ?? throw new ArgumentNullException(nameof(path));
Width = width;

View File

@@ -6,8 +6,8 @@
internal class Type1BuildCharContext
{
private readonly Func<int, PdfPath> characterByIndexFactory;
private readonly Func<string, PdfPath> characterByNameFactory;
private readonly Func<int, PdfSubpath> characterByIndexFactory;
private readonly Func<string, PdfSubpath> characterByNameFactory;
public IReadOnlyDictionary<int, Type1CharStrings.CommandSequence> Subroutines { get; }
public double WidthX { get; set; }
@@ -20,7 +20,7 @@
public bool IsFlexing { get; set; }
public PdfPath Path { get; private set; } = new PdfPath();
public PdfSubpath Path { get; private set; } = new PdfSubpath();
public PdfPoint CurrentPosition { get; set; }
@@ -31,8 +31,8 @@
public IReadOnlyList<PdfPoint> FlexPoints { get; }
public Type1BuildCharContext(IReadOnlyDictionary<int, Type1CharStrings.CommandSequence> subroutines,
Func<int, PdfPath> characterByIndexFactory,
Func<string, PdfPath> characterByNameFactory)
Func<int, PdfSubpath> characterByIndexFactory,
Func<string, PdfSubpath> characterByNameFactory)
{
this.characterByIndexFactory = characterByIndexFactory ?? throw new ArgumentNullException(nameof(characterByIndexFactory));
this.characterByNameFactory = characterByNameFactory ?? throw new ArgumentNullException(nameof(characterByNameFactory));
@@ -44,17 +44,17 @@
}
public PdfPath GetCharacter(int characterCode)
public PdfSubpath GetCharacter(int characterCode)
{
return characterByIndexFactory(characterCode);
}
public PdfPath GetCharacter(string characterName)
public PdfSubpath GetCharacter(string characterName)
{
return characterByNameFactory(characterName);
}
public void SetPath(PdfPath path)
public void SetPath(PdfSubpath path)
{
Path = path ?? throw new ArgumentNullException(nameof(path));
}

View File

@@ -10,7 +10,7 @@
{
private readonly IReadOnlyDictionary<int, string> charStringIndexToName;
private readonly object locker = new object();
private readonly Dictionary<string, PdfPath> glyphs = new Dictionary<string, PdfPath>();
private readonly Dictionary<string, PdfSubpath> glyphs = new Dictionary<string, PdfSubpath>();
public IReadOnlyDictionary<string, CommandSequence> CharStrings { get; }
@@ -24,9 +24,9 @@
Subroutines = subroutines ?? throw new ArgumentNullException(nameof(subroutines));
}
public bool TryGenerate(string name, out PdfPath path)
public bool TryGenerate(string name, out PdfSubpath path)
{
path = default(PdfPath);
path = default(PdfSubpath);
lock (locker)
{
if (glyphs.TryGetValue(name, out path))
@@ -54,7 +54,7 @@
return true;
}
private PdfPath Run(CommandSequence sequence)
private PdfSubpath Run(CommandSequence sequence)
{
var context = new Type1BuildCharContext(Subroutines, i =>
{

View File

@@ -372,7 +372,7 @@
[MemberData(nameof(IsCounterClockwiseData))]
public void IsCounterClockwise(double[][] source, bool expected)
{
PdfPath pdfPath = new PdfPath();
PdfSubpath pdfPath = new PdfSubpath();
foreach (var point in source)
{
pdfPath.LineTo(point[0], point[1]);

View File

@@ -10,7 +10,7 @@
[Fact]
public void BezierCurveGeneratesCorrectBoundingBox()
{
var curve = new PdfPath.BezierCurve(new PdfPoint(60, 105),
var curve = new PdfSubpath.BezierCurve(new PdfPoint(60, 105),
new PdfPoint(75, 30),
new PdfPoint(215, 115),
new PdfPoint(140, 160));
@@ -28,7 +28,7 @@
[Fact]
public void LoopBezierCurveGeneratesCorrectBoundingBox()
{
var curve = new PdfPath.BezierCurve(new PdfPoint(166, 142),
var curve = new PdfSubpath.BezierCurve(new PdfPoint(166, 142),
new PdfPoint(75, 30),
new PdfPoint(215, 115),
new PdfPoint(140, 160));
@@ -47,7 +47,7 @@
[Fact]
public void BezierCurveAddsCorrectSvgCommand()
{
var curve = new PdfPath.BezierCurve(new PdfPoint(60, 105),
var curve = new PdfSubpath.BezierCurve(new PdfPoint(60, 105),
new PdfPoint(75, 30),
new PdfPoint(215, 115),
new PdfPoint(140, 160));

View File

@@ -4,7 +4,7 @@
using UglyToad.PdfPig.Core;
using UglyToad.PdfPig.Geometry;
using Xunit;
using static UglyToad.PdfPig.Core.PdfPath;
using static UglyToad.PdfPig.Core.PdfSubpath;
public class BezierCurveTests
{

View File

@@ -4,7 +4,7 @@
using UglyToad.PdfPig.Core;
using UglyToad.PdfPig.Geometry;
using Xunit;
using static UglyToad.PdfPig.Core.PdfPath;
using static UglyToad.PdfPig.Core.PdfSubpath;
public class PdfPathLineTests
{

View File

@@ -20,7 +20,7 @@
public TransformationMatrix CurrentTransformationMatrix => GetCurrentState().CurrentTransformationMatrix;
public PdfPath CurrentPath { get; set; }
public PdfSubpath CurrentPath { get; set; }
public IColorSpaceContext ColorSpaceContext { get; }
@@ -29,7 +29,7 @@
public TestOperationContext()
{
StateStack.Push(new CurrentGraphicsState());
CurrentPath = new PdfPath();
CurrentPath = new PdfSubpath();
ColorSpaceContext = new ColorSpaceContext(GetCurrentState, new ResourceStore(new TestPdfTokenScanner(), new TestFontFactory()));
}

View File

@@ -73,7 +73,7 @@
IReadOnlyList<NameToken> attached,
IReadOnlyList<MarkedContentElement> children,
IReadOnlyList<Letter> letters,
IReadOnlyList<PdfPath> paths,
IReadOnlyList<PdfSubpath> paths,
IReadOnlyList<IPdfImage> images,
int index)
: base(markedContentIdentifier, tag, properties, language,

View File

@@ -50,7 +50,7 @@
/// <summary>
/// Paths contained in this marked content.
/// </summary>
public IReadOnlyList<PdfPath> Paths { get; }
public IReadOnlyList<PdfSubpath> Paths { get; }
/// <summary>
/// Images contained in this marked content.
@@ -88,7 +88,7 @@
bool isArtifact,
IReadOnlyList<MarkedContentElement> children,
IReadOnlyList<Letter> letters,
IReadOnlyList<PdfPath> paths,
IReadOnlyList<PdfSubpath> paths,
IReadOnlyList<IPdfImage> images,
int index)
{

View File

@@ -172,9 +172,9 @@
private readonly AnnotationProvider annotationProvider;
/// <summary>
/// The set of <see cref="PdfPath"/>s drawn by the PDF content.
/// The set of <see cref="PdfSubpath"/>s drawn by the PDF content.
/// </summary>
public IReadOnlyList<PdfPath> Paths => page.Content?.Paths ?? new List<PdfPath>();
public IReadOnlyList<PdfSubpath> Paths => page.Content?.Paths ?? new List<PdfSubpath>();
internal Experimental(Page page, AnnotationProvider annotationProvider)
{

View File

@@ -28,12 +28,12 @@
public IReadOnlyList<Letter> Letters { get; }
public IReadOnlyList<PdfPath> Paths { get; }
public IReadOnlyList<PdfSubpath> Paths { get; }
public int NumberOfImages => images.Count;
internal PageContent(IReadOnlyList<IGraphicsStateOperation> graphicsStateOperations, IReadOnlyList<Letter> letters,
IReadOnlyList<PdfPath> paths,
IReadOnlyList<PdfSubpath> paths,
IReadOnlyList<Union<XObjectContentRecord, InlineImage>> images,
IReadOnlyList<MarkedContentElement> markedContents,
IPdfTokenScanner pdfScanner,

View File

@@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static UglyToad.PdfPig.Core.PdfSubpath;
/// <summary>
/// Extension class to Geometry.
@@ -469,7 +470,7 @@
/// <summary>
/// Whether two lines intersect.
/// </summary>
public static bool IntersectsWith(this PdfLine line, PdfPath.Line other)
public static bool IntersectsWith(this PdfLine line, Line other)
{
return IntersectsWith(line.Point1, line.Point2, other.From, other.To);
}
@@ -485,7 +486,7 @@
/// <summary>
/// Get the <see cref="PdfPoint"/> that is the intersection of two lines.
/// </summary>
public static PdfPoint? Intersect(this PdfLine line, PdfPath.Line other)
public static PdfPoint? Intersect(this PdfLine line, Line other)
{
return Intersect(line.Point1, line.Point2, other.From, other.To);
}
@@ -501,7 +502,7 @@
/// <summary>
/// Checks if both lines are parallel.
/// </summary>
public static bool ParallelTo(this PdfLine line, PdfPath.Line other)
public static bool ParallelTo(this PdfLine line, Line other)
{
return ParallelTo(line.Point1, line.Point2, other.From, other.To);
}
@@ -511,7 +512,7 @@
/// <summary>
/// Whether the line segment contains the point.
/// </summary>
public static bool Contains(this PdfPath.Line line, PdfPoint point)
public static bool Contains(this Line line, PdfPoint point)
{
return Contains(line.From, line.To, point);
}
@@ -519,7 +520,7 @@
/// <summary>
/// Whether two lines intersect.
/// </summary>
public static bool IntersectsWith(this PdfPath.Line line, PdfPath.Line other)
public static bool IntersectsWith(this Line line, Line other)
{
return IntersectsWith(line.From, line.To, other.From, other.To);
}
@@ -527,7 +528,7 @@
/// <summary>
/// Whether two lines intersect.
/// </summary>
public static bool IntersectsWith(this PdfPath.Line line, PdfLine other)
public static bool IntersectsWith(this Line line, PdfLine other)
{
return IntersectsWith(line.From, line.To, other.Point1, other.Point2);
}
@@ -535,7 +536,7 @@
/// <summary>
/// Get the <see cref="PdfPoint"/> that is the intersection of two lines.
/// </summary>
public static PdfPoint? Intersect(this PdfPath.Line line, PdfPath.Line other)
public static PdfPoint? Intersect(this Line line, Line other)
{
return Intersect(line.From, line.To, other.From, other.To);
}
@@ -543,7 +544,7 @@
/// <summary>
/// Get the <see cref="PdfPoint"/> that is the intersection of two lines.
/// </summary>
public static PdfPoint? Intersect(this PdfPath.Line line, PdfLine other)
public static PdfPoint? Intersect(this Line line, PdfLine other)
{
return Intersect(line.From, line.To, other.Point1, other.Point2);
}
@@ -551,7 +552,7 @@
/// <summary>
/// Checks if both lines are parallel.
/// </summary>
public static bool ParallelTo(this PdfPath.Line line, PdfPath.Line other)
public static bool ParallelTo(this Line line, Line other)
{
return ParallelTo(line.From, line.To, other.From, other.To);
}
@@ -559,7 +560,7 @@
/// <summary>
/// Checks if both lines are parallel.
/// </summary>
public static bool ParallelTo(this PdfPath.Line line, PdfLine other)
public static bool ParallelTo(this Line line, PdfLine other)
{
return ParallelTo(line.From, line.To, other.Point1, other.Point2);
}
@@ -641,7 +642,7 @@
/// </summary>
/// <param name="bezierCurve">The original bezier curve.</param>
/// <param name="tau">The t value were to split the curve, usually between 0 and 1, but not necessary.</param>
public static (PdfPath.BezierCurve, PdfPath.BezierCurve) Split(this PdfPath.BezierCurve bezierCurve, double tau)
public static (BezierCurve, BezierCurve) Split(this BezierCurve bezierCurve, double tau)
{
// De Casteljau Algorithm
PdfPoint[][] points = new PdfPoint[4][];
@@ -668,29 +669,29 @@
}
}
return (new PdfPath.BezierCurve(points[0][0], points[1][0], points[2][0], points[3][0]),
new PdfPath.BezierCurve(points[3][0], points[2][1], points[1][2], points[0][3]));
return (new BezierCurve(points[0][0], points[1][0], points[2][0], points[3][0]),
new BezierCurve(points[3][0], points[2][1], points[1][2], points[0][3]));
}
/// <summary>
/// Checks if the curve and the line are intersecting.
/// <para>Avoid using this method as it is not optimised. Use <see cref="Intersect(PdfPath.BezierCurve, PdfLine)"/> instead.</para>
/// <para>Avoid using this method as it is not optimised. Use <see cref="Intersect(BezierCurve, PdfLine)"/> instead.</para>
/// </summary>
public static bool IntersectsWith(this PdfPath.BezierCurve bezierCurve, PdfLine line)
public static bool IntersectsWith(this BezierCurve bezierCurve, PdfLine line)
{
return IntersectsWith(bezierCurve, line.Point1, line.Point2);
}
/// <summary>
/// Checks if the curve and the line are intersecting.
/// <para>Avoid using this method as it is not optimised. Use <see cref="Intersect(PdfPath.BezierCurve, PdfPath.Line)"/> instead.</para>
/// <para>Avoid using this method as it is not optimised. Use <see cref="Intersect(BezierCurve, Line)"/> instead.</para>
/// </summary>
public static bool IntersectsWith(this PdfPath.BezierCurve bezierCurve, PdfPath.Line line)
public static bool IntersectsWith(this BezierCurve bezierCurve, Line line)
{
return IntersectsWith(bezierCurve, line.From, line.To);
}
private static bool IntersectsWith(PdfPath.BezierCurve bezierCurve, PdfPoint p1, PdfPoint p2)
private static bool IntersectsWith(BezierCurve bezierCurve, PdfPoint p1, PdfPoint p2)
{
return Intersect(bezierCurve, p1, p2).Length > 0;
}
@@ -698,7 +699,7 @@
/// <summary>
/// Get the <see cref="PdfPoint"/>s that are the intersections of the line and the curve.
/// </summary>
public static PdfPoint[] Intersect(this PdfPath.BezierCurve bezierCurve, PdfLine line)
public static PdfPoint[] Intersect(this BezierCurve bezierCurve, PdfLine line)
{
return Intersect(bezierCurve, line.Point1, line.Point2);
}
@@ -706,12 +707,12 @@
/// <summary>
/// Get the <see cref="PdfPoint"/>s that are the intersections of the line and the curve.
/// </summary>
public static PdfPoint[] Intersect(this PdfPath.BezierCurve bezierCurve, PdfPath.Line line)
public static PdfPoint[] Intersect(this BezierCurve bezierCurve, Line line)
{
return Intersect(bezierCurve, line.From, line.To);
}
private static PdfPoint[] Intersect(PdfPath.BezierCurve bezierCurve, PdfPoint p1, PdfPoint p2)
private static PdfPoint[] Intersect(BezierCurve bezierCurve, PdfPoint p1, PdfPoint p2)
{
var ts = IntersectT(bezierCurve, p1, p2);
if (ts == null || ts.Length == 0) return EmptyArray<PdfPoint>.Instance;
@@ -720,12 +721,12 @@
foreach (var t in ts)
{
PdfPoint point = new PdfPoint(
PdfPath.BezierCurve.ValueWithT(bezierCurve.StartPoint.X,
BezierCurve.ValueWithT(bezierCurve.StartPoint.X,
bezierCurve.FirstControlPoint.X,
bezierCurve.SecondControlPoint.X,
bezierCurve.EndPoint.X,
t),
PdfPath.BezierCurve.ValueWithT(bezierCurve.StartPoint.Y,
BezierCurve.ValueWithT(bezierCurve.StartPoint.Y,
bezierCurve.FirstControlPoint.Y,
bezierCurve.SecondControlPoint.Y,
bezierCurve.EndPoint.Y,
@@ -738,8 +739,8 @@
/// <summary>
/// Get the t values that are the intersections of the line and the curve.
/// </summary>
/// <returns>List of t values where the <see cref="PdfPath.BezierCurve"/> and the <see cref="PdfLine"/> intersect.</returns>
public static double[] IntersectT(this PdfPath.BezierCurve bezierCurve, PdfLine line)
/// <returns>List of t values where the <see cref="BezierCurve"/> and the <see cref="PdfLine"/> intersect.</returns>
public static double[] IntersectT(this BezierCurve bezierCurve, PdfLine line)
{
return IntersectT(bezierCurve, line.Point1, line.Point2);
}
@@ -747,13 +748,13 @@
/// <summary>
/// Get the t values that are the intersections of the line and the curve.
/// </summary>
/// <returns>List of t values where the <see cref="PdfPath.BezierCurve"/> and the <see cref="PdfPath.Line"/> intersect.</returns>
public static double[] IntersectT(this PdfPath.BezierCurve bezierCurve, PdfPath.Line line)
/// <returns>List of t values where the <see cref="BezierCurve"/> and the <see cref="Line"/> intersect.</returns>
public static double[] IntersectT(this BezierCurve bezierCurve, Line line)
{
return IntersectT(bezierCurve, line.From, line.To);
}
private static double[] IntersectT(PdfPath.BezierCurve bezierCurve, PdfPoint p1, PdfPoint p2)
private static double[] IntersectT(BezierCurve bezierCurve, PdfPoint p1, PdfPoint p2)
{
// if the bounding boxes do not intersect, they cannot intersect
var bezierBbox = bezierCurve.GetBoundingRectangle();
@@ -887,7 +888,7 @@
return new[] {x1, x2, x3};
}
internal static string ToSvg(this PdfPath p)
internal static string ToSvg(this PdfSubpath p)
{
var builder = new StringBuilder();
foreach (var pathCommand in p.Commands)
@@ -908,7 +909,7 @@
return builder.ToString();
}
internal static string ToFullSvg(this PdfPath p)
internal static string ToFullSvg(this PdfSubpath p)
{
string BboxToRect(PdfRectangle box, string stroke)
{

View File

@@ -28,7 +28,7 @@
/// <summary>
/// Stores each path as it is encountered in the content stream.
/// </summary>
private readonly List<PdfPath> paths = new List<PdfPath>();
private readonly List<PdfSubpath> paths = new List<PdfSubpath>();
/// <summary>
/// Stores a link to each image (either inline or XObject) as it is encountered in the content stream.
@@ -66,7 +66,7 @@
public TransformationMatrix CurrentTransformationMatrix => GetCurrentState().CurrentTransformationMatrix;
public PdfPath CurrentPath { get; private set; }
public PdfSubpath CurrentPath { get; private set; }
public IColorSpaceContext ColorSpaceContext { get; }
@@ -404,7 +404,7 @@
markedContentStack.AddPath(CurrentPath);
}
CurrentPath = new PdfPath();
CurrentPath = new PdfSubpath();
currentPathAdded = false;
}

View File

@@ -14,7 +14,7 @@
/// The current path being drawn if applicable.
/// </summary>
[CanBeNull]
PdfPath CurrentPath { get; }
PdfSubpath CurrentPath { get; }
/// <summary>
/// The active colorspaces for this content stream.

View File

@@ -57,7 +57,7 @@
top?.AddLetter(letter);
}
public void AddPath(PdfPath path)
public void AddPath(PdfSubpath path)
{
top?.AddPath(path);
}
@@ -86,7 +86,7 @@
private readonly DictionaryToken properties;
private readonly List<Letter> letters = new List<Letter>();
private readonly List<PdfPath> paths = new List<PdfPath>();
private readonly List<PdfSubpath> paths = new List<PdfSubpath>();
private readonly List<IPdfImage> images = new List<IPdfImage>();
public List<MarkedContentElement> Children { get; } = new List<MarkedContentElement>();
@@ -108,7 +108,7 @@
images.Add(image);
}
public void AddPath(PdfPath path)
public void AddPath(PdfSubpath path)
{
paths.Add(path);
}