// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. namespace SixLabors.ImageSharp.Drawing.Processing { /// /// Defines a pen that can apply a pattern to a line with a set brush and thickness /// /// /// The pattern will be in to the form of /// /// new float[]{ 1f, 2f, 0.5f} /// /// this will be converted into a pattern that is 3.5 times longer that the width with 3 sections. /// /// Section 1 will be width long (making a square) and will be filled by the brush. /// Section 2 will be width * 2 long and will be empty. /// Section 3 will be width/2 long and will be filled. /// /// The pattern will immediately repeat without gap. /// public class PatternPen : Pen { /// /// Initializes a new instance of the class. /// /// The color. /// The stroke pattern. public PatternPen(Color color, float[] strokePattern) : base(new SolidBrush(color), 1, strokePattern) { } /// /// Initializes a new instance of the class. /// /// The color. /// The stroke width in the path's local coordinate space before any drawing transform is applied. /// The stroke pattern. public PatternPen(Color color, float strokeWidth, float[] strokePattern) : base(new SolidBrush(color), strokeWidth, strokePattern) { } /// /// Initializes a new instance of the class. /// /// The brush used to fill the stroke outline. /// The stroke width in the path's local coordinate space before any drawing transform is applied. /// The stroke pattern. public PatternPen(Brush strokeFill, float strokeWidth, float[] strokePattern) : base(strokeFill, strokeWidth, strokePattern) { } /// /// Initializes a new instance of the class. /// /// The pen options. public PatternPen(PenOptions options) : base(options) { } /// public override bool Equals(Pen? other) { if (other is PatternPen) { return base.Equals(other); } return false; } /// public override IPath GeneratePath(IPath path, float strokeWidth) => path.GenerateOutline(strokeWidth, this.StrokePattern.Span, this.StrokeOptions); } }