mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-06-28 15:30:17 +08:00
Add SetStrokeDetails() and SetFillDetails() to PdfPath and tidy up ContentStreamProcessor
This commit is contained in:
parent
204f488ebf
commit
306642a234
@ -4,7 +4,6 @@ namespace UglyToad.PdfPig.Graphics
|
|||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Colors;
|
|
||||||
using Content;
|
using Content;
|
||||||
using Filters;
|
using Filters;
|
||||||
using Geometry;
|
using Geometry;
|
||||||
@ -212,7 +211,7 @@ namespace UglyToad.PdfPig.Graphics
|
|||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddCurrentSubpath() // Not an override
|
private void AddCurrentSubpath()
|
||||||
{
|
{
|
||||||
if (CurrentSubpath is null)
|
if (CurrentSubpath is null)
|
||||||
{
|
{
|
||||||
@ -385,16 +384,12 @@ namespace UglyToad.PdfPig.Graphics
|
|||||||
var currentState = GetCurrentState();
|
var currentState = GetCurrentState();
|
||||||
if (CurrentPath.IsStroked)
|
if (CurrentPath.IsStroked)
|
||||||
{
|
{
|
||||||
CurrentPath.LineDashPattern = currentState.LineDashPattern;
|
CurrentPath.SetStrokeDetails(currentState);
|
||||||
CurrentPath.StrokeColor = currentState.CurrentStrokingColor;
|
|
||||||
CurrentPath.LineWidth = currentState.LineWidth;
|
|
||||||
CurrentPath.LineCapStyle = currentState.CapStyle;
|
|
||||||
CurrentPath.LineJoinStyle = currentState.JoinStyle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurrentPath.IsFilled)
|
if (CurrentPath.IsFilled)
|
||||||
{
|
{
|
||||||
CurrentPath.FillColor = currentState.CurrentNonStrokingColor;
|
CurrentPath.SetFillDetails(currentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ParsingOptions.ClipPaths)
|
if (ParsingOptions.ClipPaths)
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
using UglyToad.PdfPig.Graphics.Core;
|
using UglyToad.PdfPig.Graphics.Core;
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// <para>A path shall be composed of straight and curved line segments, which may connect to one another or may be disconnected.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PdfPath : List<PdfSubpath>
|
public class PdfPath : List<PdfSubpath>
|
||||||
@ -29,7 +31,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The fill color.
|
/// The fill color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IColor? FillColor { get; internal set; }
|
public IColor? FillColor { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns true if the path is stroked.
|
/// Returns true if the path is stroked.
|
||||||
@ -39,31 +41,31 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The stroke color.
|
/// The stroke color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IColor? StrokeColor { get; internal set; }
|
public IColor? StrokeColor { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Thickness in user space units of path to be stroked.
|
/// Thickness in user space units of path to be stroked.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double LineWidth { get; internal set; }
|
public double LineWidth { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The pattern to be used for stroked lines.
|
/// The pattern to be used for stroked lines.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LineDashPattern? LineDashPattern { get; internal set; }
|
public LineDashPattern? LineDashPattern { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The cap style to be used for stroked lines.
|
/// The cap style to be used for stroked lines.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LineCapStyle LineCapStyle { get; internal set; }
|
public LineCapStyle LineCapStyle { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The join style to be used for stroked lines.
|
/// The join style to be used for stroked lines.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LineJoinStyle LineJoinStyle { get; internal set; }
|
public LineJoinStyle LineJoinStyle { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the clipping mode for this path and IsClipping to true.
|
/// Set the clipping mode for this path and <c>IsClipping</c> to <c>true</c>.
|
||||||
/// <para>IsFilled and IsStroked flags will be set to false.</para>
|
/// <para><c>IsFilled</c> and <c>IsStroked</c> flags will be set to <c>false</c>.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetClipping(FillingRule fillingRule)
|
public void SetClipping(FillingRule fillingRule)
|
||||||
{
|
{
|
||||||
@ -74,7 +76,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public void SetFilled(FillingRule fillingRule)
|
public void SetFilled(FillingRule fillingRule)
|
||||||
{
|
{
|
||||||
@ -83,13 +85,35 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set IsStroked to true.
|
/// Set <c>IsStroked</c> to <c>true</c>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetStroked()
|
public void SetStroked()
|
||||||
{
|
{
|
||||||
IsStroked = true;
|
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>
|
/// <summary>
|
||||||
/// Create a clone with no Subpaths.
|
/// Create a clone with no Subpaths.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user