Create PdfPath

Rename ClippingRule to FillingRule
Move FillingRule from Subpath to Path
This commit is contained in:
BobLd
2020-04-02 16:19:38 +01:00
committed by Eliot Jones
parent ab6a0f11fc
commit 6677641b37
8 changed files with 38 additions and 27 deletions

View File

@@ -3,7 +3,7 @@
/// <summary>
/// Rules for determining which points lie inside/outside a path.
/// </summary>
public enum ClippingRule : byte
public enum FillingRule : byte
{
/// <summary>
/// No rule.

View File

@@ -0,0 +1,30 @@
namespace UglyToad.PdfPig.Core
{
using System.Collections.Generic;
/// <summary>
/// A path is made up of one or more disconnected subpaths, each comprising a sequence of connected segments. The topology of the path is unrestricted: it may be concave or convex, may contain multiple subpaths representing disjoint areas, and may intersect itself in arbitrary ways.
/// <para>A path shall be composed of straight and curved line segments, which may connect to one another or may be disconnected.</para>
/// </summary>
public class PdfPath : List<PdfSubpath>
{
/// <summary>
/// Rules for determining which points lie inside/outside the path.
/// </summary>
public FillingRule FillingRule { get; private set; }
/// <summary>
/// Returns true if this is a clipping path.
/// </summary>
public bool IsClipping { get; private set; }
/// <summary>
/// Set the clipping mode for this path.
/// </summary>
public void SetClipping(FillingRule fillingRule)
{
IsClipping = true;
FillingRule = fillingRule;
}
}
}

View File

@@ -6,7 +6,7 @@
using System.Text;
/// <summary>
/// A path in a PDF document, used by glyphs and page content. Can contain multiple sub-paths.
///
/// </summary>
public class PdfSubpath
{
@@ -22,16 +22,6 @@
/// </summary>
public bool IsDrawnAsRectangle { get; internal set; }
/// <summary>
/// Rules for determining which points lie inside/outside the path.
/// </summary>
public ClippingRule ClippingRule { get; private set; }
/// <summary>
/// Returns true if this is a clipping path.
/// </summary>
public bool IsClipping { get; private set; }
private PdfPoint? currentPosition;
private double shoeLaceSum;
@@ -74,15 +64,6 @@
return new PdfPoint(points.Average(p => p.X), points.Average(p => p.Y));
}
/// <summary>
/// Set the clipping mode for this path.
/// </summary>
public void SetClipping(ClippingRule clippingRule)
{
IsClipping = true;
ClippingRule = clippingRule;
}
internal static PdfPoint GetStartPoint(IPathCommand command)
{
if (command is Line line)

View File

@@ -99,7 +99,7 @@
{
}
public void ModifyClippingIntersect(ClippingRule clippingRule)
public void ModifyClippingIntersect(FillingRule clippingRule)
{
}

View File

@@ -555,14 +555,14 @@
TextMatrices.TextMatrix = newMatrix;
}
public void ModifyClippingIntersect(ClippingRule clippingRule)
public void ModifyClippingIntersect(FillingRule clippingRule)
{
if (CurrentPath == null)
{
return;
}
CurrentPath.SetClipping(clippingRule);
}
}
}

View File

@@ -131,6 +131,6 @@
/// <summary>
/// Modify the clipping rule of the current path.
/// </summary>
void ModifyClippingIntersect(ClippingRule clippingRule);
void ModifyClippingIntersect(FillingRule clippingRule);
}
}

View File

@@ -29,7 +29,7 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.ModifyClippingIntersect(PdfPig.Core.ClippingRule.EvenOdd);
operationContext.ModifyClippingIntersect(PdfPig.Core.FillingRule.EvenOdd);
}
/// <inheritdoc />

View File

@@ -29,7 +29,7 @@
/// <inheritdoc />
public void Run(IOperationContext operationContext)
{
operationContext.ModifyClippingIntersect(PdfPig.Core.ClippingRule.NonZeroWinding);
operationContext.ModifyClippingIntersect(PdfPig.Core.FillingRule.NonZeroWinding);
}
/// <inheritdoc />