diff --git a/src/ImageSharp/Drawing/Brushes/RecolorBrush.cs b/src/ImageSharp/Drawing/Brushes/RecolorBrush.cs
index 9e00e881ff..0452a3f015 100644
--- a/src/ImageSharp/Drawing/Brushes/RecolorBrush.cs
+++ b/src/ImageSharp/Drawing/Brushes/RecolorBrush.cs
@@ -15,9 +15,9 @@ namespace ImageSharp.Drawing.Brushes
///
/// Color of the source.
/// Color of the target.
- /// The threashold.
- public RecolorBrush(Color sourceColor, Color targetColor, float threashold)
- : base(sourceColor, targetColor, threashold)
+ /// The threshold.
+ public RecolorBrush(Color sourceColor, Color targetColor, float threshold)
+ : base(sourceColor, targetColor, threshold)
{
}
}
diff --git a/src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs b/src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs
index 534317aff3..35f72c5bfa 100644
--- a/src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs
+++ b/src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs
@@ -22,21 +22,21 @@ namespace ImageSharp.Drawing.Brushes
///
/// Color of the source.
/// Color of the target.
- /// The threashold as a value between 0 and 1.
- public RecolorBrush(TColor sourceColor, TColor targetColor, float threashold)
+ /// The threshold as a value between 0 and 1.
+ public RecolorBrush(TColor sourceColor, TColor targetColor, float threshold)
{
this.SourceColor = sourceColor;
- this.Threashold = threashold;
+ this.Threshold = threshold;
this.TargetColor = targetColor;
}
///
- /// Gets the threashold.
+ /// Gets the threshold.
///
///
- /// The threashold.
+ /// The threshold.
///
- public float Threashold { get; }
+ public float Threshold { get; }
///
/// Gets the source color.
@@ -57,7 +57,7 @@ namespace ImageSharp.Drawing.Brushes
///
public IBrushApplicator CreateApplicator(PixelAccessor sourcePixels, RectangleF region)
{
- return new RecolorBrushApplicator(sourcePixels, this.SourceColor, this.TargetColor, this.Threashold);
+ return new RecolorBrushApplicator(sourcePixels, this.SourceColor, this.TargetColor, this.Threshold);
}
///
@@ -69,10 +69,21 @@ namespace ImageSharp.Drawing.Brushes
/// The source pixel accessor.
///
private readonly PixelAccessor source;
+
+ ///
+ /// The source color.
+ ///
private readonly Vector4 sourceColor;
+
+ ///
+ /// The target color.
+ ///
private readonly Vector4 targetColor;
- private readonly float threashold;
- private readonly float totalDistance;
+
+ ///
+ /// The threshold.
+ ///
+ private readonly float threshold;
///
/// Initializes a new instance of the class.
@@ -80,20 +91,19 @@ namespace ImageSharp.Drawing.Brushes
/// The source pixels.
/// Color of the source.
/// Color of the target.
- /// The threashold .
- public RecolorBrushApplicator(PixelAccessor sourcePixels, TColor sourceColor, TColor targetColor, float threashold)
+ /// The threshold .
+ public RecolorBrushApplicator(PixelAccessor sourcePixels, TColor sourceColor, TColor targetColor, float threshold)
{
this.source = sourcePixels;
this.sourceColor = sourceColor.ToVector4();
this.targetColor = targetColor.ToVector4();
- // lets hack a min max extreams for a color space by letteing the IPackedPixle clamp our values to something in the correct spaces :)
+ // Lets hack a min max extreams for a color space by letteing the IPackedPixel clamp our values to something in the correct spaces :)
TColor maxColor = default(TColor);
maxColor.PackFromVector4(new Vector4(float.MaxValue));
TColor minColor = default(TColor);
minColor.PackFromVector4(new Vector4(float.MinValue));
- this.totalDistance = Vector4.DistanceSquared(maxColor.ToVector4(), minColor.ToVector4());
- this.threashold = this.totalDistance * threashold;
+ this.threshold = Vector4.DistanceSquared(maxColor.ToVector4(), minColor.ToVector4()) * threshold;
}
///
@@ -109,9 +119,9 @@ namespace ImageSharp.Drawing.Brushes
TColor result = this.source[(int)point.X, (int)point.Y];
Vector4 background = result.ToVector4();
float distance = Vector4.DistanceSquared(background, this.sourceColor);
- if (distance <= this.threashold)
+ if (distance <= this.threshold)
{
- var lerpAmount = (this.threashold - distance) / this.threashold;
+ var lerpAmount = (this.threshold - distance) / this.threshold;
Vector4 blended = Vector4BlendTransforms.PremultipliedLerp(background, this.targetColor, lerpAmount);
result.PackFromVector4(blended);
}