Skip to content

Commit 7a6e64d

Browse files
committed
Expose JointStyle and EndCapStyle on IPen
1 parent 0e586c3 commit 7a6e64d

5 files changed

Lines changed: 31 additions & 2 deletions

File tree

src/ImageSharp.Drawing/Processing/IPen.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,15 @@ public interface IPen
2424
/// Gets the stoke pattern.
2525
/// </summary>
2626
ReadOnlySpan<float> StrokePattern { get; }
27+
28+
/// <summary>
29+
/// Gets the stroke joint style
30+
/// </summary>
31+
public JointStyle StrokeJoint { get; }
32+
33+
/// <summary>
34+
/// Gets the endcap style
35+
/// </summary>
36+
public EndCapStyle EndCap { get; }
2737
}
2838
}

src/ImageSharp.Drawing/Processing/Pen.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,11 @@ public Pen(IBrush brush, float width)
7474

7575
/// <inheritdoc/>
7676
public ReadOnlySpan<float> StrokePattern => this.pattern;
77+
78+
/// <inheritdoc/>
79+
public JointStyle StrokeJoint { get; }
80+
81+
/// <inheritdoc/>
82+
public EndCapStyle EndCap { get; }
7783
}
7884
}

src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawPathProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuratio
4949
// The global transform is applied in the FillPathProcessor.
5050
IPath outline = this.Path
5151
.Transform(Matrix3x2.CreateTranslation(0.5F, 0.5F))
52-
.GenerateOutline(this.Pen.StrokeWidth, this.Pen.StrokePattern);
52+
.GenerateOutline(this.Pen.StrokeWidth, this.Pen.StrokePattern, this.Pen.StrokeJoint, this.Pen.EndCap);
5353

5454
return new FillPathProcessor(this.Options, this.Pen.StrokeFill, outline)
5555
.CreatePixelSpecificProcessor(configuration, source, sourceRectangle);

src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public void EndGlyph()
306306
}
307307
else
308308
{
309-
path = path.GenerateOutline(this.Pen.StrokeWidth, this.Pen.StrokePattern);
309+
path = path.GenerateOutline(this.Pen.StrokeWidth, this.Pen.StrokePattern, this.Pen.StrokeJoint, this.Pen.EndCap);
310310
}
311311

312312
renderData.OutlineMap = this.Render(path);

src/ImageSharp.Drawing/Shapes/OutlinePathExtensions.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ public static IPath GenerateOutline(this IPath path, float width, float[] patter
6161
public static IPath GenerateOutline(this IPath path, float width, ReadOnlySpan<float> pattern, bool startOff)
6262
=> GenerateOutline(path, width, pattern, startOff, JointStyle.Square, EndCapStyle.Butt);
6363

64+
/// <summary>
65+
/// Generates a outline of the path with alternating on and off segments based on the pattern.
66+
/// </summary>
67+
/// <param name="path">the path to outline</param>
68+
/// <param name="width">The final width outline</param>
69+
/// <param name="pattern">The pattern made of multiples of the width.</param>
70+
/// <param name="jointStyle">The style to render the joints.</param>
71+
/// <param name="patternSectionCapStyle">The style to render between sections of the specified pattern.</param>
72+
/// <returns>A new path representing the outline.</returns>
73+
/// <exception cref="ClipperException">Couldn't calculate offset.</exception>
74+
public static IPath GenerateOutline(this IPath path, float width, ReadOnlySpan<float> pattern, JointStyle jointStyle, EndCapStyle patternSectionCapStyle)
75+
=> GenerateOutline(path, width, pattern, false, jointStyle, patternSectionCapStyle);
76+
6477
/// <summary>
6578
/// Generates a outline of the path with alternating on and off segments based on the pattern.
6679
/// </summary>

0 commit comments

Comments
 (0)