Browse Source

Normalize GraphicsOptions parameter position

af/merge-core
James Jackson-South 7 years ago
parent
commit
058836d0c9
  1. 4
      src/ImageSharp.Drawing/Processing/BrushApplicator.cs
  2. 14
      src/ImageSharp.Drawing/Processing/EllipticGradientBrush.cs
  3. 8
      src/ImageSharp.Drawing/Processing/Extensions/FillRegionExtensions.cs
  4. 12
      src/ImageSharp.Drawing/Processing/GradientBrush.cs
  5. 6
      src/ImageSharp.Drawing/Processing/IBrush.cs
  6. 16
      src/ImageSharp.Drawing/Processing/ImageBrush.cs
  7. 24
      src/ImageSharp.Drawing/Processing/LinearGradientBrush.cs
  8. 14
      src/ImageSharp.Drawing/Processing/PathGradientBrush.cs
  9. 16
      src/ImageSharp.Drawing/Processing/PatternBrush.cs
  10. 4
      src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs
  11. 4
      src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor{TPixel}.cs
  12. 4
      src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor.cs
  13. 2
      src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs
  14. 2
      src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs
  15. 16
      src/ImageSharp.Drawing/Processing/RadialGradientBrush.cs
  16. 16
      src/ImageSharp.Drawing/Processing/RecolorBrush.cs
  17. 14
      src/ImageSharp.Drawing/Processing/SolidBrush.cs
  18. 4
      src/ImageSharp/Processing/Extensions/BackgroundColorExtensions.cs
  19. 8
      src/ImageSharp/Processing/Extensions/GlowExtensions.cs
  20. 8
      src/ImageSharp/Processing/Extensions/VignetteExtensions.cs
  21. 4
      src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs
  22. 14
      src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs
  23. 10
      src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs
  24. 6
      tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs

4
src/ImageSharp.Drawing/Processing/BrushApplicator.cs

@ -21,9 +21,9 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="BrushApplicator{TPixel}"/> class.
/// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="target">The target.</param>
/// <param name="options">The options.</param>
internal BrushApplicator(Configuration configuration, ImageFrame<TPixel> target, GraphicsOptions options)
internal BrushApplicator(Configuration configuration, GraphicsOptions options, ImageFrame<TPixel> target)
{
this.Configuration = configuration;
this.Target = target;

14
src/ImageSharp.Drawing/Processing/EllipticGradientBrush.cs

@ -48,18 +48,18 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc />
public override BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
RectangleF region,
GraphicsOptions options) =>
RectangleF region) =>
new RadialGradientBrushApplicator<TPixel>(
configuration,
options,
source,
this.center,
this.referenceAxisEnd,
this.axisRatio,
this.ColorStops,
this.RepetitionMode,
options);
this.RepetitionMode);
/// <inheritdoc />
private sealed class RadialGradientBrushApplicator<TPixel> : GradientBrushApplicator<TPixel>
@ -100,14 +100,14 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="options">The graphics options.</param>
public RadialGradientBrushApplicator(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> target,
PointF center,
PointF referenceAxisEnd,
float axisRatio,
ColorStop[] colorStops,
GradientRepetitionMode repetitionMode,
GraphicsOptions options)
: base(configuration, target, colorStops, repetitionMode, options)
GradientRepetitionMode repetitionMode)
: base(configuration, options, target, colorStops, repetitionMode)
{
this.center = center;
this.referenceAxisEnd = referenceAxisEnd;

8
src/ImageSharp.Drawing/Processing/Extensions/FillRegionExtensions.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Primitives;
@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Processing
GraphicsOptions options,
IBrush brush,
Region region) =>
source.ApplyProcessor(new FillRegionProcessor(brush, region, options));
source.ApplyProcessor(new FillRegionProcessor(options, brush, region));
/// <summary>
/// Flood fills the image with the specified brush.
@ -90,6 +90,6 @@ namespace SixLabors.ImageSharp.Processing
this IImageProcessingContext source,
GraphicsOptions options,
IBrush brush) =>
source.ApplyProcessor(new FillProcessor(brush, options));
source.ApplyProcessor(new FillProcessor(options, brush));
}
}
}

12
src/ImageSharp.Drawing/Processing/GradientBrush.cs

@ -37,9 +37,9 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc />
public abstract BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
RectangleF region,
GraphicsOptions options)
RectangleF region)
where TPixel : struct, IPixel<TPixel>;
/// <summary>
@ -58,17 +58,17 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="GradientBrushApplicator{TPixel}"/> class.
/// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="target">The target image.</param>
/// <param name="colorStops">An array of color stops sorted by their position.</param>
/// <param name="repetitionMode">Defines if and how the gradient should be repeated.</param>
/// <param name="options">The graphics options.</param>
protected GradientBrushApplicator(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> target,
ColorStop[] colorStops,
GradientRepetitionMode repetitionMode,
GraphicsOptions options)
: base(configuration, target, options)
GradientRepetitionMode repetitionMode)
: base(configuration, options, target)
{
this.colorStops = colorStops; // TODO: requires colorStops to be sorted by position - should that be checked?
this.repetitionMode = repetitionMode;

6
src/ImageSharp.Drawing/Processing/IBrush.cs

@ -20,9 +20,9 @@ namespace SixLabors.ImageSharp.Processing
/// </summary>
/// <typeparam name="TPixel">The pixel type.</typeparam>
/// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphic options.</param>
/// <param name="source">The source image.</param>
/// <param name="region">The region the brush will be applied to.</param>
/// <param name="options">The graphic options</param>
/// <returns>
/// The <see cref="BrushApplicator{TPixel}"/> for this brush.
/// </returns>
@ -32,9 +32,9 @@ namespace SixLabors.ImageSharp.Processing
/// </remarks>
BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
RectangleF region,
GraphicsOptions options)
RectangleF region)
where TPixel : struct, IPixel<TPixel>;
}
}

16
src/ImageSharp.Drawing/Processing/ImageBrush.cs

@ -32,19 +32,19 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
RectangleF region,
GraphicsOptions options)
RectangleF region)
where TPixel : struct, IPixel<TPixel>
{
if (this.image is Image<TPixel> specificImage)
{
return new ImageBrushApplicator<TPixel>(configuration, source, specificImage, region, false, options);
return new ImageBrushApplicator<TPixel>(configuration, options, source, specificImage, region, false);
}
specificImage = this.image.CloneAs<TPixel>();
return new ImageBrushApplicator<TPixel>(configuration, source, specificImage, region, true, options);
return new ImageBrushApplicator<TPixel>(configuration, options, source, specificImage, region, true);
}
/// <summary>
@ -85,19 +85,19 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="ImageBrushApplicator{TPixel}"/> class.
/// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="target">The target image.</param>
/// <param name="image">The image.</param>
/// <param name="region">The region.</param>
/// <param name="shouldDisposeImage">Whether to dispose the image on disposal of the applicator.</param>
/// <param name="options">The graphics options.</param>
public ImageBrushApplicator(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> target,
Image<TPixel> image,
RectangleF region,
bool shouldDisposeImage,
GraphicsOptions options)
: base(configuration, target, options)
bool shouldDisposeImage)
: base(configuration, options, target)
{
this.sourceImage = image;
this.sourceFrame = image.Frames.RootFrame;

24
src/ImageSharp.Drawing/Processing/LinearGradientBrush.cs

@ -40,17 +40,17 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc />
public override BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
RectangleF region,
GraphicsOptions options) =>
RectangleF region) =>
new LinearGradientBrushApplicator<TPixel>(
configuration,
options,
source,
this.p1,
this.p2,
this.ColorStops,
this.RepetitionMode,
options);
this.RepetitionMode);
/// <summary>
/// The linear gradient brush applicator.
@ -96,21 +96,21 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="LinearGradientBrushApplicator{TPixel}" /> class.
/// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="source">The source image.</param>
/// <param name="start">start point of the gradient.</param>
/// <param name="end">end point of the gradient.</param>
/// <param name="colorStops">tuple list of colors and their respective position between 0 and 1 on the line.</param>
/// <param name="repetitionMode">defines how the gradient colors are repeated.</param>
/// <param name="options">the graphics options.</param>
/// <param name="start">The start point of the gradient.</param>
/// <param name="end">The end point of the gradient.</param>
/// <param name="colorStops">A tuple list of colors and their respective position between 0 and 1 on the line.</param>
/// <param name="repetitionMode">Defines how the gradient colors are repeated.</param>
public LinearGradientBrushApplicator(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
PointF start,
PointF end,
ColorStop[] colorStops,
GradientRepetitionMode repetitionMode,
GraphicsOptions options)
: base(configuration, source, colorStops, repetitionMode, options)
GradientRepetitionMode repetitionMode)
: base(configuration, options, source, colorStops, repetitionMode)
{
this.start = start;
this.end = end;

14
src/ImageSharp.Drawing/Processing/PathGradientBrush.cs

@ -84,12 +84,12 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
RectangleF region,
GraphicsOptions options)
RectangleF region)
where TPixel : struct, IPixel<TPixel>
{
return new PathGradientBrushApplicator<TPixel>(configuration, source, this.edges, this.centerColor, options);
return new PathGradientBrushApplicator<TPixel>(configuration, options, source, this.edges, this.centerColor);
}
private static Color CalculateCenterColor(Color[] colors)
@ -201,17 +201,17 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="PathGradientBrushApplicator{TPixel}"/> class.
/// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="source">The source image.</param>
/// <param name="edges">Edges of the polygon.</param>
/// <param name="centerColor">Color at the center of the gradient area to which the other colors converge.</param>
/// <param name="options">The graphics options.</param>
public PathGradientBrushApplicator(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
IList<Edge> edges,
Color centerColor,
GraphicsOptions options)
: base(configuration, source, options)
Color centerColor)
: base(configuration, options, source)
{
this.edges = edges;

16
src/ImageSharp.Drawing/Processing/PatternBrush.cs

@ -93,15 +93,15 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
RectangleF region,
GraphicsOptions options)
RectangleF region)
where TPixel : struct, IPixel<TPixel> =>
new PatternBrushApplicator<TPixel>(
configuration,
options,
source,
this.pattern.ToPixelMatrix<TPixel>(configuration),
options);
this.pattern.ToPixelMatrix<TPixel>(configuration));
/// <summary>
/// The pattern brush applicator.
@ -118,15 +118,15 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="PatternBrushApplicator{TPixel}" /> class.
/// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="source">The source image.</param>
/// <param name="pattern">The pattern.</param>
/// <param name="options">The graphics options.</param>
public PatternBrushApplicator(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
in DenseMatrix<TPixel> pattern,
GraphicsOptions options)
: base(configuration, source, options)
in DenseMatrix<TPixel> pattern)
: base(configuration, options, source)
{
this.pattern = pattern;
}

4
src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs

@ -15,9 +15,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
/// <summary>
/// Initializes a new instance of the <see cref="FillProcessor"/> class.
/// </summary>
/// <param name="brush">The brush to use for filling.</param>
/// <param name="options">The <see cref="GraphicsOptions"/> defining how to blend the brush pixels over the image pixels.</param>
public FillProcessor(IBrush brush, GraphicsOptions options)
/// <param name="brush">The brush to use for filling.</param>
public FillProcessor(GraphicsOptions options, IBrush brush)
{
this.Brush = brush;
this.Options = options;

4
src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor{TPixel}.cs

@ -85,9 +85,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
using (IMemoryOwner<float> amount = source.MemoryAllocator.Allocate<float>(width))
using (BrushApplicator<TPixel> applicator = brush.CreateApplicator(
configuration,
options,
source,
sourceRectangle,
options))
sourceRectangle))
{
amount.Memory.Span.Fill(1f);

4
src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor.cs

@ -16,10 +16,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
/// <summary>
/// Initializes a new instance of the <see cref="FillRegionProcessor" /> class.
/// </summary>
/// <param name="options">The graphics options.</param>
/// <param name="brush">The details how to fill the region of interest.</param>
/// <param name="region">The region of interest to be filled.</param>
/// <param name="options">The configuration options.</param>
public FillRegionProcessor(IBrush brush, Region region, GraphicsOptions options)
public FillRegionProcessor(GraphicsOptions options, IBrush brush, Region region)
{
this.Region = region;
this.Brush = brush;

2
src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs

@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
}
}
using (BrushApplicator<TPixel> applicator = brush.CreateApplicator(configuration, source, rect, options))
using (BrushApplicator<TPixel> applicator = brush.CreateApplicator(configuration, options, source, rect))
{
int scanlineWidth = maxX - minX;
using (IMemoryOwner<float> bBuffer = source.MemoryAllocator.Allocate<float>(maxIntersections))

2
src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs

@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Text
{
if (operations?.Count > 0)
{
using (BrushApplicator<TPixel> app = brush.CreateApplicator(this.Configuration, source, this.SourceRectangle, this.textRenderer.Options))
using (BrushApplicator<TPixel> app = brush.CreateApplicator(this.Configuration, this.textRenderer.Options, source, this.SourceRectangle))
{
foreach (DrawingOperation operation in operations)
{

16
src/ImageSharp.Drawing/Processing/RadialGradientBrush.cs

@ -36,17 +36,17 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc />
public override BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
RectangleF region,
GraphicsOptions options) =>
RectangleF region) =>
new RadialGradientBrushApplicator<TPixel>(
configuration,
options,
source,
this.center,
this.radius,
this.ColorStops,
this.RepetitionMode,
options);
this.RepetitionMode);
/// <inheritdoc />
private sealed class RadialGradientBrushApplicator<TPixel> : GradientBrushApplicator<TPixel>
@ -60,21 +60,21 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="RadialGradientBrushApplicator{TPixel}" /> class.
/// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="target">The target image.</param>
/// <param name="center">Center point of the gradient.</param>
/// <param name="radius">Radius of the gradient.</param>
/// <param name="colorStops">Definition of colors.</param>
/// <param name="repetitionMode">How the colors are repeated beyond the first gradient.</param>
/// <param name="options">The graphics options.</param>
public RadialGradientBrushApplicator(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> target,
PointF center,
float radius,
ColorStop[] colorStops,
GradientRepetitionMode repetitionMode,
GraphicsOptions options)
: base(configuration, target, colorStops, repetitionMode, options)
GradientRepetitionMode repetitionMode)
: base(configuration, options, target, colorStops, repetitionMode)
{
this.center = center;
this.radius = radius;

16
src/ImageSharp.Drawing/Processing/RecolorBrush.cs

@ -47,18 +47,18 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
RectangleF region,
GraphicsOptions options)
RectangleF region)
where TPixel : struct, IPixel<TPixel>
{
return new RecolorBrushApplicator<TPixel>(
configuration,
options,
source,
this.SourceColor.ToPixel<TPixel>(),
this.TargetColor.ToPixel<TPixel>(),
this.Threshold,
options);
this.Threshold);
}
/// <summary>
@ -83,19 +83,19 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="RecolorBrushApplicator{TPixel}" /> class.
/// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The options</param>
/// <param name="source">The source image.</param>
/// <param name="sourceColor">Color of the source.</param>
/// <param name="targetColor">Color of the target.</param>
/// <param name="threshold">The threshold .</param>
/// <param name="options">The options</param>
public RecolorBrushApplicator(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
TPixel sourceColor,
TPixel targetColor,
float threshold,
GraphicsOptions options)
: base(configuration, source, options)
float threshold)
: base(configuration, options, source)
{
this.sourceColor = sourceColor.ToVector4();
this.targetColorPixel = targetColor;

14
src/ImageSharp.Drawing/Processing/SolidBrush.cs

@ -33,12 +33,12 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
RectangleF region,
GraphicsOptions options)
RectangleF region)
where TPixel : struct, IPixel<TPixel>
{
return new SolidBrushApplicator<TPixel>(configuration, source, this.Color.ToPixel<TPixel>(), options);
return new SolidBrushApplicator<TPixel>(configuration, options, source, this.Color.ToPixel<TPixel>());
}
/// <summary>
@ -53,15 +53,15 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="SolidBrushApplicator{TPixel}"/> class.
/// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="source">The source image.</param>
/// <param name="color">The color.</param>
/// <param name="options">The graphics options.</param>
public SolidBrushApplicator(
Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source,
TPixel color,
GraphicsOptions options)
: base(configuration, source, options)
TPixel color)
: base(configuration, options, source)
{
this.Colors = source.MemoryAllocator.Allocate<TPixel>(source.Width);
this.Colors.Memory.Span.Fill(color);

4
src/ImageSharp/Processing/Extensions/BackgroundColorExtensions.cs

@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Processing
this IImageProcessingContext source,
GraphicsOptions options,
Color color) =>
source.ApplyProcessor(new BackgroundColorProcessor(color, options));
source.ApplyProcessor(new BackgroundColorProcessor(options, color));
/// <summary>
/// Replaces the background color of image with the given one.
@ -64,6 +64,6 @@ namespace SixLabors.ImageSharp.Processing
GraphicsOptions options,
Color color,
Rectangle rectangle) =>
source.ApplyProcessor(new BackgroundColorProcessor(color, options), rectangle);
source.ApplyProcessor(new BackgroundColorProcessor(options, color), rectangle);
}
}

8
src/ImageSharp/Processing/Extensions/GlowExtensions.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Primitives;
@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.Processing
Color color,
ValueSize radius,
Rectangle rectangle) =>
source.ApplyProcessor(new GlowProcessor(color, radius, options), rectangle);
source.ApplyProcessor(new GlowProcessor(options, color, radius), rectangle);
/// <summary>
/// Applies a radial glow effect to an image.
@ -170,6 +170,6 @@ namespace SixLabors.ImageSharp.Processing
GraphicsOptions options,
Color color,
ValueSize radius) =>
source.ApplyProcessor(new GlowProcessor(color, radius, options));
source.ApplyProcessor(new GlowProcessor(options, color, radius));
}
}
}

8
src/ImageSharp/Processing/Extensions/VignetteExtensions.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors.
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Primitives;
@ -166,7 +166,7 @@ namespace SixLabors.ImageSharp.Processing
ValueSize radiusX,
ValueSize radiusY,
Rectangle rectangle) =>
source.ApplyProcessor(new VignetteProcessor(color, radiusX, radiusY, options), rectangle);
source.ApplyProcessor(new VignetteProcessor(options, color, radiusX, radiusY), rectangle);
private static IImageProcessingContext VignetteInternal(
this IImageProcessingContext source,
@ -174,6 +174,6 @@ namespace SixLabors.ImageSharp.Processing
Color color,
ValueSize radiusX,
ValueSize radiusY) =>
source.ApplyProcessor(new VignetteProcessor(color, radiusX, radiusY, options));
source.ApplyProcessor(new VignetteProcessor(options, color, radiusX, radiusY));
}
}
}

4
src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs

@ -14,9 +14,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
/// <summary>
/// Initializes a new instance of the <see cref="BackgroundColorProcessor"/> class.
/// </summary>
/// <param name="color">The <see cref="Color"/> to set the background color to.</param>
/// <param name="options">The options defining blending algorithm and amount.</param>
public BackgroundColorProcessor(Color color, GraphicsOptions options)
/// <param name="color">The <see cref="Color"/> to set the background color to.</param>
public BackgroundColorProcessor(GraphicsOptions options, Color color)
{
this.Color = color;
this.GraphicsOptions = options;

14
src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs

@ -24,10 +24,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
/// <summary>
/// Initializes a new instance of the <see cref="GlowProcessor" /> class.
/// </summary>
/// <param name="color">The color or the glow.</param>
/// <param name="options">The options effecting blending and composition.</param>
public GlowProcessor(Color color, GraphicsOptions options)
: this(color, 0, options)
/// <param name="color">The color or the glow.</param>
public GlowProcessor(GraphicsOptions options, Color color)
: this(options, color, 0)
{
}
@ -37,17 +37,17 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
/// <param name="color">The color or the glow.</param>
/// <param name="radius">The radius of the glow.</param>
internal GlowProcessor(Color color, ValueSize radius)
: this(color, radius, new GraphicsOptions())
: this(new GraphicsOptions(), color, radius)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="GlowProcessor" /> class.
/// </summary>
/// <param name="options">The options effecting blending and composition.</param>
/// <param name="color">The color or the glow.</param>
/// <param name="radius">The radius of the glow.</param>
/// <param name="options">The options effecting blending and composition.</param>
internal GlowProcessor(Color color, ValueSize radius, GraphicsOptions options)
internal GlowProcessor(GraphicsOptions options, Color color, ValueSize radius)
{
this.GlowColor = color;
this.Radius = radius;
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
/// <summary>
/// Gets the the radius.
/// </summary>
internal ValueSize Radius { get; }
internal ValueSize Radius { get; }
/// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Image<TPixel> source, Rectangle sourceRectangle)

10
src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs

@ -17,16 +17,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
/// </summary>
/// <param name="color">The color of the vignette.</param>
public VignetteProcessor(Color color)
: this(color, new GraphicsOptions())
: this(new GraphicsOptions(), color)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="VignetteProcessor" /> class.
/// </summary>
/// <param name="color">The color of the vignette.</param>
/// <param name="options">The options effecting blending and composition.</param>
public VignetteProcessor(Color color, GraphicsOptions options)
/// <param name="color">The color of the vignette.</param>
public VignetteProcessor(GraphicsOptions options, Color color)
{
this.VignetteColor = color;
this.GraphicsOptions = options;
@ -35,11 +35,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
/// <summary>
/// Initializes a new instance of the <see cref="VignetteProcessor" /> class.
/// </summary>
/// <param name="options">The options effecting blending and composition.</param>
/// <param name="color">The color of the vignette.</param>
/// <param name="radiusX">The x-radius.</param>
/// <param name="radiusY">The y-radius.</param>
/// <param name="options">The options effecting blending and composition.</param>
internal VignetteProcessor(Color color, ValueSize radiusX, ValueSize radiusY, GraphicsOptions options)
internal VignetteProcessor(GraphicsOptions options, Color color, ValueSize radiusX, ValueSize radiusY)
{
this.VignetteColor = color;
this.RadiusX = radiusX;

6
tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs

@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
Antialias = antialias,
AntialiasSubpixelDepth = 1
};
var processor = new FillRegionProcessor(brush.Object, region, options);
var processor = new FillRegionProcessor(options, brush.Object, region);
var img = new Image<Rgba32>(1, 1);
processor.Execute(img, bounds);
@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
var bounds = new Rectangle(-100, -10, 10, 10);
var brush = new Mock<IBrush>();
var options = new GraphicsOptions { Antialias = true };
var processor = new FillRegionProcessor(brush.Object, new MockRegion1(), options);
var processor = new FillRegionProcessor(options, brush.Object, new MockRegion1());
var img = new Image<Rgba32>(10, 10);
processor.Execute(img, bounds);
}
@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void DoesNotThrowForIssue928()
{
var rectText = new RectangleF(0, 0, 2000, 2000);
using (Image<Rgba32> img = new Image<Rgba32>((int)rectText.Width, (int)rectText.Height))
using (var img = new Image<Rgba32>((int)rectText.Width, (int)rectText.Height))
{
img.Mutate(x => x.Fill(Rgba32.Transparent));

Loading…
Cancel
Save