From 563077d87d16238f191d04780134c9db58a2dbcd Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 11 Mar 2018 00:26:43 +1100 Subject: [PATCH] Combine drawing methods to new Overlays namespace. --- .../Drawing/Brushes/IBrush.cs | 1 - .../Drawing/Brushes/RecolorBrush{TPixel}.cs | 2 +- .../Drawing/Brushes/SolidBrush{TPixel}.cs | 1 - src/ImageSharp.Drawing/Drawing/Pens/IPen.cs | 6 +- src/ImageSharp.Drawing/Drawing/Pens/Pens.cs | 11 +-- .../Drawing/Pens/Pen{TPixel}.cs | 13 ++- .../Paths => Primitives}/ShapePath.cs | 13 +-- .../Paths => Primitives}/ShapeRegion.cs | 4 +- .../DrawBezierExtensions.cs | 55 +++++------- .../{DrawImage.cs => DrawImageExtensions.cs} | 66 +++++--------- .../DrawLineExtensions.cs} | 45 ++++------ .../DrawPathCollectionExtensions.cs} | 40 +++------ .../DrawPathExtensions.cs} | 45 ++++------ .../DrawPolygonExtensions.cs} | 47 ++++------ .../DrawRectangleExtensions.cs} | 59 +++++-------- .../FillPathBuilderExtensions.cs} | 35 +++----- .../FillPathCollectionExtensions.cs} | 34 +++---- .../FillPathExtensions.cs} | 35 +++----- .../FillPolygonExtensions.cs} | 36 +++----- .../FillRectangleExtensions.cs} | 37 +++----- ...{FillRegion.cs => FillRegionExtensions.cs} | 88 ++++++++----------- .../Overlays/Processors/DrawImageProcessor.cs | 70 +++++++++++++-- ...ext.Path.cs => DrawTextExtensions.Path.cs} | 54 ++++-------- .../{DrawText.cs => DrawTextExtensions.cs} | 56 +++++------- .../Processing/Text/TextGraphicsOptions.cs | 7 +- src/ImageSharp/Formats/Jpeg/JpegEncoder.cs | 1 + src/ImageSharp/Primitives/ValueSize.cs | 4 +- .../Processors/BackgroundColorProcessor.cs | 6 +- .../Overlays/Processors/GlowProcessor.cs | 23 +++-- .../Overlays/Processors/VignetteProcessor.cs | 4 +- .../Drawing/DrawBeziers.cs | 17 ++-- .../Drawing/DrawLines.cs | 2 + .../Drawing/DrawPolygon.cs | 17 ++-- .../Drawing/FillPolygon.cs | 22 +++-- .../Drawing/FillRectangle.cs | 19 ++-- .../Drawing/FillWithPattern.cs | 2 + .../ImageSharp.Tests/Drawing/BeziersTests.cs | 15 +--- .../ImageSharp.Tests/Drawing/BlendedShapes.cs | 12 +-- .../ImageSharp.Tests/Drawing/DrawImageTest.cs | 1 + .../ImageSharp.Tests/Drawing/DrawPathTests.cs | 12 +-- .../Drawing/FillPatternTests.cs | 2 + .../Drawing/FillRegionProcessorTests.cs | 6 +- .../Drawing/LineComplexPolygonTests.cs | 5 +- tests/ImageSharp.Tests/Drawing/LineTests.cs | 5 +- .../Drawing/Paths/FillPath.cs | 26 +++--- .../Drawing/Paths/FillPathCollection.cs | 24 ++--- .../Drawing/Paths/FillPolygon.cs | 29 +++--- .../Drawing/Paths/FillRectangle.cs | 7 +- .../Drawing/Paths/ShapeRegionTests.cs | 2 + .../ImageSharp.Tests/Drawing/PolygonTests.cs | 11 +-- .../Drawing/RecolorImageTest.cs | 4 +- .../Drawing/SolidBezierTests.cs | 5 +- .../Drawing/SolidComplexPolygonTests.cs | 5 +- .../Drawing/SolidPolygonTests.cs | 7 +- .../Drawing/Text/DrawText.Path.cs | 1 + .../ImageSharp.Tests/Drawing/Text/DrawText.cs | 3 +- .../Drawing/Text/OutputText.cs | 2 + .../Drawing/Text/TextGraphicsOptionsTests.cs | 2 + tests/ImageSharp.Tests/Issues/Issue412.cs | 10 +-- .../Processing/Effects/BackgroundColorTest.cs | 11 +-- .../ImageProviders/SolidProvider.cs | 1 + 61 files changed, 506 insertions(+), 679 deletions(-) rename src/ImageSharp.Drawing/{Processing/Paths => Primitives}/ShapePath.cs (68%) rename src/ImageSharp.Drawing/{Processing/Paths => Primitives}/ShapeRegion.cs (95%) rename src/ImageSharp.Drawing/Processing/{Paths => Overlays}/DrawBezierExtensions.cs (72%) rename src/ImageSharp.Drawing/Processing/Overlays/{DrawImage.cs => DrawImageExtensions.cs} (78%) rename src/ImageSharp.Drawing/Processing/{Paths/DrawLines.cs => Overlays/DrawLineExtensions.cs} (78%) rename src/ImageSharp.Drawing/Processing/{Paths/DrawPathCollection.cs => Overlays/DrawPathCollectionExtensions.cs} (82%) rename src/ImageSharp.Drawing/Processing/{Paths/DrawPath.cs => Overlays/DrawPathExtensions.cs} (79%) rename src/ImageSharp.Drawing/Processing/{Paths/DrawPolygon.cs => Overlays/DrawPolygonExtensions.cs} (78%) rename src/ImageSharp.Drawing/Processing/{Paths/DrawRectangle.cs => Overlays/DrawRectangleExtensions.cs} (69%) rename src/ImageSharp.Drawing/Processing/{Paths/FillPathBuilder.cs => Overlays/FillPathBuilderExtensions.cs} (79%) rename src/ImageSharp.Drawing/Processing/{Paths/FillPathCollection.cs => Overlays/FillPathCollectionExtensions.cs} (79%) rename src/ImageSharp.Drawing/Processing/{Paths/FillPaths.cs => Overlays/FillPathExtensions.cs} (77%) rename src/ImageSharp.Drawing/Processing/{Paths/FillPolygon.cs => Overlays/FillPolygonExtensions.cs} (75%) rename src/ImageSharp.Drawing/Processing/{Paths/FillRectangle.cs => Overlays/FillRectangleExtensions.cs} (69%) rename src/ImageSharp.Drawing/Processing/Overlays/{FillRegion.cs => FillRegionExtensions.cs} (80%) rename src/ImageSharp.Drawing/Processing/Text/{DrawText.Path.cs => DrawTextExtensions.Path.cs} (84%) rename src/ImageSharp.Drawing/Processing/Text/{DrawText.cs => DrawTextExtensions.cs} (83%) diff --git a/src/ImageSharp.Drawing/Drawing/Brushes/IBrush.cs b/src/ImageSharp.Drawing/Drawing/Brushes/IBrush.cs index bb907281b..41d9081eb 100644 --- a/src/ImageSharp.Drawing/Drawing/Brushes/IBrush.cs +++ b/src/ImageSharp.Drawing/Drawing/Brushes/IBrush.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.Drawing.Brushes.Processors; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; diff --git a/src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs b/src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs index ac2588038..4cef8cc83 100644 --- a/src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Drawing/Brushes/RecolorBrush{TPixel}.cs @@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.Drawing.Brushes this.targetColor = targetColor.ToVector4(); this.targetColorPixel = targetColor; - // Lets hack a min max extreams for a color space by letting the IPackedPixel clamp our values to something in the correct spaces :) + // Lets hack a min max extremes for a color space by letting the IPackedPixel clamp our values to something in the correct spaces :) var maxColor = default(TPixel); maxColor.PackFromVector4(new Vector4(float.MaxValue)); var minColor = default(TPixel); diff --git a/src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs b/src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs index 3aff3aea1..1511ce86c 100644 --- a/src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Drawing/Brushes/SolidBrush{TPixel}.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. using System; - using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Drawing.Brushes.Processors; using SixLabors.ImageSharp.Memory; diff --git a/src/ImageSharp.Drawing/Drawing/Pens/IPen.cs b/src/ImageSharp.Drawing/Drawing/Pens/IPen.cs index 0680ec2f5..ed7de1461 100644 --- a/src/ImageSharp.Drawing/Drawing/Pens/IPen.cs +++ b/src/ImageSharp.Drawing/Drawing/Pens/IPen.cs @@ -1,8 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using System; using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Drawing.Pens @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Drawing.Pens } /// - /// Iterface represting the pattern and size of the stroke to apply with a Pen. + /// Interface representing the pattern and size of the stroke to apply with a Pen. /// public interface IPen { @@ -33,6 +33,6 @@ namespace SixLabors.ImageSharp.Drawing.Pens /// /// Gets the stoke pattern. /// - System.ReadOnlySpan StrokePattern { get; } + ReadOnlySpan StrokePattern { get; } } } diff --git a/src/ImageSharp.Drawing/Drawing/Pens/Pens.cs b/src/ImageSharp.Drawing/Drawing/Pens/Pens.cs index 6478b1b81..4eb2d5d20 100644 --- a/src/ImageSharp.Drawing/Drawing/Pens/Pens.cs +++ b/src/ImageSharp.Drawing/Drawing/Pens/Pens.cs @@ -7,14 +7,15 @@ using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Drawing.Pens { /// - /// Common Pen styles + /// Contains a collection of common Pen styles /// public static class Pens { - private static readonly float[] DashDotPattern = new[] { 3f, 1f, 1f, 1f }; - private static readonly float[] DashDotDotPattern = new[] { 3f, 1f, 1f, 1f, 1f, 1f }; - private static readonly float[] DottedPattern = new[] { 1f, 1f }; - private static readonly float[] DashedPattern = new[] { 3f, 1f }; + private static readonly float[] DashDotPattern = { 3f, 1f, 1f, 1f }; + private static readonly float[] DashDotDotPattern = { 3f, 1f, 1f, 1f, 1f, 1f }; + private static readonly float[] DottedPattern = { 1f, 1f }; + private static readonly float[] DashedPattern = { 3f, 1f }; + internal static readonly float[] EmptyPattern = new float[0]; /// /// Create a solid pen with out any drawing patterns diff --git a/src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs b/src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs index d2748e111..3956dde0c 100644 --- a/src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs +++ b/src/ImageSharp.Drawing/Drawing/Pens/Pen{TPixel}.cs @@ -2,9 +2,7 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Numerics; using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Drawing.Pens @@ -24,11 +22,10 @@ namespace SixLabors.ImageSharp.Drawing.Pens public class Pen : IPen where TPixel : struct, IPixel { - private static readonly float[] EmptyPattern = new float[0]; private readonly float[] pattern; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The color. /// The width. @@ -39,7 +36,7 @@ namespace SixLabors.ImageSharp.Drawing.Pens } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The brush. /// The width. @@ -52,7 +49,7 @@ namespace SixLabors.ImageSharp.Drawing.Pens } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The color. /// The width. @@ -62,12 +59,12 @@ namespace SixLabors.ImageSharp.Drawing.Pens } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The brush. /// The width. public Pen(IBrush brush, float width) - : this(brush, width, EmptyPattern) + : this(brush, width, Pens.EmptyPattern) { } diff --git a/src/ImageSharp.Drawing/Processing/Paths/ShapePath.cs b/src/ImageSharp.Drawing/Primitives/ShapePath.cs similarity index 68% rename from src/ImageSharp.Drawing/Processing/Paths/ShapePath.cs rename to src/ImageSharp.Drawing/Primitives/ShapePath.cs index 4c2278719..6b4ccd917 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/ShapePath.cs +++ b/src/ImageSharp.Drawing/Primitives/ShapePath.cs @@ -1,14 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Buffers; -using System.Numerics; - -using SixLabors.ImageSharp.Memory; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Drawing +namespace SixLabors.ImageSharp.Primitives { /// /// A mapping between a and a region. @@ -20,10 +15,10 @@ namespace SixLabors.ImageSharp.Drawing /// /// The shape. /// The pen to apply to the shape. - // SixLabors.shape willbe moving to a Span/ReadOnlySpan based API shortly use ToArray for now. - public ShapePath(IPath shape, Pens.IPen pen) + // TODO: SixLabors.shape will be moving to a Span/ReadOnlySpan based API shortly use ToArray for now. + public ShapePath(IPath shape, Drawing.Pens.IPen pen) : base(shape.GenerateOutline(pen.StrokeWidth, pen.StrokePattern.ToArray())) { } } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/ShapeRegion.cs b/src/ImageSharp.Drawing/Primitives/ShapeRegion.cs similarity index 95% rename from src/ImageSharp.Drawing/Processing/Paths/ShapeRegion.cs rename to src/ImageSharp.Drawing/Primitives/ShapeRegion.cs index 9e1f1bc35..cfd1945d0 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/ShapeRegion.cs +++ b/src/ImageSharp.Drawing/Primitives/ShapeRegion.cs @@ -2,12 +2,10 @@ // Licensed under the Apache License, Version 2.0. using System; - -using SixLabors.ImageSharp.Primitives; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp.Drawing +namespace SixLabors.ImageSharp.Primitives { /// /// A mapping between a and a region. diff --git a/src/ImageSharp.Drawing/Processing/Paths/DrawBezierExtensions.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawBezierExtensions.cs similarity index 72% rename from src/ImageSharp.Drawing/Processing/Paths/DrawBezierExtensions.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawBezierExtensions.cs index 7476f3a75..974c7a650 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/DrawBezierExtensions.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawBezierExtensions.cs @@ -1,24 +1,21 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Numerics; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// EAdds extensions that allow the drawing of Bezier paths to the type. + /// Adds extensions that allow the drawing of Bezier paths to the type. /// public static class DrawBezierExtensions { /// - /// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush + /// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush /// /// The type of the color. /// The image this method extends. @@ -28,13 +25,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)), options); /// - /// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush + /// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush /// /// The type of the color. /// The image this method extends. @@ -43,13 +38,11 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points))); /// - /// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush + /// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush /// /// The type of the color. /// The image this method extends. @@ -58,13 +51,11 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points) - where TPixel : struct, IPixel - { - return source.DrawBeziers(new SolidBrush(color), thickness, points); - } + where TPixel : struct, IPixel + => source.DrawBeziers(new SolidBrush(color), thickness, points); /// - /// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush + /// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush /// /// The type of the color. /// The image this method extends. @@ -74,13 +65,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawBeziers(new SolidBrush(color), thickness, points, options); - } + where TPixel : struct, IPixel + => source.DrawBeziers(new SolidBrush(color), thickness, points, options); /// - /// Draws the provided Points as an open Bezier path with the supplied pen + /// Draws the provided points as an open Bezier path with the supplied pen /// /// The type of the color. /// The image this method extends. @@ -89,13 +78,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IPen pen, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(pen, new Path(new CubicBezierLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Draw(pen, new Path(new CubicBezierLineSegment(points)), options); /// - /// Draws the provided Points as an open Bezier path with the supplied pen + /// Draws the provided points as an open Bezier path with the supplied pen /// /// The type of the color. /// The image this method extends. @@ -103,9 +90,7 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IPen pen, PointF[] points) - where TPixel : struct, IPixel - { - return source.Draw(pen, new Path(new CubicBezierLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Draw(pen, new Path(new CubicBezierLineSegment(points))); } } diff --git a/src/ImageSharp.Drawing/Processing/Overlays/DrawImage.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawImageExtensions.cs similarity index 78% rename from src/ImageSharp.Drawing/Processing/Overlays/DrawImage.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawImageExtensions.cs index 9ff593d3e..1fa16da49 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/DrawImage.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawImageExtensions.cs @@ -1,34 +1,17 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of images to the type. /// - public static partial class ImageExtensions + public static class DrawImageExtensions { - /// - /// Draws the given image together with the current one by blending their pixels. - /// - /// The image this method extends. - /// The image to blend with the currently processing image. - /// The pixel format. - /// The location to draw the blended image. - /// The options. - /// The . - public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, GraphicsOptions options) - where TPixel : struct, IPixel - { - source.ApplyProcessor(new DrawImageProcessor(image, location, options)); - return source; - } - /// /// Draws the given image together with the current one by blending their pixels. /// @@ -39,11 +22,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Blend(this IImageProcessingContext source, Image image, float opacity) where TPixel : struct, IPixel - { - GraphicsOptions options = GraphicsOptions.Default; - options.BlendPercentage = opacity; - return DrawImage(source, image, Point.Empty, options); - } + => source.ApplyProcessor(new DrawImageProcessor(image, opacity)); /// /// Draws the given image together with the current one by blending their pixels. @@ -56,12 +35,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Blend(this IImageProcessingContext source, Image image, PixelBlenderMode blender, float opacity) where TPixel : struct, IPixel - { - GraphicsOptions options = GraphicsOptions.Default; - options.BlendPercentage = opacity; - options.BlenderMode = blender; - return DrawImage(source, image, Point.Empty, options); - } + => source.ApplyProcessor(new DrawImageProcessor(image, opacity, blender)); /// /// Draws the given image together with the current one by blending their pixels. @@ -74,7 +48,7 @@ namespace SixLabors.ImageSharp public static IImageProcessingContext Blend(this IImageProcessingContext source, Image image, GraphicsOptions options) where TPixel : struct, IPixel { - return DrawImage(source, image, Point.Empty, options); + return source.ApplyProcessor(new DrawImageProcessor(image, options)); } /// @@ -88,11 +62,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, float opacity, Point location) where TPixel : struct, IPixel - { - GraphicsOptions options = GraphicsOptions.Default; - options.BlendPercentage = opacity; - return source.DrawImage(image, location, options); - } + => source.ApplyProcessor(new DrawImageProcessor(image, location, opacity)); /// /// Draws the given image together with the current one by blending their pixels. @@ -106,11 +76,19 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelBlenderMode blender, float opacity, Point location) where TPixel : struct, IPixel - { - GraphicsOptions options = GraphicsOptions.Default; - options.BlenderMode = blender; - options.BlendPercentage = opacity; - return source.DrawImage(image, location, options); - } + => source.ApplyProcessor(new DrawImageProcessor(image, location, opacity, blender)); + + /// + /// Draws the given image together with the current one by blending their pixels. + /// + /// The image this method extends. + /// The image to blend with the currently processing image. + /// The pixel format. + /// The location to draw the blended image. + /// The options containing the blend mode and opacity. + /// The . + public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, GraphicsOptions options) + where TPixel : struct, IPixel + => source.ApplyProcessor(new DrawImageProcessor(image, location, options)); } } \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/DrawLines.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawLineExtensions.cs similarity index 78% rename from src/ImageSharp.Drawing/Processing/Paths/DrawLines.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawLineExtensions.cs index 397cd20e7..8bf42a07f 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/DrawLines.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawLineExtensions.cs @@ -1,21 +1,18 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Numerics; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of lines to the type. /// - public static partial class ImageExtensions + public static class DrawLineExtensions { /// /// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush @@ -28,10 +25,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points)), options); /// /// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush @@ -43,10 +38,8 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points))); /// /// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush @@ -58,10 +51,8 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawLines(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points) - where TPixel : struct, IPixel - { - return source.DrawLines(new SolidBrush(color), thickness, points); - } + where TPixel : struct, IPixel + => source.DrawLines(new SolidBrush(color), thickness, points); /// /// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush @@ -74,10 +65,8 @@ namespace SixLabors.ImageSharp /// The options. /// The .> public static IImageProcessingContext DrawLines(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawLines(new SolidBrush(color), thickness, points, options); - } + where TPixel : struct, IPixel + => source.DrawLines(new SolidBrush(color), thickness, points, options); /// /// Draws the provided Points as an open Linear path with the supplied pen @@ -89,10 +78,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IPen pen, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(pen, new Path(new LinearLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Draw(pen, new Path(new LinearLineSegment(points)), options); /// /// Draws the provided Points as an open Linear path with the supplied pen @@ -103,9 +90,7 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IPen pen, PointF[] points) - where TPixel : struct, IPixel - { - return source.Draw(pen, new Path(new LinearLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Draw(pen, new Path(new LinearLineSegment(points))); } } diff --git a/src/ImageSharp.Drawing/Processing/Paths/DrawPathCollection.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawPathCollectionExtensions.cs similarity index 82% rename from src/ImageSharp.Drawing/Processing/Paths/DrawPathCollection.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawPathCollectionExtensions.cs index 17d7fed41..191a73a36 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/DrawPathCollection.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawPathCollectionExtensions.cs @@ -1,19 +1,17 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of collections of polygon outlines to the type. /// - public static partial class ImageExtensions + public static class DrawPathCollectionExtensions { /// /// Draws the outline of the polygon with the provided pen. @@ -44,10 +42,8 @@ namespace SixLabors.ImageSharp /// The paths. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPathCollection paths) - where TPixel : struct, IPixel - { - return source.Draw(pen, paths, GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Draw(pen, paths, GraphicsOptions.Default); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -60,10 +56,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPathCollection paths, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), paths, options); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), paths, options); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -75,10 +69,8 @@ namespace SixLabors.ImageSharp /// The paths. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPathCollection paths) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), paths); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), paths); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -91,10 +83,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPathCollection paths, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new SolidBrush(color), thickness, paths, options); - } + where TPixel : struct, IPixel + => source.Draw(new SolidBrush(color), thickness, paths, options); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -106,9 +96,7 @@ namespace SixLabors.ImageSharp /// The paths. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPathCollection paths) - where TPixel : struct, IPixel - { - return source.Draw(new SolidBrush(color), thickness, paths); - } + where TPixel : struct, IPixel + => source.Draw(new SolidBrush(color), thickness, paths); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/DrawPath.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawPathExtensions.cs similarity index 79% rename from src/ImageSharp.Drawing/Processing/Paths/DrawPath.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawPathExtensions.cs index b265342a4..7f86ddee6 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/DrawPath.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawPathExtensions.cs @@ -1,19 +1,18 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of polygon outlines to the type. /// - public static partial class ImageExtensions + public static class DrawPathExtensions { /// /// Draws the outline of the polygon with the provided pen. @@ -25,10 +24,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPath path, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(pen.StrokeFill, new ShapePath(path, pen), options); - } + where TPixel : struct, IPixel + => source.Fill(pen.StrokeFill, new ShapePath(path, pen), options); /// /// Draws the outline of the polygon with the provided pen. @@ -39,10 +36,8 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPath path) - where TPixel : struct, IPixel - { - return source.Draw(pen, path, GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Draw(pen, path, GraphicsOptions.Default); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -55,10 +50,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPath path, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), path, options); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), path, options); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -70,10 +63,8 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPath path) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), path); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), path); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -86,10 +77,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPath path, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new SolidBrush(color), thickness, path, options); - } + where TPixel : struct, IPixel + => source.Draw(new SolidBrush(color), thickness, path, options); /// /// Draws the outline of the polygon with the provided brush at the provided thickness. @@ -101,9 +90,7 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPath path) - where TPixel : struct, IPixel - { - return source.Draw(new SolidBrush(color), thickness, path); - } + where TPixel : struct, IPixel + => source.Draw(new SolidBrush(color), thickness, path); } } diff --git a/src/ImageSharp.Drawing/Processing/Paths/DrawPolygon.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawPolygonExtensions.cs similarity index 78% rename from src/ImageSharp.Drawing/Processing/Paths/DrawPolygon.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawPolygonExtensions.cs index 7615284d2..f56ab19d8 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/DrawPolygon.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawPolygonExtensions.cs @@ -1,21 +1,18 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Numerics; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of closed linear polygons to the type. /// - public static partial class ImageExtensions + public static class DrawPolygonExtensions { /// /// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness. @@ -28,10 +25,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)), options); /// /// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness. @@ -43,10 +38,8 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points))); /// /// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness. @@ -58,10 +51,8 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points) - where TPixel : struct, IPixel - { - return source.DrawPolygon(new SolidBrush(color), thickness, points); - } + where TPixel : struct, IPixel + => source.DrawPolygon(new SolidBrush(color), thickness, points); /// /// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness. @@ -74,10 +65,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawPolygon(new SolidBrush(color), thickness, points, options); - } + where TPixel : struct, IPixel + => source.DrawPolygon(new SolidBrush(color), thickness, points, options); /// /// Draws the provided Points as a closed Linear Polygon with the provided Pen. @@ -88,10 +77,8 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IPen pen, PointF[] points) - where TPixel : struct, IPixel - { - return source.Draw(pen, new Polygon(new LinearLineSegment(points)), GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Draw(pen, new Polygon(new LinearLineSegment(points)), GraphicsOptions.Default); /// /// Draws the provided Points as a closed Linear Polygon with the provided Pen. @@ -103,9 +90,7 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IPen pen, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(pen, new Polygon(new LinearLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Draw(pen, new Polygon(new LinearLineSegment(points)), options); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/DrawRectangle.cs b/src/ImageSharp.Drawing/Processing/Overlays/DrawRectangleExtensions.cs similarity index 69% rename from src/ImageSharp.Drawing/Processing/Paths/DrawRectangle.cs rename to src/ImageSharp.Drawing/Processing/Overlays/DrawRectangleExtensions.cs index db825e2e8..df0c1bf15 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/DrawRectangle.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/DrawRectangleExtensions.cs @@ -1,22 +1,21 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; +using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of rectangles to the type. /// - public static partial class ImageExtensions + public static class DrawRectangleExtensions { /// - /// Draws the outline of the polygon with the provided pen. + /// Draws the outline of the rectangle with the provided pen. /// /// The type of the color. /// The image this method extends. @@ -25,13 +24,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, RectangleF shape, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(pen, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options); - } + where TPixel : struct, IPixel + => source.Draw(pen, new RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options); /// - /// Draws the outline of the polygon with the provided pen. + /// Draws the outline of the rectangle with the provided pen. /// /// The type of the color. /// The image this method extends. @@ -39,13 +36,11 @@ namespace SixLabors.ImageSharp /// The shape. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, RectangleF shape) - where TPixel : struct, IPixel - { - return source.Draw(pen, shape, GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Draw(pen, shape, GraphicsOptions.Default); /// - /// Draws the outline of the polygon with the provided brush at the provided thickness. + /// Draws the outline of the rectangle with the provided brush at the provided thickness. /// /// The type of the color. /// The image this method extends. @@ -55,13 +50,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, RectangleF shape, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), shape, options); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), shape, options); /// - /// Draws the outline of the polygon with the provided brush at the provided thickness. + /// Draws the outline of the rectangle with the provided brush at the provided thickness. /// /// The type of the color. /// The image this method extends. @@ -70,13 +63,11 @@ namespace SixLabors.ImageSharp /// The shape. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, RectangleF shape) - where TPixel : struct, IPixel - { - return source.Draw(new Pen(brush, thickness), shape); - } + where TPixel : struct, IPixel + => source.Draw(new Pen(brush, thickness), shape); /// - /// Draws the outline of the polygon with the provided brush at the provided thickness. + /// Draws the outline of the rectangle with the provided brush at the provided thickness. /// /// The type of the color. /// The image this method extends. @@ -86,13 +77,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, RectangleF shape, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Draw(new SolidBrush(color), thickness, shape, options); - } + where TPixel : struct, IPixel + => source.Draw(new SolidBrush(color), thickness, shape, options); /// - /// Draws the outline of the polygon with the provided brush at the provided thickness. + /// Draws the outline of the rectangle with the provided brush at the provided thickness. /// /// The type of the color. /// The image this method extends. @@ -101,9 +90,7 @@ namespace SixLabors.ImageSharp /// The shape. /// The . public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, RectangleF shape) - where TPixel : struct, IPixel - { - return source.Draw(new SolidBrush(color), thickness, shape); - } + where TPixel : struct, IPixel + => source.Draw(new SolidBrush(color), thickness, shape); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/FillPathBuilder.cs b/src/ImageSharp.Drawing/Processing/Overlays/FillPathBuilderExtensions.cs similarity index 79% rename from src/ImageSharp.Drawing/Processing/Paths/FillPathBuilder.cs rename to src/ImageSharp.Drawing/Processing/Overlays/FillPathBuilderExtensions.cs index f9846b863..e40eaa413 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/FillPathBuilder.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/FillPathBuilderExtensions.cs @@ -2,21 +2,20 @@ // Licensed under the Apache License, Version 2.0. using System; -using SixLabors.ImageSharp.Drawing; + using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the filling of polygons with various brushes to the type. /// - public static partial class ImageExtensions + public static class FillPathBuilderExtensions { /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided polygon with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -42,13 +41,11 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Action path) - where TPixel : struct, IPixel - { - return source.Fill(brush, path, GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Fill(brush, path, GraphicsOptions.Default); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided polygon with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -57,13 +54,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Action path, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), path, options); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), path, options); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided polygon with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -71,9 +66,7 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Action path) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), path); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), path); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/FillPathCollection.cs b/src/ImageSharp.Drawing/Processing/Overlays/FillPathCollectionExtensions.cs similarity index 79% rename from src/ImageSharp.Drawing/Processing/Paths/FillPathCollection.cs rename to src/ImageSharp.Drawing/Processing/Overlays/FillPathCollectionExtensions.cs index d8fd89678..7021b5c87 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/FillPathCollection.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/FillPathCollectionExtensions.cs @@ -1,21 +1,19 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the filling of collections of polygon outlines to the type. /// - public static partial class ImageExtensions + public static class FillPathCollectionExtensions { /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided polygon with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -43,13 +41,11 @@ namespace SixLabors.ImageSharp /// The paths. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, IPathCollection paths) - where TPixel : struct, IPixel - { - return source.Fill(brush, paths, GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Fill(brush, paths, GraphicsOptions.Default); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided polygon with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -58,13 +54,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, IPathCollection paths, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), paths, options); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), paths, options); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided polygon with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -72,9 +66,7 @@ namespace SixLabors.ImageSharp /// The paths. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, IPathCollection paths) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), paths); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), paths); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/FillPaths.cs b/src/ImageSharp.Drawing/Processing/Overlays/FillPathExtensions.cs similarity index 77% rename from src/ImageSharp.Drawing/Processing/Paths/FillPaths.cs rename to src/ImageSharp.Drawing/Processing/Overlays/FillPathExtensions.cs index eb8fcc4ee..779a6e94f 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/FillPaths.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/FillPathExtensions.cs @@ -1,18 +1,17 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the filling of polygon outlines to the type. /// - public static partial class ImageExtensions + public static class FillPathExtensions { /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. @@ -24,10 +23,8 @@ namespace SixLabors.ImageSharp /// The graphics options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, IPath path, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(brush, new ShapeRegion(path), options); - } + where TPixel : struct, IPixel + => source.Fill(brush, new ShapeRegion(path), options); /// /// Flood fills the image in the shape of the provided polygon with the specified brush. @@ -38,10 +35,8 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, IPath path) - where TPixel : struct, IPixel - { - return source.Fill(brush, new ShapeRegion(path), GraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.Fill(brush, new ShapeRegion(path), GraphicsOptions.Default); /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. @@ -53,10 +48,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, IPath path, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), path, options); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), path, options); /// /// Flood fills the image in the shape of the provided polygon with the specified brush.. @@ -67,9 +60,7 @@ namespace SixLabors.ImageSharp /// The path. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, IPath path) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), path); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), path); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/FillPolygon.cs b/src/ImageSharp.Drawing/Processing/Overlays/FillPolygonExtensions.cs similarity index 75% rename from src/ImageSharp.Drawing/Processing/Paths/FillPolygon.cs rename to src/ImageSharp.Drawing/Processing/Overlays/FillPolygonExtensions.cs index 4e3fea9c7..700b3e18f 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/FillPolygon.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/FillPolygonExtensions.cs @@ -1,21 +1,17 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Numerics; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the filling of closed linear polygons to the type. /// - public static partial class ImageExtensions + public static class FillPolygonExtensions { /// /// Flood fills the image in the shape of a Linear polygon described by the points @@ -27,10 +23,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext FillPolygon(this IImageProcessingContext source, IBrush brush, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(brush, new Polygon(new LinearLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Fill(brush, new Polygon(new LinearLineSegment(points)), options); /// /// Flood fills the image in the shape of a Linear polygon described by the points @@ -41,10 +35,8 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext FillPolygon(this IImageProcessingContext source, IBrush brush, PointF[] points) - where TPixel : struct, IPixel - { - return source.Fill(brush, new Polygon(new LinearLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Fill(brush, new Polygon(new LinearLineSegment(points))); /// /// Flood fills the image in the shape of a Linear polygon described by the points @@ -56,10 +48,8 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext FillPolygon(this IImageProcessingContext source, TPixel color, PointF[] points, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points)), options); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points)), options); /// /// Flood fills the image in the shape of a Linear polygon described by the points @@ -70,9 +60,7 @@ namespace SixLabors.ImageSharp /// The points. /// The . public static IImageProcessingContext FillPolygon(this IImageProcessingContext source, TPixel color, PointF[] points) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points))); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points))); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Paths/FillRectangle.cs b/src/ImageSharp.Drawing/Processing/Overlays/FillRectangleExtensions.cs similarity index 69% rename from src/ImageSharp.Drawing/Processing/Paths/FillRectangle.cs rename to src/ImageSharp.Drawing/Processing/Overlays/FillRectangleExtensions.cs index 2f3b67629..a7ba82d49 100644 --- a/src/ImageSharp.Drawing/Processing/Paths/FillRectangle.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/FillRectangleExtensions.cs @@ -1,21 +1,20 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; using SixLabors.Primitives; +using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the filling of rectangles to the type. /// - public static partial class ImageExtensions + public static class FillRectangleExtensions { /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided rectangle with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -25,12 +24,10 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, RectangleF shape, GraphicsOptions options) where TPixel : struct, IPixel - { - return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options); - } + => source.Fill(brush, new RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided rectangle with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -39,12 +36,10 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, RectangleF shape) where TPixel : struct, IPixel - { - return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height)); - } + => source.Fill(brush, new RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height)); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided rectangle with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -53,13 +48,11 @@ namespace SixLabors.ImageSharp /// The options. /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, RectangleF shape, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), shape, options); - } + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), shape, options); /// - /// Flood fills the image in the shape of the provided polygon with the specified brush.. + /// Flood fills the image in the shape of the provided rectangle with the specified brush. /// /// The type of the color. /// The image this method extends. @@ -68,8 +61,6 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, RectangleF shape) where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), shape); - } + => source.Fill(new SolidBrush(color), shape); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Overlays/FillRegion.cs b/src/ImageSharp.Drawing/Processing/Overlays/FillRegionExtensions.cs similarity index 80% rename from src/ImageSharp.Drawing/Processing/Overlays/FillRegion.cs rename to src/ImageSharp.Drawing/Processing/Overlays/FillRegionExtensions.cs index b9fb8650a..0f1176e9d 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/FillRegion.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/FillRegionExtensions.cs @@ -1,34 +1,18 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Primitives; -using SixLabors.ImageSharp.Processing; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Overlays { /// - /// Extension methods for the type. + /// Adds extensions that allow the filling of regions with various brushes to the type. /// - public static partial class ImageExtensions + public static class FillRegionExtensions { - /// - /// Flood fills the image with the specified brush. - /// - /// The type of the color. - /// The image this method extends. - /// The details how to fill the region of interest. - /// The graphics options. - /// The . - public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.ApplyProcessor(new FillProcessor(brush, options)); - } - /// /// Flood fills the image with the specified brush. /// @@ -38,9 +22,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush) where TPixel : struct, IPixel - { - return source.Fill(brush, GraphicsOptions.Default); - } + => source.Fill(brush, GraphicsOptions.Default); /// /// Flood fills the image with the specified color. @@ -51,9 +33,7 @@ namespace SixLabors.ImageSharp /// The . public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color) where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color)); - } + => source.Fill(new SolidBrush(color)); /// /// Flood fills the image with in the region with the specified brush. @@ -62,27 +42,23 @@ namespace SixLabors.ImageSharp /// The image this method extends. /// The brush. /// The region. - /// The graphics options. /// The . - public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Region region, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.ApplyProcessor(new FillRegionProcessor(brush, region, options)); - } + public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Region region) + where TPixel : struct, IPixel + => source.Fill(brush, region, GraphicsOptions.Default); /// - /// Flood fills the image with in the region with the specified brush. + /// Flood fills the image with in the region with the specified color. /// /// The type of the color. /// The image this method extends. - /// The brush. + /// The color. /// The region. + /// The options. /// The . - public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Region region) - where TPixel : struct, IPixel - { - return source.Fill(brush, region, GraphicsOptions.Default); - } + public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Region region, GraphicsOptions options) + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), region, options); /// /// Flood fills the image with in the region with the specified color. @@ -91,26 +67,34 @@ namespace SixLabors.ImageSharp /// The image this method extends. /// The color. /// The region. - /// The options. /// The . - public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Region region, GraphicsOptions options) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), region, options); - } + public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Region region) + where TPixel : struct, IPixel + => source.Fill(new SolidBrush(color), region); /// - /// Flood fills the image with in the region with the specified color. + /// Flood fills the image with in the region with the specified brush. /// /// The type of the color. /// The image this method extends. - /// The color. + /// The brush. /// The region. + /// The graphics options. /// The . - public static IImageProcessingContext Fill(this IImageProcessingContext source, TPixel color, Region region) - where TPixel : struct, IPixel - { - return source.Fill(new SolidBrush(color), region); - } + public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, Region region, GraphicsOptions options) + where TPixel : struct, IPixel + => source.ApplyProcessor(new FillRegionProcessor(brush, region, options)); + + /// + /// Flood fills the image with the specified brush. + /// + /// The type of the color. + /// The image this method extends. + /// The details how to fill the region of interest. + /// The graphics options. + /// The . + public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush, GraphicsOptions options) + where TPixel : struct, IPixel + => source.ApplyProcessor(new FillProcessor(brush, options)); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Overlays/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processing/Overlays/Processors/DrawImageProcessor.cs index 53997b618..a41496d2a 100644 --- a/src/ImageSharp.Drawing/Processing/Overlays/Processors/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processing/Overlays/Processors/DrawImageProcessor.cs @@ -9,7 +9,7 @@ using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; -namespace SixLabors.ImageSharp.Drawing.Processors +namespace SixLabors.ImageSharp.Processing.Overlays.Processors { /// /// Combines two images together by blending the pixels. @@ -18,19 +18,79 @@ namespace SixLabors.ImageSharp.Drawing.Processors internal class DrawImageProcessor : ImageProcessor where TPixel : struct, IPixel { + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// The opacity of the image to blend. Must be between 0 and 1. + public DrawImageProcessor(Image image, float opacity) + : this(image, Point.Empty, opacity) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// + /// The options containing the opacity of the image to blend and blending mode. + /// Opacity must be between 0 and 1. + /// + public DrawImageProcessor(Image image, GraphicsOptions options) + : this(image, Point.Empty, options) + { + } + /// /// Initializes a new instance of the class. /// /// The image to blend with the currently processing image. /// The location to draw the blended image. - /// The opacity of the image to blend. Between 0 and 1. + /// The opacity of the image to blend. Must be between 0 and 1. + public DrawImageProcessor(Image image, Point location, float opacity) + : this(image, location, opacity, GraphicsOptions.Default.BlenderMode) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// The location to draw the blended image. + /// + /// The options containing the opacity of the image to blend and blending mode. + /// Opacity must be between 0 and 1. + /// public DrawImageProcessor(Image image, Point location, GraphicsOptions options) + : this(image, location, options.BlendPercentage, options.BlenderMode) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// The opacity of the image to blend. Must be between 0 and 1. + /// The blending mode to use when drawing the image. + public DrawImageProcessor(Image image, float opacity, PixelBlenderMode blenderMode) + : this(image, Point.Empty, opacity, blenderMode) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The image to blend with the currently processing image. + /// The location to draw the blended image. + /// The opacity of the image to blend. Must be between 0 and 1. + /// The blending mode to use when drawing the image. + public DrawImageProcessor(Image image, Point location, float opacity, PixelBlenderMode blenderMode) { - Guard.MustBeBetweenOrEqualTo(options.BlendPercentage, 0, 1, nameof(options.BlendPercentage)); + Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); this.Image = image; - this.Opacity = options.BlendPercentage; - this.Blender = PixelOperations.Instance.GetPixelBlender(options.BlenderMode); + this.Opacity = opacity; + this.Blender = PixelOperations.Instance.GetPixelBlender(blenderMode); this.Location = location; } diff --git a/src/ImageSharp.Drawing/Processing/Text/DrawText.Path.cs b/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs similarity index 84% rename from src/ImageSharp.Drawing/Processing/Text/DrawText.Path.cs rename to src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs index f1fbd2cec..6c009169f 100644 --- a/src/ImageSharp.Drawing/Processing/Text/DrawText.Path.cs +++ b/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.Path.cs @@ -1,21 +1,19 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Numerics; using SixLabors.Fonts; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Text { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of text along given paths to the type. /// - public static partial class ImageExtensions + public static partial class DrawTextExtensions { /// /// Draws the text onto the the image filled via the brush. @@ -30,10 +28,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, TPixel color, IPath path) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, color, path, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, color, path, TextGraphicsOptions.Default); /// /// Draws the text onto the the image filled via the brush. @@ -49,10 +45,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, TPixel color, IPath path, TextGraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, Brushes.Solid(color), null, path, options); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, Brushes.Solid(color), null, path, options); /// /// Draws the text onto the the image filled via the brush. @@ -67,10 +61,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, IPath path) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, brush, path, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, brush, path, TextGraphicsOptions.Default); /// /// Draws the text onto the the image filled via the brush. @@ -86,10 +78,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, IPath path, TextGraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, brush, null, path, options); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, brush, null, path, options); /// /// Draws the text onto the the image outlined via the pen. @@ -104,10 +94,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IPen pen, IPath path) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, pen, path, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, pen, path, TextGraphicsOptions.Default); /// /// Draws the text onto the the image outlined via the pen. @@ -123,10 +111,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IPen pen, IPath path, TextGraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, null, pen, path, options); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, null, pen, path, options); /// /// Draws the text onto the the image filled via the brush then outlined via the pen. @@ -142,10 +128,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, IPen pen, IPath path) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, brush, pen, path, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, brush, pen, path, TextGraphicsOptions.Default); /// /// Draws the text onto the the image filled via the brush then outlined via the pen. @@ -192,4 +176,4 @@ namespace SixLabors.ImageSharp return source; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Text/DrawText.cs b/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.cs similarity index 83% rename from src/ImageSharp.Drawing/Processing/Text/DrawText.cs rename to src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.cs index cac5ae22f..7e43fb17c 100644 --- a/src/ImageSharp.Drawing/Processing/Text/DrawText.cs +++ b/src/ImageSharp.Drawing/Processing/Text/DrawTextExtensions.cs @@ -1,22 +1,20 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.Numerics; using SixLabors.Fonts; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Primitives; using SixLabors.Shapes; -namespace SixLabors.ImageSharp +namespace SixLabors.ImageSharp.Processing.Text { /// - /// Extension methods for the type. + /// Adds extensions that allow the drawing of text to the type. /// - public static partial class ImageExtensions + public static partial class DrawTextExtensions { private static readonly int DefaultTextDpi = 72; @@ -33,10 +31,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, TPixel color, PointF location) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, color, location, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, color, location, TextGraphicsOptions.Default); /// /// Draws the text onto the the image filled via the brush. @@ -52,10 +48,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, TPixel color, PointF location, TextGraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, Brushes.Solid(color), null, location, options); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, Brushes.Solid(color), null, location, options); /// /// Draws the text onto the the image filled via the brush. @@ -70,10 +64,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, PointF location) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, brush, location, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, brush, location, TextGraphicsOptions.Default); /// /// Draws the text onto the the image filled via the brush. @@ -89,10 +81,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, PointF location, TextGraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, brush, null, location, options); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, brush, null, location, options); /// /// Draws the text onto the the image outlined via the pen. @@ -107,10 +97,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IPen pen, PointF location) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, pen, location, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, pen, location, TextGraphicsOptions.Default); /// /// Draws the text onto the the image outlined via the pen. @@ -126,10 +114,8 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IPen pen, PointF location, TextGraphicsOptions options) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, null, pen, location, options); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, null, pen, location, options); /// /// Draws the text onto the the image filled via the brush then outlined via the pen. @@ -145,13 +131,11 @@ namespace SixLabors.ImageSharp /// The . /// public static IImageProcessingContext DrawText(this IImageProcessingContext source, string text, Font font, IBrush brush, IPen pen, PointF location) - where TPixel : struct, IPixel - { - return source.DrawText(text, font, brush, pen, location, TextGraphicsOptions.Default); - } + where TPixel : struct, IPixel + => source.DrawText(text, font, brush, pen, location, TextGraphicsOptions.Default); /// - /// Draws the text onto the the image filled via the brush then outlined via the pen. + /// Draws the text using the default resolution of 72dpi onto the the image filled via the brush then outlined via the pen. /// /// The type of the color. /// The image this method extends. @@ -195,4 +179,4 @@ namespace SixLabors.ImageSharp return source; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Processing/Text/TextGraphicsOptions.cs b/src/ImageSharp.Drawing/Processing/Text/TextGraphicsOptions.cs index c230a8c79..bba473ddb 100644 --- a/src/ImageSharp.Drawing/Processing/Text/TextGraphicsOptions.cs +++ b/src/ImageSharp.Drawing/Processing/Text/TextGraphicsOptions.cs @@ -1,9 +1,10 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. + using SixLabors.Fonts; using SixLabors.ImageSharp.PixelFormats; -namespace SixLabors.ImageSharp.Drawing +namespace SixLabors.ImageSharp.Processing.Text { /// /// Options for influencing the drawing functions. @@ -29,8 +30,8 @@ namespace SixLabors.ImageSharp.Drawing private float wrapTextWidth; - private SixLabors.Fonts.HorizontalAlignment? horizontalAlignment; - private SixLabors.Fonts.VerticalAlignment? verticalAlignment; + private HorizontalAlignment? horizontalAlignment; + private VerticalAlignment? verticalAlignment; /// /// Initializes a new instance of the struct. diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs index 8850f581c..60b00c0f5 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs @@ -20,6 +20,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg /// /// Gets or sets the quality, that will be used to encode the image. Quality /// index must be between 0 and 100 (compression from max to min). + /// Defaults to 75. /// public int Quality { get; set; } = 75; diff --git a/src/ImageSharp/Primitives/ValueSize.cs b/src/ImageSharp/Primitives/ValueSize.cs index e64d838e6..8af9ba2e4 100644 --- a/src/ImageSharp/Primitives/ValueSize.cs +++ b/src/ImageSharp/Primitives/ValueSize.cs @@ -38,12 +38,12 @@ namespace SixLabors.ImageSharp.Primitives Absolute, /// - /// The value is a percentage of the Images Width + /// The value is a percentage of the image width /// PercentageOfWidth, /// - /// The value is a percentage of the Images height + /// The value is a percentage of the images height /// PercentageOfHeight } diff --git a/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs index e0639d8ad..b676f6a12 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/BackgroundColorProcessor.cs @@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors /// The options defining blending algorithm and amount. public BackgroundColorProcessor(TPixel color, GraphicsOptions options) { - this.Value = color; + this.Color = color; this.GraphicsOptions = options; } @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors /// /// Gets the background color value. /// - public TPixel Value { get; } + public TPixel Color { get; } /// protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) @@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors // TODO: Use Span.Fill? for (int i = 0; i < width; i++) { - colorSpan[i] = this.Value; + colorSpan[i] = this.Color; amountSpan[i] = this.GraphicsOptions.BlendPercentage; } diff --git a/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs index 5f9b8f5af..ac5d3dc82 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/GlowProcessor.cs @@ -27,10 +27,8 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors /// /// The color or the glow. public GlowProcessor(TPixel color) + : this(color, 0) { - this.GlowColor = color; - this.GraphicsOptions = GraphicsOptions.Default; - this.blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); } /// @@ -39,11 +37,18 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors /// The color or the glow. /// The radius of the glow. public GlowProcessor(TPixel color, ValueSize radius) + : this(color, radius, GraphicsOptions.Default) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The color or the glow. + /// The options effecting blending and composition. + public GlowProcessor(TPixel color, GraphicsOptions options) + : this(color, 0, options) { - this.GlowColor = color; - this.Radius = radius; - this.GraphicsOptions = GraphicsOptions.Default; - this.blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); } /// @@ -83,7 +88,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors int startX = sourceRectangle.X; int endX = sourceRectangle.Right; TPixel glowColor = this.GlowColor; - Vector2 centre = Rectangle.Center(sourceRectangle); + Vector2 center = Rectangle.Center(sourceRectangle); float finalRadius = this.Radius.Calculate(source.Size()); @@ -130,7 +135,7 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors int offsetX = minX - startX; for (int i = 0; i < width; i++) { - float distance = Vector2.Distance(centre, new Vector2(i + offsetX, offsetY)); + float distance = Vector2.Distance(center, new Vector2(i + offsetX, offsetY)); amountsSpan[i] = (this.GraphicsOptions.BlendPercentage * (1 - (.95F * (distance / maxDistance)))).Clamp(0, 1); } diff --git a/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs index 961c0f9f0..ec286db62 100644 --- a/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs +++ b/src/ImageSharp/Processing/Overlays/Processors/VignetteProcessor.cs @@ -27,10 +27,8 @@ namespace SixLabors.ImageSharp.Processing.Overlays.Processors /// /// The color of the vignette. public VignetteProcessor(TPixel color) + : this(color, GraphicsOptions.Default) { - this.VignetteColor = color; - this.GraphicsOptions = GraphicsOptions.Default; - this.blender = PixelOperations.Instance.GetPixelBlender(this.GraphicsOptions.BlenderMode); } /// diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs index a8042c77c..9b7b8f4e6 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs @@ -3,17 +3,16 @@ // Licensed under the Apache License, Version 2.0. // +using System.Drawing; +using System.Drawing.Drawing2D; +using System.IO; +using System.Numerics; +using BenchmarkDotNet.Attributes; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; + namespace SixLabors.ImageSharp.Benchmarks { - using System.Drawing; - using System.Drawing.Drawing2D; - using System.IO; - using System.Numerics; - - using BenchmarkDotNet.Attributes; - - using SixLabors.ImageSharp.Processing; - public class DrawBeziers : BenchmarkBase { [Benchmark(Baseline = true, Description = "System.Drawing Draw Beziers")] diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs index f89d9a684..d12b064cb 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.Processing.Overlays; + namespace SixLabors.ImageSharp.Benchmarks { using System.Drawing; diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs index aa24088ae..3f2a03050 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs @@ -3,18 +3,17 @@ // Licensed under the Apache License, Version 2.0. // +using System.Drawing; +using System.Drawing.Drawing2D; +using BenchmarkDotNet.Attributes; +using System.IO; +using System.Numerics; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; + namespace SixLabors.ImageSharp.Benchmarks { - using System.Drawing; - using System.Drawing.Drawing2D; - - using BenchmarkDotNet.Attributes; - - using System.IO; - using System.Numerics; - using SixLabors.ImageSharp.PixelFormats; - using SixLabors.ImageSharp.Processing; public class DrawPolygon : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs index 9075e02e8..a6f8b2c08 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs @@ -3,26 +3,24 @@ // Licensed under the Apache License, Version 2.0. // +using System.Drawing; +using System.Drawing.Drawing2D; +using System.IO; +using System.Numerics; +using SixLabors.Shapes; +using BenchmarkDotNet.Attributes; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; + namespace SixLabors.ImageSharp.Benchmarks { - using System.Drawing; - using System.Drawing.Drawing2D; - using System.IO; - using System.Numerics; - using SixLabors.Shapes; - - using BenchmarkDotNet.Attributes; - - using SixLabors.ImageSharp.PixelFormats; - using SixLabors.ImageSharp.Processing; - public class FillPolygon : BenchmarkBase { private readonly Polygon shape; public FillPolygon() { - this.shape = new SixLabors.Shapes.Polygon(new LinearLineSegment(new Vector2(10, 10), + this.shape = new Polygon(new LinearLineSegment(new Vector2(10, 10), new Vector2(550, 50), new Vector2(200, 400))); } diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs index 1fd2dbe82..b60a068f1 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs @@ -3,19 +3,18 @@ // Licensed under the Apache License, Version 2.0. // +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Numerics; +using BenchmarkDotNet.Attributes; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; +using CoreRectangle = SixLabors.Primitives.Rectangle; +using CoreSize = SixLabors.Primitives.Size; + namespace SixLabors.ImageSharp.Benchmarks { - using System.Drawing; - using System.Drawing.Drawing2D; - - using BenchmarkDotNet.Attributes; - using CoreRectangle = SixLabors.Primitives.Rectangle; - using CoreSize = SixLabors.Primitives.Size; - - using System.Numerics; - using SixLabors.ImageSharp.PixelFormats; - using SixLabors.ImageSharp.Processing; public class FillRectangle : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs index 64132e479..3d840de46 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs @@ -3,6 +3,8 @@ // Licensed under the Apache License, Version 2.0. // +using SixLabors.ImageSharp.Processing.Overlays; + namespace SixLabors.ImageSharp.Benchmarks { using System.Drawing; diff --git a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs index af1364af4..9ab772208 100644 --- a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs +++ b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs @@ -1,20 +1,13 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; using System.Numerics; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Drawing; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { - using SixLabors.ImageSharp.Processing; - using SixLabors.ImageSharp.Processing.Overlays; - public class Beziers : FileTestBase { [Fact] @@ -71,9 +64,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Vector2(240, 30), new Vector2(300, 400) })); - image.Save($"{path}/Opacity.png"); + image.Save($"{path}/Opacity.png"); - //shift background color towards forground color by the opacity amount + //shift background color towards foreground color by the opacity amount Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f)); using (PixelAccessor sourcePixels = image.Lock()) diff --git a/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs index bea0d8b07..3138b8c70 100644 --- a/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs +++ b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs @@ -4,8 +4,8 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Primitives; using Xunit; @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing public class BlendedShapes { public static IEnumerable modes = ((PixelBlenderMode[])Enum.GetValues(typeof(PixelBlenderMode))) - .Select(x=> new object[] { x }); + .Select(x => new object[] { x }); [Theory] [WithBlankImages(nameof(modes), 250, 250, PixelTypes.Rgba32)] @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { var scaleX = (img.Width / 100); var scaleY = (img.Height / 100); - img.Mutate(x=>x + img.Mutate(x => x .Fill(NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY)) .Fill(NamedColors.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY), new ImageSharp.GraphicsOptions(true) { @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { var scaleX = (img.Width / 100); var scaleY = (img.Height / 100); - img.Mutate(x=>x.Fill(NamedColors.DarkBlue, new Rectangle(0* scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); + img.Mutate(x => x.Fill(NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); img.Mutate(x => x.Fill(NamedColors.HotPink, new Rectangle(20 * scaleX, 0 * scaleY, 30 * scaleX, 100 * scaleY), new ImageSharp.GraphicsOptions(true) { BlenderMode = mode @@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { var scaleX = (img.Width / 100); var scaleY = (img.Height / 100); - img.Mutate(x=>x.Fill(NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40, 100 * scaleX, 20* scaleY))); + img.Mutate(x => x.Fill(NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40, 100 * scaleX, 20 * scaleY))); img.Mutate(x => x.Fill(NamedColors.HotPink, new Rectangle(20 * scaleX, 0, 30 * scaleX, 100 * scaleY), new ImageSharp.GraphicsOptions(true) { BlenderMode = mode @@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { var scaleX = (img.Width / 100); var scaleY = (img.Height / 100); - img.Mutate(x => x.Fill(NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40* scaleY, 100 * scaleX, 20 * scaleY))); + img.Mutate(x => x.Fill(NamedColors.DarkBlue, new Rectangle(0 * scaleX, 40 * scaleY, 100 * scaleX, 20 * scaleY))); img.Mutate(x => x.Fill(NamedColors.Black, new SixLabors.Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY), new ImageSharp.GraphicsOptions(true) { BlenderMode = mode diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index e36396a4e..eb8e48b7e 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -5,6 +5,7 @@ using System; using System.Numerics; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Primitives; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs index 3902e874c..58aebb2df 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs @@ -1,19 +1,15 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.IO; using System.Numerics; using SixLabors.ImageSharp.Drawing.Pens; -using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; using Xunit; -using ShapePath = SixLabors.Shapes.Path; namespace SixLabors.ImageSharp.Tests.Drawing { - using SixLabors.ImageSharp.Processing; - using SixLabors.ImageSharp.Processing.Overlays; - public class DrawPathTests : FileTestBase { [Fact] @@ -31,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Vector2(60, 10), new Vector2(10, 400)); - ShapePath p = new ShapePath(linerSegemnt, bazierSegment); + Path p = new Path(linerSegemnt, bazierSegment); image.Mutate(x => x .BackgroundColor(Rgba32.Blue) @@ -69,7 +65,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Vector2(60, 10), new Vector2(10, 400)); - ShapePath p = new ShapePath(linerSegemnt, bazierSegment); + Path p = new Path(linerSegemnt, bazierSegment); using (Image image = new Image(500, 500)) { diff --git a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs index da2589ed5..79bf91803 100644 --- a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs @@ -7,6 +7,8 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Overlays; + using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing diff --git a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs index 21113f48c..48e3c6204 100644 --- a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs @@ -2,18 +2,18 @@ // Licensed under the Apache License, Version 2.0. using System.Numerics; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Pens; using SixLabors.ImageSharp.Drawing.Processors; using Moq; using Xunit; using SixLabors.ImageSharp.Drawing.Brushes; +using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Tests.Drawing { - using SixLabors.ImageSharp.Processing; - public class FillRegionProcessorTests { [Theory] diff --git a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs index 8eb8d2159..6cfd89b7b 100644 --- a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs @@ -1,12 +1,9 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.IO; using System.Numerics; -using SixLabors.ImageSharp.Drawing; + using SixLabors.ImageSharp.Drawing.Pens; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Drawing; using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/LineTests.cs b/tests/ImageSharp.Tests/Drawing/LineTests.cs index 7b26d9e1d..3659a4b28 100644 --- a/tests/ImageSharp.Tests/Drawing/LineTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineTests.cs @@ -1,11 +1,10 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.IO; using System.Numerics; -using SixLabors.ImageSharp.Drawing; + using SixLabors.ImageSharp.Drawing.Pens; -using SixLabors.ImageSharp.PixelFormats; + using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs index a88a5b09c..28820ceb4 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs @@ -1,13 +1,11 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using System.Numerics; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; -using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; using Xunit; @@ -28,7 +26,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths [Fact] public void CorrectlySetsBrushAndPath() { - this.operations.Fill(brush, path); + this.operations.Fill(this.brush, this.path); var processor = this.Verify>(); Assert.Equal(GraphicsOptions.Default, processor.Options); @@ -39,28 +37,28 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } [Fact] public void CorrectlySetsBrushPathOptions() { - this.operations.Fill(brush, path, noneDefault); + this.operations.Fill(this.brush, this.path, this.noneDefault); var processor = this.Verify>(); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } [Fact] public void CorrectlySetsColorAndPath() { - this.operations.Fill(color, path); + this.operations.Fill(this.color, this.path); var processor = this.Verify>(); Assert.Equal(GraphicsOptions.Default, processor.Options); @@ -70,23 +68,23 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } [Fact] public void CorrectlySetsColorPathAndOptions() { - this.operations.Fill(color, path, noneDefault); + this.operations.Fill(this.color, this.path, this.noneDefault); var processor = this.Verify>(); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } } } diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs index e8fad9d12..0b4a5e0bf 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs @@ -8,6 +8,8 @@ using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; using Xunit; @@ -35,13 +37,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths public FillPathCollection() { - this.pathCollection = new PathCollection(path1, path2); + this.pathCollection = new PathCollection(this.path1, this.path2); } [Fact] public void CorrectlySetsBrushAndPath() { - this.operations.Fill(brush, pathCollection); + this.operations.Fill(this.brush, this.pathCollection); for (var i = 0; i < 2; i++) { @@ -55,33 +57,33 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } } [Fact] public void CorrectlySetsBrushPathOptions() { - this.operations.Fill(brush, pathCollection, noneDefault); + this.operations.Fill(this.brush, this.pathCollection, this.noneDefault); for (var i = 0; i < 2; i++) { FillRegionProcessor processor = this.Verify>(i); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } } [Fact] public void CorrectlySetsColorAndPath() { - this.operations.Fill(color, pathCollection); + this.operations.Fill(this.color, this.pathCollection); for (var i = 0; i < 2; i++) { @@ -94,27 +96,27 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } } [Fact] public void CorrectlySetsColorPathAndOptions() { - this.operations.Fill(color, pathCollection, noneDefault); + this.operations.Fill(this.color, this.pathCollection, this.noneDefault); for (var i = 0; i < 2; i++) { FillRegionProcessor processor = this.Verify>(i); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } } } diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs index b390c3106..2cd63217f 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs @@ -1,13 +1,12 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; using System.Numerics; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Drawing; + using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; -using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Shapes; using Xunit; @@ -18,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; SolidBrush brush = Brushes.Solid(Rgba32.HotPink); - SixLabors.Primitives.PointF[] path = new SixLabors.Primitives.PointF[] { + SixLabors.Primitives.PointF[] path = { new Vector2(10,10), new Vector2(20,10), new Vector2(20,10), @@ -29,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths [Fact] public void CorrectlySetsBrushAndPath() { - this.operations.FillPolygon(brush, path); + this.operations.FillPolygon(this.brush, this.path); FillRegionProcessor processor = this.Verify>(); @@ -39,28 +38,28 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segemnt = Assert.IsType(polygon.LineSegments[0]); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } [Fact] public void CorrectlySetsBrushPathAndOptions() { - this.operations.FillPolygon(brush, path, noneDefault); + this.operations.FillPolygon(this.brush, this.path, this.noneDefault); FillRegionProcessor processor = this.Verify>(); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segemnt = Assert.IsType(polygon.LineSegments[0]); - Assert.Equal(brush, processor.Brush); + Assert.Equal(this.brush, processor.Brush); } [Fact] public void CorrectlySetsColorAndPath() { - this.operations.FillPolygon(color, path); + this.operations.FillPolygon(this.color, this.path); FillRegionProcessor processor = this.Verify>(); @@ -71,24 +70,24 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths LinearLineSegment segemnt = Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } [Fact] public void CorrectlySetsColorPathAndOptions() { - this.operations.FillPolygon(color, path, noneDefault); + this.operations.FillPolygon(this.color, this.path, this.noneDefault); FillRegionProcessor processor = this.Verify>(); - Assert.Equal(noneDefault, processor.Options); + Assert.Equal(this.noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segemnt = Assert.IsType(polygon.LineSegments[0]); SolidBrush brush = Assert.IsType>(processor.Brush); - Assert.Equal(color, brush.Color); + Assert.Equal(this.color, brush.Color); } } } diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs index 05e6bb29b..61c7b2b42 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs @@ -1,11 +1,10 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; using SixLabors.ImageSharp.Drawing.Processors; -using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Primitives; +using SixLabors.ImageSharp.Processing.Overlays; using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing.Paths @@ -58,7 +57,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths { this.operations.Fill(color, rectangle); FillRegionProcessor processor = this.Verify>(); - + Assert.Equal(GraphicsOptions.Default, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); diff --git a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs index 5ca09ad1d..d0912acee 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs @@ -1,6 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. +using SixLabors.ImageSharp.Primitives; + namespace SixLabors.ImageSharp.Tests.Drawing.Paths { using System; diff --git a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs index f2d5187e3..4265aa4d6 100644 --- a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs @@ -1,21 +1,14 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; using System.Numerics; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Drawing; using SixLabors.Primitives; +using SixLabors.ImageSharp.Processing; +using SixLabors.ImageSharp.Processing.Overlays; using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing { - using SixLabors.ImageSharp.Processing; - using SixLabors.ImageSharp.Processing.Overlays; - public class PolygonTests : FileTestBase { [Fact] diff --git a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs index baaa8fe2a..6207a8b0d 100644 --- a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs @@ -1,10 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.IO; -using System.Linq; using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Overlays; using SixLabors.Primitives; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs index 1fc1b172f..70b896cf8 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.IO; using System.Numerics; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Shapes; @@ -32,7 +31,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing using (Image image = provider.GetImage()) { - + image.Mutate(x => x .BackgroundColor(blue) .Fill(hotPink, new Polygon(new CubicBezierLineSegment(simplePath)))); @@ -53,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing new Vector2(300, 400) }; - Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); + var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); using (var image = provider.GetImage() as Image) { diff --git a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs index 59ddc43ed..a35bcb4f5 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs @@ -1,11 +1,8 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using System.IO; using System.Numerics; -using SixLabors.ImageSharp.Drawing; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Drawing; + using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs index fbb0f0095..1de6e59d6 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs @@ -2,13 +2,8 @@ // Licensed under the Apache License, Version 2.0. using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; using System.Numerics; -using SixLabors.ImageSharp.Drawing; using SixLabors.ImageSharp.Drawing.Brushes; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Tests.Drawing; using SixLabors.Shapes; using Xunit; @@ -23,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByFilledPolygon() { string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); - SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { + SixLabors.Primitives.PointF[] simplePath = { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs index 3f138248e..939a5bd65 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs @@ -10,6 +10,7 @@ using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.Drawing.Paths; using SixLabors.Fonts; +using SixLabors.ImageSharp.Processing.Text; using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs index d9fe1a76d..85234d0b5 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs @@ -10,6 +10,7 @@ using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Tests.Drawing.Paths; using SixLabors.Fonts; +using SixLabors.ImageSharp.Processing.Text; using SixLabors.Shapes; using Xunit; @@ -187,7 +188,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text } [Fact] - public void BrushAppliesBeforPen() + public void BrushAppliesBeforePen() { this.operations.DrawText( "1", diff --git a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs index 079510c33..908120d42 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs @@ -13,6 +13,8 @@ using SixLabors.ImageSharp.Drawing.Processors; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.Fonts; +using SixLabors.ImageSharp.Processing.Overlays; +using SixLabors.ImageSharp.Processing.Text; using SixLabors.Shapes; using Xunit; diff --git a/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs b/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs index 975622e43..dbbfa186e 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs @@ -8,6 +8,8 @@ using System.Numerics; using System.Threading.Tasks; using SixLabors.ImageSharp.Drawing; using SixLabors.Fonts; +using SixLabors.ImageSharp.Processing.Text; + using Xunit; namespace SixLabors.ImageSharp.Tests.Drawing.Text diff --git a/tests/ImageSharp.Tests/Issues/Issue412.cs b/tests/ImageSharp.Tests/Issues/Issue412.cs index 77db68281..8d4e360a5 100644 --- a/tests/ImageSharp.Tests/Issues/Issue412.cs +++ b/tests/ImageSharp.Tests/Issues/Issue412.cs @@ -1,10 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Text; -using SixLabors.Primitives; -using SixLabors.ImageSharp.Advanced; +using SixLabors.Primitives; + using Xunit; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Overlays; namespace SixLabors.ImageSharp.Tests.Issues { @@ -14,7 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Issues { [Theory] [WithBlankImages(40, 30, PixelTypes.Rgba32)] - public void AllPixelsExpectedToBeRedWhenAntialisedDisabled(TestImageProvider provider) where TPixel : struct, IPixel + public void AllPixelsExpectedToBeRedWhenAntialiasedDisabled(TestImageProvider provider) where TPixel : struct, IPixel { using (var image = provider.GetImage()) { diff --git a/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs index ceb25d58e..ddb9a6d1d 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs @@ -1,9 +1,6 @@ // Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing.Processors; -using SixLabors.Primitives; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Effects @@ -20,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Effects var processor = this.Verify>(); Assert.Equal(GraphicsOptions.Default, processor.GraphicsOptions); - Assert.Equal(Rgba32.BlanchedAlmond, processor.Value); + Assert.Equal(Rgba32.BlanchedAlmond, processor.Color); } [Fact] @@ -30,7 +27,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Effects var processor = this.Verify>(this.rect); Assert.Equal(GraphicsOptions.Default, processor.GraphicsOptions); - Assert.Equal(Rgba32.BlanchedAlmond, processor.Value); + Assert.Equal(Rgba32.BlanchedAlmond, processor.Color); } [Fact] @@ -40,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Effects var processor = this.Verify>(); Assert.Equal(this.options, processor.GraphicsOptions); - Assert.Equal(Rgba32.BlanchedAlmond, processor.Value); + Assert.Equal(Rgba32.BlanchedAlmond, processor.Color); } [Fact] @@ -50,7 +47,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Effects var processor = this.Verify>(this.rect); Assert.Equal(this.options, processor.GraphicsOptions); - Assert.Equal(Rgba32.BlanchedAlmond, processor.Value); + Assert.Equal(Rgba32.BlanchedAlmond, processor.Color); } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs index 9901661f4..c06902071 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs @@ -4,6 +4,7 @@ using System; using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing.Overlays; using Xunit.Abstractions;