mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-18 18:27:55 +08:00
Create PdfPath
Rename ClippingRule to FillingRule Move FillingRule from Subpath to Path
This commit is contained in:
@@ -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.
|
||||
|
30
src/UglyToad.PdfPig.Core/PdfPath.cs
Normal file
30
src/UglyToad.PdfPig.Core/PdfPath.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -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)
|
||||
|
@@ -99,7 +99,7 @@
|
||||
{
|
||||
}
|
||||
|
||||
public void ModifyClippingIntersect(ClippingRule clippingRule)
|
||||
public void ModifyClippingIntersect(FillingRule clippingRule)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -555,14 +555,14 @@
|
||||
TextMatrices.TextMatrix = newMatrix;
|
||||
}
|
||||
|
||||
public void ModifyClippingIntersect(ClippingRule clippingRule)
|
||||
public void ModifyClippingIntersect(FillingRule clippingRule)
|
||||
{
|
||||
if (CurrentPath == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentPath.SetClipping(clippingRule);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -131,6 +131,6 @@
|
||||
/// <summary>
|
||||
/// Modify the clipping rule of the current path.
|
||||
/// </summary>
|
||||
void ModifyClippingIntersect(ClippingRule clippingRule);
|
||||
void ModifyClippingIntersect(FillingRule clippingRule);
|
||||
}
|
||||
}
|
@@ -29,7 +29,7 @@
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.ModifyClippingIntersect(PdfPig.Core.ClippingRule.EvenOdd);
|
||||
operationContext.ModifyClippingIntersect(PdfPig.Core.FillingRule.EvenOdd);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@@ -29,7 +29,7 @@
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
operationContext.ModifyClippingIntersect(PdfPig.Core.ClippingRule.NonZeroWinding);
|
||||
operationContext.ModifyClippingIntersect(PdfPig.Core.FillingRule.NonZeroWinding);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
Reference in New Issue
Block a user