make Clipping internal

do not throw errors when CurrentPath is null
modify tests to match
This commit is contained in:
BobLd
2020-04-02 18:06:07 +01:00
committed by Eliot Jones
parent 51165dc11a
commit 064fa4922a
6 changed files with 37 additions and 34 deletions

View File

@@ -4,7 +4,7 @@
using UglyToad.PdfPig.Core;
using Xunit;
public class PdfPathTests
public class PdfSubpathTests
{
private static readonly DoubleComparer DoubleComparer = new DoubleComparer(3);
private static readonly DoubleComparer PreciseDoubleComparer = new DoubleComparer(6);
@@ -373,8 +373,11 @@
public void IsCounterClockwise(double[][] source, bool expected)
{
PdfSubpath pdfPath = new PdfSubpath();
foreach (var point in source)
pdfPath.MoveTo(source[0][0], source[0][1]);
for (int i = 1; i < source.Length; i++)
{
var point = source[i];
pdfPath.LineTo(point[0], point[1]);
}
pdfPath.LineTo(source[0][0], source[0][1]); // close path

View File

@@ -63,7 +63,7 @@
foreach (var charString in result.CharStrings.CharStrings)
{
Assert.True(result.CharStrings.TryGenerate(charString.Key, out var path));
builder.AppendLine(path.ToFullSvg(double.NaN)); // TODO
builder.AppendLine(path.ToFullSvg(0));
}
builder.Append("</body></html>");

View File

@@ -6,7 +6,7 @@
using Xunit;
using static UglyToad.PdfPig.Core.PdfSubpath;
public class PdfPathLineTests
public class PdfSubpathLineTests
{
private static readonly DoubleComparer DoubleComparer = new DoubleComparer(3);
private static readonly DoubleComparer PreciseDoubleComparer = new DoubleComparer(6);

View File

@@ -92,6 +92,7 @@
"UglyToad.PdfPig.Geometry.GeometryExtensions",
"UglyToad.PdfPig.Graphics.Colors.CMYKColor",
"UglyToad.PdfPig.Graphics.Colors.ColorSpace",
"UglyToad.PdfPig.Graphics.PdfPath",
"UglyToad.PdfPig.Graphics.Colors.ColorSpaceExtensions",
"UglyToad.PdfPig.Graphics.Colors.ColorSpaceFamily",
"UglyToad.PdfPig.Graphics.Colors.GrayColor",
@@ -110,15 +111,16 @@
"UglyToad.PdfPig.Graphics.Operations.ClippingPaths.ModifyClippingByNonZeroWindingIntersect",
"UglyToad.PdfPig.Graphics.Operations.Compatibility.BeginCompatibilitySection",
"UglyToad.PdfPig.Graphics.Operations.Compatibility.EndCompatibilitySection",
"UglyToad.PdfPig.Graphics.Operations.CloseAndStrokePath",
"UglyToad.PdfPig.Graphics.Operations.CloseFillPathEvenOddRuleAndStroke",
"UglyToad.PdfPig.Graphics.Operations.CloseFillPathNonZeroWindingAndStroke",
"UglyToad.PdfPig.Graphics.Operations.EndPath",
"UglyToad.PdfPig.Graphics.Operations.FillPathEvenOddRule",
"UglyToad.PdfPig.Graphics.Operations.FillPathEvenOddRuleAndStroke",
"UglyToad.PdfPig.Graphics.Operations.FillPathNonZeroWinding",
"UglyToad.PdfPig.Graphics.Operations.FillPathNonZeroWindingAndStroke",
"UglyToad.PdfPig.Graphics.Operations.FillPathNonZeroWindingCompatibility",
"UglyToad.PdfPig.Graphics.Operations.PathPainting.CloseAndStrokePath",
"UglyToad.PdfPig.Graphics.Operations.PathPainting.CloseFillPathEvenOddRuleAndStroke",
"UglyToad.PdfPig.Graphics.Operations.PathPainting.CloseFillPathNonZeroWindingAndStroke",
"UglyToad.PdfPig.Graphics.Operations.PathPainting.EndPath",
"UglyToad.PdfPig.Graphics.Operations.PathPainting.FillPathEvenOddRule",
"UglyToad.PdfPig.Graphics.Operations.PathPainting.FillPathEvenOddRuleAndStroke",
"UglyToad.PdfPig.Graphics.Operations.PathPainting.FillPathNonZeroWinding",
"UglyToad.PdfPig.Graphics.Operations.PathPainting.FillPathNonZeroWindingAndStroke",
"UglyToad.PdfPig.Graphics.Operations.PathPainting.FillPathNonZeroWindingCompatibility",
"UglyToad.PdfPig.Graphics.Operations.PathPainting.StrokePath",
"UglyToad.PdfPig.Graphics.Operations.General.SetColorRenderingIntent",
"UglyToad.PdfPig.Graphics.Operations.General.SetFlatnessTolerance",
"UglyToad.PdfPig.Graphics.Operations.General.SetLineCap",
@@ -160,7 +162,6 @@
"UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.Pop",
"UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.Push",
"UglyToad.PdfPig.Graphics.Operations.SpecialGraphicsState.SetGraphicsStateParametersFromDictionary",
"UglyToad.PdfPig.Graphics.Operations.StrokePath",
"UglyToad.PdfPig.Graphics.Operations.TextObjects.BeginText",
"UglyToad.PdfPig.Graphics.Operations.TextObjects.EndText",
"UglyToad.PdfPig.Graphics.Operations.TextPositioning.MoveToNextLine",

View File

@@ -5,7 +5,7 @@
/// <summary>
///
/// </summary>
public static class Clipping
internal static class Clipping
{
const double factor = 10_000.0;

View File

@@ -451,8 +451,7 @@
{
if (CurrentPath == null)
{
throw new ArgumentException("StrokePath(null)");
//return;
return;
}
CurrentPath.SetStroked();
@@ -469,8 +468,7 @@
{
if (CurrentPath == null)
{
throw new ArgumentException("FillPath(null)");
//return;
return;
}
CurrentPath.SetFilled(fillingRule);
@@ -487,8 +485,7 @@
{
if (CurrentPath == null)
{
throw new ArgumentException("FillStrokePath(null)");
//return;
return;
}
CurrentPath.SetFilled(fillingRule);
@@ -514,7 +511,7 @@
{
if (!clipPaths)
{
// if we don't clip paths, add clipping paths
// if we don't clip paths, add clipping path to paths
paths.Add(CurrentPath);
markedContentStack.AddPath(CurrentPath);
}
@@ -573,26 +570,28 @@
{
if (CurrentPath == null)
{
throw new ArgumentException("ModifyClippingIntersect(null)");
return;
}
AddCurrentSubpath();
CurrentPath.SetClipping(clippingRule);
if (clipPaths)
{
var currentClipping = GetCurrentState().CurrentClippingPath;
currentClipping.SetClipping(clippingRule);
var newClippings = CurrentPath.Clip(currentClipping);
if (newClippings == null)
{
Console.WriteLine("ContentStreamProcessor.ModifyClippingIntersect(): Warning, empty clipping path found... Clipping path not updated.");
log.Warn("ModifyClippingIntersect(): Warning, empty clipping path found... Clipping path not updated.");
log.Warn("Empty clipping path found. Clipping path not updated.");
}
else
{
GetCurrentState().CurrentClippingPath = newClippings;
}
}
}
public void SetNamedGraphicsState(NameToken stateName)
{