Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/UglyToad.PdfPig/Graphics/ContentStreamProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace UglyToad.PdfPig.Graphics
{
using System;
using System.Collections.Generic;
using Colors;
using Content;
using Filters;
using Geometry;
Expand Down Expand Up @@ -212,7 +211,7 @@ public override void BeginSubpath()
return point;
}

public void AddCurrentSubpath() // Not an override
private void AddCurrentSubpath()
{
if (CurrentSubpath is null)
{
Expand Down Expand Up @@ -385,16 +384,12 @@ public override void ClosePath()
var currentState = GetCurrentState();
if (CurrentPath.IsStroked)
{
CurrentPath.LineDashPattern = currentState.LineDashPattern;
CurrentPath.StrokeColor = currentState.CurrentStrokingColor;
CurrentPath.LineWidth = currentState.LineWidth;
CurrentPath.LineCapStyle = currentState.CapStyle;
CurrentPath.LineJoinStyle = currentState.JoinStyle;
CurrentPath.SetStrokeDetails(currentState);
}

if (CurrentPath.IsFilled)
{
CurrentPath.FillColor = currentState.CurrentNonStrokingColor;
CurrentPath.SetFillDetails(currentState);
}

if (ParsingOptions.ClipPaths)
Expand Down
46 changes: 35 additions & 11 deletions src/UglyToad.PdfPig/Graphics/PdfPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
using UglyToad.PdfPig.Graphics.Core;

/// <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.
/// 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>
Expand All @@ -29,7 +31,7 @@ public class PdfPath : List<PdfSubpath>
/// <summary>
/// The fill color.
/// </summary>
public IColor? FillColor { get; internal set; }
public IColor? FillColor { get; private set; }

/// <summary>
/// Returns true if the path is stroked.
Expand All @@ -39,31 +41,31 @@ public class PdfPath : List<PdfSubpath>
/// <summary>
/// The stroke color.
/// </summary>
public IColor? StrokeColor { get; internal set; }
public IColor? StrokeColor { get; private set; }

/// <summary>
/// Thickness in user space units of path to be stroked.
/// </summary>
public double LineWidth { get; internal set; }
public double LineWidth { get; private set; }

/// <summary>
/// The pattern to be used for stroked lines.
/// </summary>
public LineDashPattern? LineDashPattern { get; internal set; }
public LineDashPattern? LineDashPattern { get; private set; }

/// <summary>
/// The cap style to be used for stroked lines.
/// </summary>
public LineCapStyle LineCapStyle { get; internal set; }
public LineCapStyle LineCapStyle { get; private set; }

/// <summary>
/// The join style to be used for stroked lines.
/// </summary>
public LineJoinStyle LineJoinStyle { get; internal set; }
public LineJoinStyle LineJoinStyle { get; private set; }

/// <summary>
/// Set the clipping mode for this path and IsClipping to true.
/// <para>IsFilled and IsStroked flags will be set to false.</para>
/// Set the clipping mode for this path and <c>IsClipping</c> to <c>true</c>.
/// <para><c>IsFilled</c> and <c>IsStroked</c> flags will be set to <c>false</c>.</para>
/// </summary>
public void SetClipping(FillingRule fillingRule)
{
Expand All @@ -74,7 +76,7 @@ public void SetClipping(FillingRule fillingRule)
}

/// <summary>
/// Set the filling rule for this path and IsFilled to true.
/// Set the filling rule for this path and <c>IsFilled</c> to <c>true</c>.
/// </summary>
public void SetFilled(FillingRule fillingRule)
{
Expand All @@ -83,13 +85,35 @@ public void SetFilled(FillingRule fillingRule)
}

/// <summary>
/// Set IsStroked to true.
/// Set <c>IsStroked</c> to <c>true</c>.
/// </summary>
public void SetStroked()
{
IsStroked = true;
}

/// <summary>
/// Set the path stroke details, i.e. <c>LineDashPattern</c>, <c>StrokeColor</c>, <c>LineWidth</c>, <c>LineCapStyle</c> and <c>LineJoinStyle</c>.
/// </summary>
/// <param name="graphicsState">The current graphics state.</param>
public void SetStrokeDetails(CurrentGraphicsState graphicsState)
{
LineDashPattern = graphicsState.LineDashPattern;
StrokeColor = graphicsState.CurrentStrokingColor;
LineWidth = graphicsState.LineWidth;
LineCapStyle = graphicsState.CapStyle;
LineJoinStyle = graphicsState.JoinStyle;
}

/// <summary>
/// Set the path fill details, i.e. <c>FillColor</c>.
/// </summary>
/// <param name="graphicsState">The current graphics state.</param>
public void SetFillDetails(CurrentGraphicsState graphicsState)
{
FillColor = graphicsState.CurrentNonStrokingColor;
}

/// <summary>
/// Create a clone with no Subpaths.
/// </summary>
Expand Down
Loading