Class PatternBrush
- Namespace
- SixLabors.ImageSharp.Drawing.Processing
- Assembly
- SixLabors.ImageSharp.Drawing.dll
Provides an implementation of a pattern brush for painting patterns.
public sealed class PatternBrush : Brush, IEquatable<Brush>
- Inheritance
-
PatternBrush
- Implements
- Inherited Members
Remarks
The patterns that are used to create a custom pattern brush are made up of a repeating matrix of flags, where each flag denotes whether to draw the foreground color or the background color. so to create a new bool[,] with your flags
For example if you wanted to create a diagonal line that repeat every 4 pixels you would use a pattern like so 1000 0100 0010 0001
or you want a horizontal stripe which is 3 pixels apart you would use a pattern like 1 0 0
Constructors
PatternBrush(Color, Color, bool[,])
Initializes a new instance of the PatternBrush class.
public PatternBrush(Color foreColor, Color backColor, bool[,] pattern)
Parameters
Properties
Pattern
Gets the pattern color matrix.
public DenseMatrix<Color> Pattern { get; }
Property Value
Methods
CreateRenderer<TPixel>(Configuration, GraphicsOptions, int, RectangleF)
Creates the prepared execution object for this brush.
public override BrushRenderer<TPixel> CreateRenderer<TPixel>(Configuration configuration, GraphicsOptions options, int canvasWidth, RectangleF region) where TPixel : unmanaged, IPixel<TPixel>
Parameters
configurationConfigurationThe configuration instance to use when performing operations.
optionsGraphicsOptionsThe graphic options.
canvasWidthintThe canvas width for the current render pass.
regionRectangleFThe region the brush will be applied to.
Returns
- BrushRenderer<TPixel>
The BrushRenderer<TPixel> for this brush.
Type Parameters
TPixelThe pixel type.
Remarks
The region when being applied to things like shapes would usually be the
bounding box of the shape not necessarily the bounds of the whole image.
Equals(Brush?)
Indicates whether the current object is equal to another object of the same type.
public override bool Equals(Brush? other)
Parameters
otherBrushAn object to compare with this object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.