Browse Source

Another attempt at fixing Lerp.

Former-commit-id: 48f5e84d6b95756a125ec0ff3adce66530f8a277
Former-commit-id: cc600e84bb3e3a5ae3038811bc466f9b161e6ee8
Former-commit-id: ef0a7b1b98de88cb1ab51634aac379d0132039a2
pull/17/head
James Jackson-South 10 years ago
parent
commit
708bac6ce2
  1. 2
      src/ImageProcessor/Colors/Color.cs
  2. 8
      src/ImageProcessor/Filters/ColorMatrix/Polaroid.cs
  3. 2
      src/ImageProcessor/Filters/Glow.cs
  4. 2
      tests/ImageProcessor.Tests/Processors/Filters/FilterTests.cs
  5. 2
      tests/ImageProcessor.Tests/Processors/ProcessorTestBase.cs

2
src/ImageProcessor/Colors/Color.cs

@ -350,7 +350,7 @@ namespace ImageProcessor
{
amount = amount.Clamp(0f, 1f);
if (Math.Abs(from.A - 1) < Epsilon || Math.Abs(from.A) < Epsilon)
if (Math.Abs(from.A - 1) < Epsilon && Math.Abs(to.A - 1) < Epsilon)
{
return from + (to - from) * amount;
}

8
src/ImageProcessor/Filters/ColorMatrix/Polaroid.cs

@ -33,7 +33,13 @@ namespace ImageProcessor.Filters
protected override void AfterApply(ImageBase source, ImageBase target, Rectangle targetRectangle, Rectangle sourceRectangle)
{
new Vignette { Color = new Color(102 / 255f, 34 / 255f, 0) }.Apply(target, target, targetRectangle);
new Glow { Color = new Color(1, 153 / 255f, 102 / 255f, .7f) }.Apply(target, target, targetRectangle);
new Glow
{
Color = new Color(1, 153 / 255f, 102 / 255f),
RadiusX = target.Width / 4f,
RadiusY = target.Width / 4f
}
.Apply(target, target, targetRectangle);
}
}
}

2
src/ImageProcessor/Filters/Glow.cs

@ -49,7 +49,7 @@ namespace ImageProcessor.Filters
{
float distance = Vector2.Distance(centre, new Vector2(x, y));
Color sourceColor = target[x, y];
target[x, y] = Color.Lerp(sourceColor, glowColor, .334f * (1 - distance / maxDistance));
target[x, y] = Color.Lerp(sourceColor, glowColor, .5f * (1 - distance / maxDistance));
}
});
}

2
tests/ImageProcessor.Tests/Processors/Filters/FilterTests.cs

@ -45,7 +45,7 @@ namespace ImageProcessor.Tests
{ "Hue-180", new Hue(180) },
{ "Hue--180", new Hue(-180) },
{ "BoxBlur", new BoxBlur(10) },
{"Vignette", new Vignette()}
{ "Vignette", new Vignette()}
};
[Theory]

2
tests/ImageProcessor.Tests/Processors/ProcessorTestBase.cs

@ -23,7 +23,7 @@ namespace ImageProcessor.Tests
"TestImages/Formats/Jpg/Calliphora.jpg",
//"TestImages/Formats/Jpg/gamma_dalai_lama_gray.jpg", //Perf: Enable for local testing only
"TestImages/Formats/Bmp/Car.bmp",
//"TestImages/Formats/Png/blur.png", //Perf: Enable for local testing only
"TestImages/Formats/Png/blur.png", //Perf: Enable for local testing only
"TestImages/Formats/Png/splash.png",
"TestImages/Formats/Gif/rings.gif",
//"TestImages/Formats/Gif/giphy.gif" //Perf: Enable for local testing only

Loading…
Cancel
Save