Class RecolorBrush
- Namespace
- SixLabors.ImageSharp.Drawing.Processing
- Assembly
- SixLabors.ImageSharp.Drawing.dll
Provides an implementation of a brush that can recolor an image. Pixels within Threshold of SourceColor are blended towards TargetColor, with the blend strength falling off as the color distance approaches the threshold.
public sealed class RecolorBrush : Brush, IEquatable<Brush>
- Inheritance
-
RecolorBrush
- Implements
- Inherited Members
Constructors
RecolorBrush(Color, Color, float)
Initializes a new instance of the RecolorBrush class.
public RecolorBrush(Color sourceColor, Color targetColor, float threshold)
Parameters
sourceColorColorThe color to match against existing pixels.
targetColorColorThe color to recolor matched pixels with.
thresholdfloatThe color-matching threshold as a value between 0 and 1.
Properties
SourceColor
Gets the color to match against existing pixels.
public Color SourceColor { get; }
Property Value
TargetColor
Gets the color to recolor matched pixels with.
public Color TargetColor { get; }
Property Value
Threshold
Gets the color-matching threshold as a value between 0 and 1.
public float Threshold { 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.