Skip to content

Commit 6ef0a7b

Browse files
Non-nullable stroke pattern.
1 parent 9b9a109 commit 6ef0a7b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/ImageSharp.Drawing/Processing/Pen.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Drawing.Processing;
2121
/// </remarks>
2222
public abstract class Pen : IEquatable<Pen>
2323
{
24-
private readonly float[]? pattern;
24+
private readonly float[] pattern;
2525

2626
/// <summary>
2727
/// Initializes a new instance of the <see cref="Pen"/> class.
@@ -50,7 +50,9 @@ protected Pen(Brush strokeFill, float strokeWidth)
5050
/// <param name="strokePattern">The stroke pattern.</param>
5151
protected Pen(Brush strokeFill, float strokeWidth, float[] strokePattern)
5252
{
53+
Guard.NotNull(strokeFill, nameof(strokeFill));
5354
Guard.MustBeGreaterThan(strokeWidth, 0, nameof(strokeWidth));
55+
Guard.NotNull(strokePattern, nameof(strokePattern));
5456

5557
this.StrokeFill = strokeFill;
5658
this.StrokeWidth = strokeWidth;
@@ -115,7 +117,5 @@ public virtual bool Equals(Pen? other)
115117

116118
/// <inheritdoc/>
117119
public override int GetHashCode()
118-
119-
// TODO: StrokePattern should be part of the hash-code.
120-
=> HashCode.Combine(this.StrokeWidth, this.JointStyle, this.EndCapStyle, this.StrokeFill);
120+
=> HashCode.Combine(this.StrokeWidth, this.JointStyle, this.EndCapStyle, this.StrokeFill, this.pattern);
121121
}

src/ImageSharp.Drawing/Processing/PenOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public PenOptions(Brush strokeFill, float strokeWidth, float[]? strokePattern)
5050

5151
this.StrokeFill = strokeFill;
5252
this.StrokeWidth = strokeWidth;
53-
this.StrokePattern = strokePattern;
53+
this.StrokePattern = strokePattern ?? Pens.EmptyPattern;
5454
this.JointStyle = JointStyle.Square;
5555
this.EndCapStyle = EndCapStyle.Butt;
5656
}
@@ -68,7 +68,7 @@ public PenOptions(Brush strokeFill, float strokeWidth, float[]? strokePattern)
6868
/// <summary>
6969
/// Gets the stroke pattern.
7070
/// </summary>
71-
public float[]? StrokePattern { get; }
71+
public float[] StrokePattern { get; }
7272

7373
/// <summary>
7474
/// Gets or sets the joint style.

0 commit comments

Comments
 (0)