diff --git a/ImageSharp.sln b/ImageSharp.sln index 2e0cbd52e9..ef15dc734e 100644 --- a/ImageSharp.sln +++ b/ImageSharp.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26403.7 +VisualStudioVersion = 15.0.26430.6 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{C317F1B1-D75E-4C6D-83EB-80367343E0D7}" ProjectSection(SolutionItems) = preProject @@ -45,6 +45,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Benchmarks", "te EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageSharp.Sandbox46", "tests\ImageSharp.Sandbox46\ImageSharp.Sandbox46.csproj", "{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scratch", "Scratch\Scratch.csproj", "{615D14B2-3092-45E7-BA72-817C131E8018}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -127,6 +129,18 @@ Global {96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Release|x64.Build.0 = Release|Any CPU {96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Release|x86.ActiveCfg = Release|Any CPU {96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Release|x86.Build.0 = Release|Any CPU + {615D14B2-3092-45E7-BA72-817C131E8018}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {615D14B2-3092-45E7-BA72-817C131E8018}.Debug|Any CPU.Build.0 = Debug|Any CPU + {615D14B2-3092-45E7-BA72-817C131E8018}.Debug|x64.ActiveCfg = Debug|Any CPU + {615D14B2-3092-45E7-BA72-817C131E8018}.Debug|x64.Build.0 = Debug|Any CPU + {615D14B2-3092-45E7-BA72-817C131E8018}.Debug|x86.ActiveCfg = Debug|Any CPU + {615D14B2-3092-45E7-BA72-817C131E8018}.Debug|x86.Build.0 = Debug|Any CPU + {615D14B2-3092-45E7-BA72-817C131E8018}.Release|Any CPU.ActiveCfg = Release|Any CPU + {615D14B2-3092-45E7-BA72-817C131E8018}.Release|Any CPU.Build.0 = Release|Any CPU + {615D14B2-3092-45E7-BA72-817C131E8018}.Release|x64.ActiveCfg = Release|Any CPU + {615D14B2-3092-45E7-BA72-817C131E8018}.Release|x64.Build.0 = Release|Any CPU + {615D14B2-3092-45E7-BA72-817C131E8018}.Release|x86.ActiveCfg = Release|Any CPU + {615D14B2-3092-45E7-BA72-817C131E8018}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -139,5 +153,6 @@ Global {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC} {2BF743D8-2A06-412D-96D7-F448F00C5EA5} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC} {96188137-5FA6-4924-AB6E-4EFF79C6E0BB} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC} + {615D14B2-3092-45E7-BA72-817C131E8018} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC} EndGlobalSection EndGlobal diff --git a/Scratch/Program.cs b/Scratch/Program.cs new file mode 100644 index 0000000000..b3be8af01f --- /dev/null +++ b/Scratch/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Numerics; +using ImageSharp; + +namespace Scratch +{ + class Program + { + static void Main(string[] args) + { + using (var image = Image.Load(@"C:\Users\tocso\Desktop\92d8758c-471c-11e7-81d8-62ec301b092a (1).jpg")) { + + //image.Fill(Rgba32.Beige, b => b.AddBezier(Vector2.UnitX, Vector2.UnitX, Vector2.UnitX, Vector2.UnitX)); + + image.Resize(640, 480) + .Save(@"C:\Users\tocso\Desktop\92d8758c-471c-11e7-81d8-62ec301b092a (1)-saved.jpg"); + } + } + } +} \ No newline at end of file diff --git a/Scratch/Scratch.csproj b/Scratch/Scratch.csproj new file mode 100644 index 0000000000..99b199b0ad --- /dev/null +++ b/Scratch/Scratch.csproj @@ -0,0 +1,13 @@ + + + + Exe + netcoreapp1.1 + + + + + + + + \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Brushes/IBrush.cs b/src/ImageSharp.Drawing/Brushes/IBrush.cs index 8cb7317823..33b516e5c2 100644 --- a/src/ImageSharp.Drawing/Brushes/IBrush.cs +++ b/src/ImageSharp.Drawing/Brushes/IBrush.cs @@ -7,6 +7,7 @@ namespace ImageSharp.Drawing { using ImageSharp.PixelFormats; using Processors; + using SixLabors.Primitives; /// /// Brush represents a logical configuration of a brush which can be used to source pixel colors diff --git a/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs index 59dbd39266..57fcd8ffa6 100644 --- a/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Drawing.Brushes using ImageSharp.Memory; using ImageSharp.PixelFormats; using Processors; + using SixLabors.Primitives; /// /// Provides an implementation of an image brush for painting images within areas. diff --git a/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs index 5dd57bda66..5fcb92bdc7 100644 --- a/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Drawing.Brushes using ImageSharp.Memory; using ImageSharp.PixelFormats; using Processors; + using SixLabors.Primitives; /// /// Provides an implementation of a pattern brush for painting patterns. diff --git a/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs index 96d824b2fc..27aa99b975 100644 --- a/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Drawing.Brushes using ImageSharp.Memory; using ImageSharp.PixelFormats; using Processors; + using SixLabors.Primitives; /// /// Provides an implementation of a brush that can recolor an image diff --git a/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs index 453b4d29ef..21ebb88a04 100644 --- a/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Drawing.Brushes using ImageSharp.Memory; using ImageSharp.PixelFormats; using Processors; + using SixLabors.Primitives; /// /// Provides an implementation of a solid brush for painting solid color areas. diff --git a/src/ImageSharp.Drawing/DrawImage.cs b/src/ImageSharp.Drawing/DrawImage.cs index db40132c8a..03eb7be289 100644 --- a/src/ImageSharp.Drawing/DrawImage.cs +++ b/src/ImageSharp.Drawing/DrawImage.cs @@ -7,6 +7,7 @@ namespace ImageSharp { using Drawing.Processors; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index 13500b65af..10562b08ca 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -36,7 +36,7 @@ - + All diff --git a/src/ImageSharp.Drawing/Paths/DrawBeziers.cs b/src/ImageSharp.Drawing/Paths/DrawBeziers.cs index c4ea8c3785..59bcf40363 100644 --- a/src/ImageSharp.Drawing/Paths/DrawBeziers.cs +++ b/src/ImageSharp.Drawing/Paths/DrawBeziers.cs @@ -10,6 +10,7 @@ namespace ImageSharp using Drawing.Brushes; using Drawing.Pens; using ImageSharp.PixelFormats; + using SixLabors.Primitives; using SixLabors.Shapes; /// @@ -27,10 +28,10 @@ namespace ImageSharp /// The points. /// The options. /// The . - public static Image DrawBeziers(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options) + public static Image DrawBeziers(this Image source, IBrush brush, float thickness, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), new Path(new BezierLineSegment(points)), options); + return source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)), options); } /// @@ -42,10 +43,10 @@ namespace ImageSharp /// The thickness. /// The points. /// The . - public static Image DrawBeziers(this Image source, IBrush brush, float thickness, Vector2[] points) + public static Image DrawBeziers(this Image source, IBrush brush, float thickness, PointF[] points) where TPixel : struct, IPixel { - return source.Draw(new Pen(brush, thickness), new Path(new BezierLineSegment(points))); + return source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points))); } /// @@ -57,7 +58,7 @@ namespace ImageSharp /// The thickness. /// The points. /// The . - public static Image DrawBeziers(this Image source, TPixel color, float thickness, Vector2[] points) + public static Image DrawBeziers(this Image source, TPixel color, float thickness, PointF[] points) where TPixel : struct, IPixel { return source.DrawBeziers(new SolidBrush(color), thickness, points); @@ -73,7 +74,7 @@ namespace ImageSharp /// The points. /// The options. /// The . - public static Image DrawBeziers(this Image source, TPixel color, float thickness, Vector2[] points, GraphicsOptions options) + public static Image DrawBeziers(this Image source, TPixel color, float thickness, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel { return source.DrawBeziers(new SolidBrush(color), thickness, points, options); @@ -88,10 +89,10 @@ namespace ImageSharp /// The points. /// The options. /// The . - public static Image DrawBeziers(this Image source, IPen pen, Vector2[] points, GraphicsOptions options) + public static Image DrawBeziers(this Image source, IPen pen, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel { - return source.Draw(pen, new Path(new BezierLineSegment(points)), options); + return source.Draw(pen, new Path(new CubicBezierLineSegment(points)), options); } /// @@ -102,10 +103,10 @@ namespace ImageSharp /// The pen. /// The points. /// The . - public static Image DrawBeziers(this Image source, IPen pen, Vector2[] points) + public static Image DrawBeziers(this Image source, IPen pen, PointF[] points) where TPixel : struct, IPixel { - return source.Draw(pen, new Path(new BezierLineSegment(points))); + return source.Draw(pen, new Path(new CubicBezierLineSegment(points))); } } } diff --git a/src/ImageSharp.Drawing/Paths/DrawLines.cs b/src/ImageSharp.Drawing/Paths/DrawLines.cs index e8c463638f..3ce0dc4da6 100644 --- a/src/ImageSharp.Drawing/Paths/DrawLines.cs +++ b/src/ImageSharp.Drawing/Paths/DrawLines.cs @@ -10,6 +10,7 @@ namespace ImageSharp using Drawing.Brushes; using Drawing.Pens; using ImageSharp.PixelFormats; + using SixLabors.Primitives; using SixLabors.Shapes; /// @@ -27,7 +28,7 @@ namespace ImageSharp /// The points. /// The options. /// The . - public static Image DrawLines(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options) + public static Image DrawLines(this Image 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); @@ -42,7 +43,7 @@ namespace ImageSharp /// The thickness. /// The points. /// The . - public static Image DrawLines(this Image source, IBrush brush, float thickness, Vector2[] points) + public static Image DrawLines(this Image source, IBrush brush, float thickness, PointF[] points) where TPixel : struct, IPixel { return source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points))); @@ -57,7 +58,7 @@ namespace ImageSharp /// The thickness. /// The points. /// The . - public static Image DrawLines(this Image source, TPixel color, float thickness, Vector2[] points) + public static Image DrawLines(this Image source, TPixel color, float thickness, PointF[] points) where TPixel : struct, IPixel { return source.DrawLines(new SolidBrush(color), thickness, points); @@ -73,7 +74,7 @@ namespace ImageSharp /// The points. /// The options. /// The .> - public static Image DrawLines(this Image source, TPixel color, float thickness, Vector2[] points, GraphicsOptions options) + public static Image DrawLines(this Image source, TPixel color, float thickness, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel { return source.DrawLines(new SolidBrush(color), thickness, points, options); @@ -88,7 +89,7 @@ namespace ImageSharp /// The points. /// The options. /// The . - public static Image DrawLines(this Image source, IPen pen, Vector2[] points, GraphicsOptions options) + public static Image DrawLines(this Image source, IPen pen, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel { return source.Draw(pen, new Path(new LinearLineSegment(points)), options); @@ -102,7 +103,7 @@ namespace ImageSharp /// The pen. /// The points. /// The . - public static Image DrawLines(this Image source, IPen pen, Vector2[] points) + public static Image DrawLines(this Image source, IPen pen, PointF[] points) where TPixel : struct, IPixel { return source.Draw(pen, new Path(new LinearLineSegment(points))); diff --git a/src/ImageSharp.Drawing/Paths/DrawPolygon.cs b/src/ImageSharp.Drawing/Paths/DrawPolygon.cs index 4b99e60c02..4fa469a496 100644 --- a/src/ImageSharp.Drawing/Paths/DrawPolygon.cs +++ b/src/ImageSharp.Drawing/Paths/DrawPolygon.cs @@ -10,6 +10,7 @@ namespace ImageSharp using Drawing.Brushes; using Drawing.Pens; using ImageSharp.PixelFormats; + using SixLabors.Primitives; using SixLabors.Shapes; /// @@ -27,7 +28,7 @@ namespace ImageSharp /// The points. /// The options. /// The . - public static Image DrawPolygon(this Image source, IBrush brush, float thickness, Vector2[] points, GraphicsOptions options) + public static Image DrawPolygon(this Image 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); @@ -42,7 +43,7 @@ namespace ImageSharp /// The thickness. /// The points. /// The . - public static Image DrawPolygon(this Image source, IBrush brush, float thickness, Vector2[] points) + public static Image DrawPolygon(this Image source, IBrush brush, float thickness, PointF[] points) where TPixel : struct, IPixel { return source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points))); @@ -57,7 +58,7 @@ namespace ImageSharp /// The thickness. /// The points. /// The . - public static Image DrawPolygon(this Image source, TPixel color, float thickness, Vector2[] points) + public static Image DrawPolygon(this Image source, TPixel color, float thickness, PointF[] points) where TPixel : struct, IPixel { return source.DrawPolygon(new SolidBrush(color), thickness, points); @@ -73,7 +74,7 @@ namespace ImageSharp /// The points. /// The options. /// The . - public static Image DrawPolygon(this Image source, TPixel color, float thickness, Vector2[] points, GraphicsOptions options) + public static Image DrawPolygon(this Image source, TPixel color, float thickness, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel { return source.DrawPolygon(new SolidBrush(color), thickness, points, options); @@ -87,7 +88,7 @@ namespace ImageSharp /// The pen. /// The points. /// The . - public static Image DrawPolygon(this Image source, IPen pen, Vector2[] points) + public static Image DrawPolygon(this Image source, IPen pen, PointF[] points) where TPixel : struct, IPixel { return source.Draw(pen, new Polygon(new LinearLineSegment(points)), GraphicsOptions.Default); @@ -102,7 +103,7 @@ namespace ImageSharp /// The points. /// The options. /// The . - public static Image DrawPolygon(this Image source, IPen pen, Vector2[] points, GraphicsOptions options) + public static Image DrawPolygon(this Image source, IPen pen, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel { return source.Draw(pen, new Polygon(new LinearLineSegment(points)), options); diff --git a/src/ImageSharp.Drawing/Paths/DrawRectangle.cs b/src/ImageSharp.Drawing/Paths/DrawRectangle.cs index 0fefc6cab4..b3f0e6fc3b 100644 --- a/src/ImageSharp.Drawing/Paths/DrawRectangle.cs +++ b/src/ImageSharp.Drawing/Paths/DrawRectangle.cs @@ -9,6 +9,7 @@ namespace ImageSharp using Drawing.Brushes; using Drawing.Pens; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Extension methods for the type. @@ -24,10 +25,10 @@ namespace ImageSharp /// The shape. /// The options. /// The . - public static Image Draw(this Image source, IPen pen, Rectangle shape, GraphicsOptions options) + public static Image Draw(this Image source, IPen pen, RectangleF shape, GraphicsOptions options) where TPixel : struct, IPixel { - return source.Draw(pen, new SixLabors.Shapes.Rectangle(shape.X, shape.Y, shape.Width, shape.Height), options); + return source.Draw(pen, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options); } /// @@ -38,7 +39,7 @@ namespace ImageSharp /// The pen. /// The shape. /// The . - public static Image Draw(this Image source, IPen pen, Rectangle shape) + public static Image Draw(this Image source, IPen pen, RectangleF shape) where TPixel : struct, IPixel { return source.Draw(pen, shape, GraphicsOptions.Default); @@ -54,7 +55,7 @@ namespace ImageSharp /// The shape. /// The options. /// The . - public static Image Draw(this Image source, IBrush brush, float thickness, Rectangle shape, GraphicsOptions options) + public static Image Draw(this Image source, IBrush brush, float thickness, RectangleF shape, GraphicsOptions options) where TPixel : struct, IPixel { return source.Draw(new Pen(brush, thickness), shape, options); @@ -69,7 +70,7 @@ namespace ImageSharp /// The thickness. /// The shape. /// The . - public static Image Draw(this Image source, IBrush brush, float thickness, Rectangle shape) + public static Image Draw(this Image source, IBrush brush, float thickness, RectangleF shape) where TPixel : struct, IPixel { return source.Draw(new Pen(brush, thickness), shape); @@ -85,7 +86,7 @@ namespace ImageSharp /// The shape. /// The options. /// The . - public static Image Draw(this Image source, TPixel color, float thickness, Rectangle shape, GraphicsOptions options) + public static Image Draw(this Image source, TPixel color, float thickness, RectangleF shape, GraphicsOptions options) where TPixel : struct, IPixel { return source.Draw(new SolidBrush(color), thickness, shape, options); @@ -100,7 +101,7 @@ namespace ImageSharp /// The thickness. /// The shape. /// The . - public static Image Draw(this Image source, TPixel color, float thickness, Rectangle shape) + public static Image Draw(this Image source, TPixel color, float thickness, RectangleF shape) where TPixel : struct, IPixel { return source.Draw(new SolidBrush(color), thickness, shape); diff --git a/src/ImageSharp.Drawing/Paths/FillPathBuilder.cs b/src/ImageSharp.Drawing/Paths/FillPathBuilder.cs new file mode 100644 index 0000000000..abb5ef73a7 --- /dev/null +++ b/src/ImageSharp.Drawing/Paths/FillPathBuilder.cs @@ -0,0 +1,80 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using Drawing; + using Drawing.Brushes; + using ImageSharp.PixelFormats; + using SixLabors.Shapes; + + /// + /// Extension methods for the type. + /// + public static partial class ImageExtensions + { + /// + /// 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. + /// The brush. + /// The shape. + /// The graphics options. + /// The . + public static Image Fill(this Image source, IBrush brush, Action path, GraphicsOptions options) + where TPixel : struct, IPixel + { + var pb = new PathBuilder(); + path(pb); + + return source.Fill(brush, pb.Build(), options); + } + + /// + /// 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. + /// The brush. + /// The path. + /// The . + public static Image Fill(this Image source, IBrush brush, Action path) + where TPixel : struct, IPixel + { + return source.Fill(brush, path, GraphicsOptions.Default); + } + + /// + /// 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. + /// The color. + /// The path. + /// The options. + /// The . + public static Image Fill(this Image source, TPixel color, Action path, GraphicsOptions options) + where TPixel : struct, IPixel + { + return source.Fill(new SolidBrush(color), path, options); + } + + /// + /// 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. + /// The color. + /// The path. + /// The . + public static Image Fill(this Image source, TPixel color, Action path) + where TPixel : struct, IPixel + { + return source.Fill(new SolidBrush(color), path); + } + } +} diff --git a/src/ImageSharp.Drawing/Paths/FillPolygon.cs b/src/ImageSharp.Drawing/Paths/FillPolygon.cs index 3360cff13c..6266d3bd64 100644 --- a/src/ImageSharp.Drawing/Paths/FillPolygon.cs +++ b/src/ImageSharp.Drawing/Paths/FillPolygon.cs @@ -10,6 +10,7 @@ namespace ImageSharp using Drawing; using Drawing.Brushes; using ImageSharp.PixelFormats; + using SixLabors.Primitives; using SixLabors.Shapes; /// @@ -26,7 +27,7 @@ namespace ImageSharp /// The points. /// The options. /// The . - public static Image FillPolygon(this Image source, IBrush brush, Vector2[] points, GraphicsOptions options) + public static Image FillPolygon(this Image source, IBrush brush, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel { return source.Fill(brush, new Polygon(new LinearLineSegment(points)), options); @@ -40,7 +41,7 @@ namespace ImageSharp /// The brush. /// The points. /// The . - public static Image FillPolygon(this Image source, IBrush brush, Vector2[] points) + public static Image FillPolygon(this Image source, IBrush brush, PointF[] points) where TPixel : struct, IPixel { return source.Fill(brush, new Polygon(new LinearLineSegment(points))); @@ -55,7 +56,7 @@ namespace ImageSharp /// The points. /// The options. /// The . - public static Image FillPolygon(this Image source, TPixel color, Vector2[] points, GraphicsOptions options) + public static Image FillPolygon(this Image source, TPixel color, PointF[] points, GraphicsOptions options) where TPixel : struct, IPixel { return source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points)), options); @@ -69,7 +70,7 @@ namespace ImageSharp /// The color. /// The points. /// The . - public static Image FillPolygon(this Image source, TPixel color, Vector2[] points) + public static Image FillPolygon(this Image source, TPixel color, PointF[] points) where TPixel : struct, IPixel { return source.Fill(new SolidBrush(color), new Polygon(new LinearLineSegment(points))); diff --git a/src/ImageSharp.Drawing/Paths/FillRectangle.cs b/src/ImageSharp.Drawing/Paths/FillRectangle.cs index 07ff4c69c5..bd6460cf90 100644 --- a/src/ImageSharp.Drawing/Paths/FillRectangle.cs +++ b/src/ImageSharp.Drawing/Paths/FillRectangle.cs @@ -8,6 +8,7 @@ namespace ImageSharp using Drawing; using Drawing.Brushes; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Extension methods for the type. @@ -23,10 +24,10 @@ namespace ImageSharp /// The shape. /// The options. /// The . - public static Image Fill(this Image source, IBrush brush, Rectangle shape, GraphicsOptions options) + public static Image Fill(this Image source, IBrush brush, RectangleF shape, GraphicsOptions options) where TPixel : struct, IPixel { - return source.Fill(brush, new SixLabors.Shapes.Rectangle(shape.X, shape.Y, shape.Width, shape.Height), options); + return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options); } /// @@ -37,10 +38,10 @@ namespace ImageSharp /// The brush. /// The shape. /// The . - public static Image Fill(this Image source, IBrush brush, Rectangle shape) + public static Image Fill(this Image source, IBrush brush, RectangleF shape) where TPixel : struct, IPixel { - return source.Fill(brush, new SixLabors.Shapes.Rectangle(shape.X, shape.Y, shape.Width, shape.Height)); + return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height)); } /// @@ -52,7 +53,7 @@ namespace ImageSharp /// The shape. /// The options. /// The . - public static Image Fill(this Image source, TPixel color, Rectangle shape, GraphicsOptions options) + public static Image Fill(this Image source, TPixel color, RectangleF shape, GraphicsOptions options) where TPixel : struct, IPixel { return source.Fill(new SolidBrush(color), shape, options); @@ -66,7 +67,7 @@ namespace ImageSharp /// The color. /// The shape. /// The . - public static Image Fill(this Image source, TPixel color, Rectangle shape) + public static Image Fill(this Image source, TPixel color, RectangleF shape) where TPixel : struct, IPixel { return source.Fill(new SolidBrush(color), shape); diff --git a/src/ImageSharp.Drawing/Paths/RectangleExtensions.cs b/src/ImageSharp.Drawing/Paths/RectangleExtensions.cs deleted file mode 100644 index 1b5df75742..0000000000 --- a/src/ImageSharp.Drawing/Paths/RectangleExtensions.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Drawing -{ - using System; - - /// - /// Extension methods for helping to bridge Shaper2D and ImageSharp primitives. - /// - internal static class RectangleExtensions - { - /// - /// Converts a Shaper2D to an ImageSharp by creating a the entirely surrounds the source. - /// - /// The image this method extends. - /// A representation of this - public static Rectangle Convert(this SixLabors.Shapes.Rectangle source) - { - int left = (int)MathF.Floor(source.Left); - int right = (int)MathF.Ceiling(source.Right); - int top = (int)MathF.Floor(source.Top); - int bottom = (int)MathF.Ceiling(source.Bottom); - return new Rectangle(left, top, right - left, bottom - top); - } - } -} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Paths/ShapePath.cs b/src/ImageSharp.Drawing/Paths/ShapePath.cs index 63c814f2d5..ec4f222e09 100644 --- a/src/ImageSharp.Drawing/Paths/ShapePath.cs +++ b/src/ImageSharp.Drawing/Paths/ShapePath.cs @@ -11,8 +11,6 @@ namespace ImageSharp.Drawing using SixLabors.Shapes; - using Rectangle = ImageSharp.Rectangle; - /// /// A mapping between a and a region. /// diff --git a/src/ImageSharp.Drawing/Paths/ShapeRegion.cs b/src/ImageSharp.Drawing/Paths/ShapeRegion.cs index 9dbf52285b..51093c5d9c 100644 --- a/src/ImageSharp.Drawing/Paths/ShapeRegion.cs +++ b/src/ImageSharp.Drawing/Paths/ShapeRegion.cs @@ -8,11 +8,9 @@ namespace ImageSharp.Drawing using System; using System.Buffers; using System.Numerics; - + using SixLabors.Primitives; using SixLabors.Shapes; - using Rectangle = ImageSharp.Rectangle; - /// /// A mapping between a and a region. /// @@ -25,7 +23,12 @@ namespace ImageSharp.Drawing public ShapeRegion(IPath shape) { this.Shape = shape.AsClosedPath(); - this.Bounds = shape.Bounds.Convert(); + int left = (int)MathF.Floor(shape.Bounds.Left); + int top = (int)MathF.Floor(shape.Bounds.Top); + + int right = (int)MathF.Ceiling(shape.Bounds.Right); + int bottom = (int)MathF.Ceiling(shape.Bounds.Bottom); + this.Bounds = Rectangle.FromLTRB(left, top, right, bottom); } /// @@ -42,12 +45,12 @@ namespace ImageSharp.Drawing /// public override int Scan(float y, Span buffer) { - Vector2 start = new Vector2(this.Bounds.Left - 1, y); - Vector2 end = new Vector2(this.Bounds.Right + 1, y); - Vector2[] innerbuffer = ArrayPool.Shared.Rent(buffer.Length); + PointF start = new PointF(this.Bounds.Left - 1, y); + PointF end = new PointF(this.Bounds.Right + 1, y); + PointF[] innerbuffer = ArrayPool.Shared.Rent(buffer.Length); try { - int count = this.Shape.FindIntersections(start, end, innerbuffer, buffer.Length, 0); + int count = this.Shape.FindIntersections(start, end, innerbuffer); for (int i = 0; i < count; i++) { @@ -58,7 +61,7 @@ namespace ImageSharp.Drawing } finally { - ArrayPool.Shared.Return(innerbuffer); + ArrayPool.Shared.Return(innerbuffer); } } } diff --git a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs index ed45417fc9..62344b1012 100644 --- a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs @@ -12,6 +12,7 @@ namespace ImageSharp.Drawing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; using ImageSharp.Processing; + using SixLabors.Primitives; /// /// Combines two images together by blending the pixels. diff --git a/src/ImageSharp.Drawing/Processors/FillProcessor.cs b/src/ImageSharp.Drawing/Processors/FillProcessor.cs index 8c7cd4e8c5..6eb12cf488 100644 --- a/src/ImageSharp.Drawing/Processors/FillProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/FillProcessor.cs @@ -14,6 +14,7 @@ namespace ImageSharp.Drawing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; using ImageSharp.Processing; + using SixLabors.Primitives; /// /// Using the bursh as a source of pixels colors blends the brush color with source. diff --git a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs b/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs index f2e09d2897..c398824323 100644 --- a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs @@ -13,6 +13,7 @@ namespace ImageSharp.Drawing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; using ImageSharp.Processing; + using SixLabors.Primitives; /// /// Usinf a brsuh and a shape fills shape with contents of brush the diff --git a/src/ImageSharp.Drawing/Region.cs b/src/ImageSharp.Drawing/Region.cs index 687ee23fdd..23028b9a8f 100644 --- a/src/ImageSharp.Drawing/Region.cs +++ b/src/ImageSharp.Drawing/Region.cs @@ -6,6 +6,7 @@ namespace ImageSharp.Drawing { using System; + using SixLabors.Primitives; /// /// Represents a region of an image. diff --git a/src/ImageSharp.Drawing/Text/DrawText.Path.cs b/src/ImageSharp.Drawing/Text/DrawText.Path.cs index 2bc23b64bc..523813188a 100644 --- a/src/ImageSharp.Drawing/Text/DrawText.Path.cs +++ b/src/ImageSharp.Drawing/Text/DrawText.Path.cs @@ -166,13 +166,15 @@ namespace ImageSharp public static Image DrawText(this Image source, string text, Font font, IBrush brush, IPen pen, IPath path, TextGraphicsOptions options) where TPixel : struct, IPixel { - Vector2 dpi = DefaultTextDpi; + float dpiX = DefaultTextDpi; + float dpiY = DefaultTextDpi; if (options.UseImageResolution) { - dpi = new Vector2((float)source.MetaData.HorizontalResolution, (float)source.MetaData.VerticalResolution); + dpiX = (float)source.MetaData.HorizontalResolution; + dpiY = (float)source.MetaData.VerticalResolution; } - var style = new FontSpan(font, dpi) + var style = new RendererOptions(font, dpiX, dpiY) { ApplyKerning = options.ApplyKerning, TabWidth = options.TabWidth, diff --git a/src/ImageSharp.Drawing/Text/DrawText.cs b/src/ImageSharp.Drawing/Text/DrawText.cs index 3b0d3db411..6352836a9c 100644 --- a/src/ImageSharp.Drawing/Text/DrawText.cs +++ b/src/ImageSharp.Drawing/Text/DrawText.cs @@ -12,6 +12,7 @@ namespace ImageSharp using Drawing.Pens; using ImageSharp.PixelFormats; using SixLabors.Fonts; + using SixLabors.Primitives; using SixLabors.Shapes; /// @@ -19,7 +20,7 @@ namespace ImageSharp /// public static partial class ImageExtensions { - private static readonly Vector2 DefaultTextDpi = new Vector2(72); + private static readonly int DefaultTextDpi = 72; /// /// Draws the text onto the the image filled via the brush. @@ -33,7 +34,7 @@ namespace ImageSharp /// /// The . /// - public static Image DrawText(this Image source, string text, Font font, TPixel color, Vector2 location) + public static Image DrawText(this Image source, string text, Font font, TPixel color, PointF location) where TPixel : struct, IPixel { return source.DrawText(text, font, color, location, TextGraphicsOptions.Default); @@ -52,7 +53,7 @@ namespace ImageSharp /// /// The . /// - public static Image DrawText(this Image source, string text, Font font, TPixel color, Vector2 location, TextGraphicsOptions options) + public static Image DrawText(this Image 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); @@ -70,7 +71,7 @@ namespace ImageSharp /// /// The . /// - public static Image DrawText(this Image source, string text, Font font, IBrush brush, Vector2 location) + public static Image DrawText(this Image source, string text, Font font, IBrush brush, PointF location) where TPixel : struct, IPixel { return source.DrawText(text, font, brush, location, TextGraphicsOptions.Default); @@ -89,7 +90,7 @@ namespace ImageSharp /// /// The . /// - public static Image DrawText(this Image source, string text, Font font, IBrush brush, Vector2 location, TextGraphicsOptions options) + public static Image DrawText(this Image source, string text, Font font, IBrush brush, PointF location, TextGraphicsOptions options) where TPixel : struct, IPixel { return source.DrawText(text, font, brush, null, location, options); @@ -107,7 +108,7 @@ namespace ImageSharp /// /// The . /// - public static Image DrawText(this Image source, string text, Font font, IPen pen, Vector2 location) + public static Image DrawText(this Image source, string text, Font font, IPen pen, PointF location) where TPixel : struct, IPixel { return source.DrawText(text, font, pen, location, TextGraphicsOptions.Default); @@ -126,7 +127,7 @@ namespace ImageSharp /// /// The . /// - public static Image DrawText(this Image source, string text, Font font, IPen pen, Vector2 location, TextGraphicsOptions options) + public static Image DrawText(this Image source, string text, Font font, IPen pen, PointF location, TextGraphicsOptions options) where TPixel : struct, IPixel { return source.DrawText(text, font, null, pen, location, options); @@ -145,7 +146,7 @@ namespace ImageSharp /// /// The . /// - public static Image DrawText(this Image source, string text, Font font, IBrush brush, IPen pen, Vector2 location) + public static Image DrawText(this Image 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); @@ -165,16 +166,18 @@ namespace ImageSharp /// /// The . /// - public static Image DrawText(this Image source, string text, Font font, IBrush brush, IPen pen, Vector2 location, TextGraphicsOptions options) + public static Image DrawText(this Image source, string text, Font font, IBrush brush, IPen pen, PointF location, TextGraphicsOptions options) where TPixel : struct, IPixel { - Vector2 dpi = DefaultTextDpi; + float dpiX = DefaultTextDpi; + float dpiY = DefaultTextDpi; if (options.UseImageResolution) { - dpi = new Vector2((float)source.MetaData.HorizontalResolution, (float)source.MetaData.VerticalResolution); + dpiX = (float)source.MetaData.HorizontalResolution; + dpiY = (float)source.MetaData.VerticalResolution; } - var style = new FontSpan(font, dpi) + var style = new RendererOptions(font, dpiX, dpiY, location) { ApplyKerning = options.ApplyKerning, TabWidth = options.TabWidth, @@ -183,7 +186,7 @@ namespace ImageSharp VerticalAlignment = options.VerticalAlignment }; - IPathCollection glyphs = TextBuilder.GenerateGlyphs(text, location, style); + IPathCollection glyphs = TextBuilder.GenerateGlyphs(text, style); var pathOptions = (GraphicsOptions)options; if (brush != null) diff --git a/src/ImageSharp/Common/Helpers/ImageMaths.cs b/src/ImageSharp/Common/Helpers/ImageMaths.cs index 9c4dee5033..367aa12d00 100644 --- a/src/ImageSharp/Common/Helpers/ImageMaths.cs +++ b/src/ImageSharp/Common/Helpers/ImageMaths.cs @@ -11,6 +11,7 @@ namespace ImageSharp using System.Runtime.CompilerServices; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Provides common mathematical methods. diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 5b56c4c02f..ef0331c0d9 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -12,6 +12,7 @@ namespace ImageSharp.Formats using System.Text; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Performs the gif decoding operation. diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/YCbCrImage.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/YCbCrImage.cs index 89e327f0db..c9cc327b86 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/YCbCrImage.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/YCbCrImage.cs @@ -8,6 +8,7 @@ namespace ImageSharp.Formats.Jpg using System.Buffers; using ImageSharp.Memory; + using SixLabors.Primitives; /// /// Represents an image made up of three color components (luminance, blue chroma, red chroma) diff --git a/src/ImageSharp/Image/IImageBase.cs b/src/ImageSharp/Image/IImageBase.cs index 393d83077a..0e087aa4a3 100644 --- a/src/ImageSharp/Image/IImageBase.cs +++ b/src/ImageSharp/Image/IImageBase.cs @@ -5,6 +5,8 @@ namespace ImageSharp { + using SixLabors.Primitives; + /// /// Encapsulates the basic properties and methods required to manipulate images. /// diff --git a/src/ImageSharp/Image/IImageProcessor.cs b/src/ImageSharp/Image/IImageProcessor.cs index c4fa9afa29..8687766d5e 100644 --- a/src/ImageSharp/Image/IImageProcessor.cs +++ b/src/ImageSharp/Image/IImageProcessor.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Processing using System.Threading.Tasks; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Encapsulates methods to alter the pixels of an image. diff --git a/src/ImageSharp/Image/ImageBase{TPixel}.cs b/src/ImageSharp/Image/ImageBase{TPixel}.cs index 647d60075d..20b891f2dd 100644 --- a/src/ImageSharp/Image/ImageBase{TPixel}.cs +++ b/src/ImageSharp/Image/ImageBase{TPixel}.cs @@ -12,6 +12,7 @@ namespace ImageSharp using ImageSharp.Memory; using ImageSharp.PixelFormats; using ImageSharp.Processing; + using SixLabors.Primitives; /// /// The base class of all images. Encapsulates the basic properties and methods required to manipulate diff --git a/src/ImageSharp/Image/Image{TPixel}.cs b/src/ImageSharp/Image/Image{TPixel}.cs index 059ccb9a07..1cda8ebc7a 100644 --- a/src/ImageSharp/Image/Image{TPixel}.cs +++ b/src/ImageSharp/Image/Image{TPixel}.cs @@ -16,6 +16,7 @@ namespace ImageSharp using Formats; using ImageSharp.PixelFormats; using ImageSharp.Processing; + using SixLabors.Primitives; /// /// Encapsulates an image, which consists of the pixel data for a graphics image and its attributes. diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 17f7bf58f3..afacb3c97d 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -34,6 +34,7 @@ + All diff --git a/src/ImageSharp/Numerics/Ellipse.cs b/src/ImageSharp/Numerics/Ellipse.cs deleted file mode 100644 index 9aba745e46..0000000000 --- a/src/ImageSharp/Numerics/Ellipse.cs +++ /dev/null @@ -1,183 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - using System.ComponentModel; - using System.Numerics; - - /// - /// Represents an ellipse. - /// - public struct Ellipse : IEquatable - { - /// - /// Represents a that has X and Y values set to zero. - /// - public static readonly Ellipse Empty = default(Ellipse); - - /// - /// The center point. - /// - private Point center; - - /// - /// Initializes a new instance of the struct. - /// - /// The center point. - /// The x-radius. - /// The y-radius. - public Ellipse(Point center, float radiusX, float radiusY) - { - this.center = center; - this.RadiusX = radiusX; - this.RadiusY = radiusY; - } - - /// - /// Gets the x-radius of this . - /// - public float RadiusX { get; } - - /// - /// Gets the y-radius of this . - /// - public float RadiusY { get; } - - /// - /// Gets a value indicating whether this is empty. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsEmpty => this.Equals(Empty); - - /// - /// Compares two objects for equality. - /// - /// - /// The on the left side of the operand. - /// - /// - /// The on the right side of the operand. - /// - /// - /// True if the current left is equal to the parameter; otherwise, false. - /// - public static bool operator ==(Ellipse left, Ellipse right) - { - return left.Equals(right); - } - - /// - /// Compares two objects for inequality. - /// - /// - /// The on the left side of the operand. - /// - /// - /// The on the right side of the operand. - /// - /// - /// True if the current left is unequal to the parameter; otherwise, false. - /// - public static bool operator !=(Ellipse left, Ellipse right) - { - return !left.Equals(right); - } - - /// - /// Returns the center point of the given - /// - /// The ellipse - /// - public static Vector2 Center(Ellipse ellipse) - { - return new Vector2(ellipse.center.X, ellipse.center.Y); - } - - /// - /// Determines if the specfied point is contained within the rectangular region defined by - /// this . - /// - /// The x-coordinate of the given point. - /// The y-coordinate of the given point. - /// The - public bool Contains(int x, int y) - { - if (this.RadiusX <= 0 || this.RadiusY <= 0) - { - return false; - } - - // TODO: SIMD? - // This is a more general form of the circle equation - // X^2/a^2 + Y^2/b^2 <= 1 - Point normalized = new Point(x - this.center.X, y - this.center.Y); - int nX = normalized.X; - int nY = normalized.Y; - - return ((double)(nX * nX) / (this.RadiusX * this.RadiusX)) - + ((double)(nY * nY) / (this.RadiusY * this.RadiusY)) - <= 1.0; - } - - /// - public override int GetHashCode() - { - return this.GetHashCode(this); - } - - /// - public override string ToString() - { - if (this.IsEmpty) - { - return "Ellipse [ Empty ]"; - } - - return - $"Ellipse [ RadiusX={this.RadiusX}, RadiusY={this.RadiusX}, Centre={this.center.X},{this.center.Y} ]"; - } - - /// - public override bool Equals(object obj) - { - if (obj is Ellipse) - { - return this.Equals((Ellipse)obj); - } - - return false; - } - - /// - public bool Equals(Ellipse other) - { - return this.center.Equals(other.center) - && this.RadiusX.Equals(other.RadiusX) - && this.RadiusY.Equals(other.RadiusY); - } - - /// - /// Returns the hash code for this instance. - /// - /// - /// The instance of to return the hash code for. - /// - /// - /// A 32-bit signed integer that is the hash code for this instance. - /// - private int GetHashCode(Ellipse ellipse) - { - unchecked - { - int hashCode = ellipse.center.GetHashCode(); - hashCode = (hashCode * 397) ^ ellipse.RadiusX.GetHashCode(); - hashCode = (hashCode * 397) ^ ellipse.RadiusY.GetHashCode(); - return hashCode; - } - } - } -} diff --git a/src/ImageSharp/Numerics/Matrix3x2Extensions.cs b/src/ImageSharp/Numerics/Matrix3x2Extensions.cs deleted file mode 100644 index f424624020..0000000000 --- a/src/ImageSharp/Numerics/Matrix3x2Extensions.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System.Numerics; - using System.Runtime.CompilerServices; - - /// - /// Extension methods for the struct - /// - public static class Matrix3x2Extensions - { - /// - /// Creates a rotation matrix for the given rotation in degrees and a center point. - /// - /// The angle in degrees - /// The center point - /// The rotation - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Matrix3x2 CreateRotation(float degree, Point centerPoint) - { - float radian = MathF.DegreeToRadian(degree); - return Matrix3x2.CreateRotation(radian, new Vector2(centerPoint.X, centerPoint.Y)); - } - - /// - /// Creates a rotation matrix for the given rotation in degrees and a center point. - /// - /// The angle in degrees - /// The center point - /// The rotation - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Matrix3x2 CreateRotation(float degree, PointF centerPoint) - { - float radian = MathF.DegreeToRadian(degree); - return Matrix3x2.CreateRotation(radian, centerPoint); - } - - /// - /// Creates a skew matrix for the given angle in degrees and a center point. - /// - /// The x-angle in degrees - /// The y-angle in degrees - /// The center point - /// The rotation - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Matrix3x2 CreateSkew(float degreesX, float degreesY, Point centerPoint) - { - float radiansX = MathF.DegreeToRadian(degreesX); - float radiansY = MathF.DegreeToRadian(degreesY); - return Matrix3x2.CreateSkew(radiansX, radiansY, new Vector2(centerPoint.X, centerPoint.Y)); - } - - /// - /// Creates a skew matrix for the given angle in degrees and a center point. - /// - /// The x-angle in degrees - /// The y-angle in degrees - /// The rotation - /// The center point - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Matrix3x2 CreateSkew(float degreesX, float degreesY, PointF centerPoint) - { - float radiansX = MathF.DegreeToRadian(degreesX); - float radiansY = MathF.DegreeToRadian(degreesY); - return Matrix3x2.CreateSkew(radiansX, radiansY, new Vector2(centerPoint.X, centerPoint.Y)); - } - } -} diff --git a/src/ImageSharp/Numerics/Point.cs b/src/ImageSharp/Numerics/Point.cs deleted file mode 100644 index 9bff27d2ac..0000000000 --- a/src/ImageSharp/Numerics/Point.cs +++ /dev/null @@ -1,257 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - using System.ComponentModel; - using System.Numerics; - using System.Runtime.CompilerServices; - - /// - /// Represents an ordered pair of integer x- and y-coordinates that defines a point in - /// a two-dimensional plane. - /// - /// - /// This struct is fully mutable. This is done (against the guidelines) for the sake of performance, - /// as it avoids the need to create new values for modification operations. - /// - public struct Point : IEquatable - { - /// - /// Represents a that has X and Y values set to zero. - /// - public static readonly Point Empty = default(Point); - - /// - /// Initializes a new instance of the struct. - /// - /// The horizontal and vertical position of the point. - public Point(int value) - : this() - { - this.X = LowInt16(value); - this.Y = HighInt16(value); - } - - /// - /// Initializes a new instance of the struct. - /// - /// The horizontal position of the point. - /// The vertical position of the point. - public Point(int x, int y) - : this() - { - this.X = x; - this.Y = y; - } - - /// - /// Initializes a new instance of the struct from the given . - /// - /// The size - public Point(Size size) - { - this.X = size.Width; - this.Y = size.Height; - } - - /// - /// Gets or sets the x-coordinate of this . - /// - public int X { get; set; } - - /// - /// Gets or sets the y-coordinate of this . - /// - public int Y { get; set; } - - /// - /// Gets a value indicating whether this is empty. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsEmpty => this.Equals(Empty); - - /// - /// Creates a with the coordinates of the specified . - /// - /// The point - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator PointF(Point point) => new PointF(point.X, point.Y); - - /// - /// Creates a with the coordinates of the specified . - /// - /// The point - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator Vector2(Point point) => new Vector2(point.X, point.Y); - - /// - /// Creates a with the coordinates of the specified . - /// - /// The point - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator Size(Point point) => new Size(point.X, point.Y); - - /// - /// Translates a by a given . - /// - /// The point on the left hand of the operand. - /// The size on the right hand of the operand. - /// - /// The - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point operator +(Point point, Size size) => Add(point, size); - - /// - /// Translates a by the negative of a given . - /// - /// The point on the left hand of the operand. - /// The size on the right hand of the operand. - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point operator -(Point point, Size size) => Subtract(point, size); - - /// - /// Compares two objects for equality. - /// - /// The on the left side of the operand. - /// The on the right side of the operand. - /// - /// True if the current left is equal to the parameter; otherwise, false. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator ==(Point left, Point right) => left.Equals(right); - - /// - /// Compares two objects for inequality. - /// - /// The on the left side of the operand. - /// The on the right side of the operand. - /// - /// True if the current left is unequal to the parameter; otherwise, false. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator !=(Point left, Point right) => !left.Equals(right); - - /// - /// Translates a by the negative of a given . - /// - /// The point on the left hand of the operand. - /// The size on the right hand of the operand. - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Add(Point point, Size size) => new Point(unchecked(point.X + size.Width), unchecked(point.Y + size.Height)); - - /// - /// Translates a by the negative of a given . - /// - /// The point on the left hand of the operand. - /// The size on the right hand of the operand. - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Subtract(Point point, Size size) => new Point(unchecked(point.X - size.Width), unchecked(point.Y - size.Height)); - - /// - /// Converts a to a by performing a ceiling operation on all the coordinates. - /// - /// The point - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Ceiling(PointF point) => new Point(unchecked((int)MathF.Ceiling(point.X)), unchecked((int)MathF.Ceiling(point.Y))); - - /// - /// Converts a to a by performing a round operation on all the coordinates. - /// - /// The point - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Round(PointF point) => new Point(unchecked((int)MathF.Round(point.X)), unchecked((int)MathF.Round(point.Y))); - - /// - /// Converts a to a by performing a truncate operation on all the coordinates. - /// - /// The point - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Truncate(PointF point) => new Point(unchecked((int)point.X), unchecked((int)point.Y)); - - /// - /// Converts a to a by performing a round operation on all the coordinates. - /// - /// The vector - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Round(Vector2 vector) => new Point(unchecked((int)MathF.Round(vector.X)), unchecked((int)MathF.Round(vector.Y))); - - /// - /// Rotates a point around the given rotation matrix. - /// - /// The point to rotate - /// Rotation matrix used - /// The rotated - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Rotate(Point point, Matrix3x2 rotation) => Round(Vector2.Transform(new Vector2(point.X, point.Y), rotation)); - - /// - /// Skews a point using the given skew matrix. - /// - /// The point to rotate - /// Rotation matrix used - /// The rotated - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Skew(Point point, Matrix3x2 skew) => Round(Vector2.Transform(new Vector2(point.X, point.Y), skew)); - - /// - /// Translates this by the specified amount. - /// - /// The amount to offset the x-coordinate. - /// The amount to offset the y-coordinate. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Offset(int dx, int dy) - { - unchecked - { - this.X += dx; - this.Y += dy; - } - } - - /// - /// Translates this by the specified amount. - /// - /// The used offset this . - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Offset(Point point) => this.Offset(point.X, point.Y); - - /// - public override int GetHashCode() => this.GetHashCode(this); - - /// - public override string ToString() - { - if (this.IsEmpty) - { - return "Point [ Empty ]"; - } - - return $"Point [ X={this.X}, Y={this.Y} ]"; - } - - /// - public override bool Equals(object obj) => obj is Point && this.Equals((Point)obj); - - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(Point other) => this.X == other.X && this.Y == other.Y; - - private static short HighInt16(int n) => unchecked((short)((n >> 16) & 0xffff)); - - private static short LowInt16(int n) => unchecked((short)(n & 0xffff)); - - private int GetHashCode(Point point) => point.X ^ point.Y; - } -} \ No newline at end of file diff --git a/src/ImageSharp/Numerics/PointF.cs b/src/ImageSharp/Numerics/PointF.cs deleted file mode 100644 index cbe5c7f48b..0000000000 --- a/src/ImageSharp/Numerics/PointF.cs +++ /dev/null @@ -1,233 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - using System.ComponentModel; - using System.Numerics; - using System.Runtime.CompilerServices; - - /// - /// Represents an ordered pair of single precision floating point x- and y-coordinates that defines a point in - /// a two-dimensional plane. - /// - /// - /// This struct is fully mutable. This is done (against the guidelines) for the sake of performance, - /// as it avoids the need to create new values for modification operations. - /// - public struct PointF : IEquatable - { - /// - /// Represents a that has X and Y values set to zero. - /// - public static readonly PointF Empty = default(PointF); - - /// - /// Initializes a new instance of the struct. - /// - /// The horizontal position of the point. - /// The vertical position of the point. - public PointF(float x, float y) - : this() - { - this.X = x; - this.Y = y; - } - - /// - /// Initializes a new instance of the struct from the given . - /// - /// The size - public PointF(SizeF size) - { - this.X = size.Width; - this.Y = size.Height; - } - - /// - /// Gets or sets the x-coordinate of this . - /// - public float X { get; set; } - - /// - /// Gets or sets the y-coordinate of this . - /// - public float Y { get; set; } - - /// - /// Gets a value indicating whether this is empty. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsEmpty => this.Equals(Empty); - - /// - /// Creates a with the coordinates of the specified . - /// - /// The vector. - /// - /// The . - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator PointF(Vector2 vector) => new PointF(vector.X, vector.Y); - - /// - /// Creates a with the coordinates of the specified . - /// - /// The point. - /// - /// The . - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator Vector2(PointF point) => new Vector2(point.X, point.Y); - - /// - /// Creates a with the coordinates of the specified by truncating each of the coordinates. - /// - /// The point. - /// - /// The . - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator Point(PointF point) => Point.Truncate(point); - - /// - /// Translates a by a given . - /// - /// The point on the left hand of the operand. - /// The size on the right hand of the operand. - /// - /// The - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static PointF operator +(PointF point, SizeF size) => Add(point, size); - - /// - /// Translates a by the negative of a given . - /// - /// The point on the left hand of the operand. - /// The size on the right hand of the operand. - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static PointF operator -(PointF point, SizeF size) => Subtract(point, size); - - /// - /// Compares two objects for equality. - /// - /// - /// The on the left side of the operand. - /// - /// - /// The on the right side of the operand. - /// - /// - /// True if the current left is equal to the parameter; otherwise, false. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator ==(PointF left, PointF right) => left.Equals(right); - - /// - /// Compares two objects for inequality. - /// - /// - /// The on the left side of the operand. - /// - /// - /// The on the right side of the operand. - /// - /// - /// True if the current left is unequal to the parameter; otherwise, false. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator !=(PointF left, PointF right) => !left.Equals(right); - - /// - /// Translates a by the negative of a given . - /// - /// The point on the left hand of the operand. - /// The size on the right hand of the operand. - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static PointF Add(PointF point, SizeF size) => new PointF(point.X + size.Width, point.Y + size.Height); - - /// - /// Translates a by the negative of a given . - /// - /// The point on the left hand of the operand. - /// The size on the right hand of the operand. - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static PointF Subtract(PointF point, SizeF size) => new PointF(point.X - size.Width, point.Y - size.Height); - - /// - /// Rotates a point around the given rotation matrix. - /// - /// The point to rotate - /// Rotation matrix used - /// The rotated - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static PointF Rotate(PointF point, Matrix3x2 rotation) => Vector2.Transform(new Vector2(point.X, point.Y), rotation); - - /// - /// Skews a point using the given skew matrix. - /// - /// The point to rotate - /// Rotation matrix used - /// The rotated - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static PointF Skew(PointF point, Matrix3x2 skew) => Vector2.Transform(new Vector2(point.X, point.Y), skew); - - /// - /// Translates this by the specified amount. - /// - /// The amount to offset the x-coordinate. - /// The amount to offset the y-coordinate. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Offset(float dx, float dy) - { - this.X += dx; - this.Y += dy; - } - - /// - /// Translates this by the specified amount. - /// - /// The used offset this . - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Offset(PointF point) => this.Offset(point.X, point.Y); - - /// - public override int GetHashCode() => this.GetHashCode(this); - - /// - public override string ToString() - { - if (this.IsEmpty) - { - return "PointF [ Empty ]"; - } - - return $"PointF [ X={this.X}, Y={this.Y} ]"; - } - - /// - public override bool Equals(object obj) => obj is PointF && this.Equals((PointF)obj); - - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(PointF other) => this.X.Equals(other.X) && this.Y.Equals(other.Y); - - /// - /// Returns the hash code for this instance. - /// - /// - /// The instance of to return the hash code for. - /// - /// - /// A 32-bit signed integer that is the hash code for this instance. - /// - private int GetHashCode(PointF point) => point.X.GetHashCode() ^ point.Y.GetHashCode(); - } -} \ No newline at end of file diff --git a/src/ImageSharp/Numerics/Rectangle.cs b/src/ImageSharp/Numerics/Rectangle.cs deleted file mode 100644 index d16b22920a..0000000000 --- a/src/ImageSharp/Numerics/Rectangle.cs +++ /dev/null @@ -1,467 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - using System.ComponentModel; - using System.Numerics; - using System.Runtime.CompilerServices; - - /// - /// Stores a set of four integers that represent the location and size of a rectangle. - /// - /// - /// This struct is fully mutable. This is done (against the guidelines) for the sake of performance, - /// as it avoids the need to create new values for modification operations. - /// - public struct Rectangle : IEquatable - { - /// - /// Represents a that has X, Y, Width, and Height values set to zero. - /// - public static readonly Rectangle Empty = default(Rectangle); - - /// - /// Initializes a new instance of the struct. - /// - /// The horizontal position of the rectangle. - /// The vertical position of the rectangle. - /// The width of the rectangle. - /// The height of the rectangle. - public Rectangle(int x, int y, int width, int height) - { - this.X = x; - this.Y = y; - this.Width = width; - this.Height = height; - } - - /// - /// Initializes a new instance of the struct. - /// - /// - /// The which specifies the rectangles point in a two-dimensional plane. - /// - /// - /// The which specifies the rectangles height and width. - /// - public Rectangle(Point point, Size size) - { - this.X = point.X; - this.Y = point.Y; - this.Width = size.Width; - this.Height = size.Height; - } - - /// - /// Gets or sets the x-coordinate of this . - /// - public int X { get; set; } - - /// - /// Gets or sets the y-coordinate of this . - /// - public int Y { get; set; } - - /// - /// Gets or sets the width of this . - /// - public int Width { get; set; } - - /// - /// Gets or sets the height of this . - /// - public int Height { get; set; } - - /// - /// Gets or sets the coordinates of the upper-left corner of the rectangular region represented by this . - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public Point Location - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => new Point(this.X, this.Y); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - set - { - this.X = value.X; - this.Y = value.Y; - } - } - - /// - /// Gets or sets the size of this . - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public Size Size - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => new Size(this.Width, this.Height); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - set - { - this.Width = value.Width; - this.Height = value.Height; - } - } - - /// - /// Gets a value indicating whether this is empty. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsEmpty => this.Equals(Empty); - - /// - /// Gets the y-coordinate of the top edge of this . - /// - public int Top - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return this.Y; - } - } - - /// - /// Gets the x-coordinate of the right edge of this . - /// - public int Right - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return unchecked(this.X + this.Width); - } - } - - /// - /// Gets the y-coordinate of the bottom edge of this . - /// - public int Bottom - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return unchecked(this.Y + this.Height); - } - } - - /// - /// Gets the x-coordinate of the left edge of this . - /// - public int Left - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return this.X; - } - } - - /// - /// Creates a with the coordinates of the specified . - /// - /// The rectangle - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator RectangleF(Rectangle rectangle) => new RectangleF(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); - - /// - /// Creates a with the coordinates of the specified . - /// - /// The rectangle - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator Vector4(Rectangle rectangle) => new Vector4(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); - - /// - /// Compares two objects for equality. - /// - /// The on the left side of the operand. - /// The on the right side of the operand. - /// - /// True if the current left is equal to the parameter; otherwise, false. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator ==(Rectangle left, Rectangle right) => left.Equals(right); - - /// - /// Compares two objects for inequality. - /// - /// The on the left side of the operand. - /// The on the right side of the operand. - /// - /// True if the current left is unequal to the parameter; otherwise, false. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator !=(Rectangle left, Rectangle right) => !left.Equals(right); - - /// - /// Creates a new with the specified location and size. - /// The left coordinate of the rectangle - /// The top coordinate of the rectangle - /// The right coordinate of the rectangle - /// The bottom coordinate of the rectangle - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - - // ReSharper disable once InconsistentNaming - public static Rectangle FromLTRB(int left, int top, int right, int bottom) => new Rectangle(left, top, unchecked(right - left), unchecked(bottom - top)); - - /// - /// Returns the center point of the given - /// - /// The rectangle - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point Center(Rectangle rectangle) => new Point(rectangle.Left + (rectangle.Width / 2), rectangle.Top + (rectangle.Height / 2)); - - /// - /// Creates a rectangle that represents the intersection between and - /// . If there is no intersection, an empty rectangle is returned. - /// - /// The first rectangle - /// The second rectangle - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rectangle Intersect(Rectangle a, Rectangle b) - { - int x1 = Math.Max(a.X, b.X); - int x2 = Math.Min(a.Right, b.Right); - int y1 = Math.Max(a.Y, b.Y); - int y2 = Math.Min(a.Bottom, b.Bottom); - - if (x2 >= x1 && y2 >= y1) - { - return new Rectangle(x1, y1, x2 - x1, y2 - y1); - } - - return Empty; - } - - /// - /// Creates a that is inflated by the specified amount. - /// - /// The rectangle - /// The amount to inflate the width by - /// The amount to inflate the height by - /// A new - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rectangle Inflate(Rectangle rectangle, int x, int y) - { - Rectangle r = rectangle; - r.Inflate(x, y); - return r; - } - - /// - /// Converts a to a by performing a ceiling operation on all the coordinates. - /// - /// The rectangle - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rectangle Ceiling(RectangleF rectangle) - { - unchecked - { - return new Rectangle( - (int)MathF.Ceiling(rectangle.X), - (int)MathF.Ceiling(rectangle.Y), - (int)MathF.Ceiling(rectangle.Width), - (int)MathF.Ceiling(rectangle.Height)); - } - } - - /// - /// Converts a to a by performing a truncate operation on all the coordinates. - /// - /// The rectangle - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rectangle Truncate(RectangleF rectangle) - { - unchecked - { - return new Rectangle( - (int)rectangle.X, - (int)rectangle.Y, - (int)rectangle.Width, - (int)rectangle.Height); - } - } - - /// - /// Converts a to a by performing a round operation on all the coordinates. - /// - /// The rectangle - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rectangle Round(RectangleF rectangle) - { - unchecked - { - return new Rectangle( - (int)MathF.Round(rectangle.X), - (int)MathF.Round(rectangle.Y), - (int)MathF.Round(rectangle.Width), - (int)MathF.Round(rectangle.Height)); - } - } - - /// - /// Creates a rectangle that represents the union between and . - /// - /// The first rectangle - /// The second rectangle - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rectangle Union(Rectangle a, Rectangle b) - { - int x1 = Math.Min(a.X, b.X); - int x2 = Math.Max(a.Right, b.Right); - int y1 = Math.Min(a.Y, b.Y); - int y2 = Math.Max(a.Bottom, b.Bottom); - - return new Rectangle(x1, y1, x2 - x1, y2 - y1); - } - - /// - /// Creates a Rectangle that represents the intersection between this Rectangle and the . - /// - /// The rectangle - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Intersect(Rectangle rectangle) - { - Rectangle result = Intersect(rectangle, this); - - this.X = result.X; - this.Y = result.Y; - this.Width = result.Width; - this.Height = result.Height; - } - - /// - /// Inflates this by the specified amount. - /// - /// The width - /// The height - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Inflate(int width, int height) - { - unchecked - { - this.X -= width; - this.Y -= height; - - this.Width += 2 * width; - this.Height += 2 * height; - } - } - - /// - /// Inflates this by the specified amount. - /// - /// The size - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Inflate(Size size) => this.Inflate(size.Width, size.Height); - - /// - /// Determines if the specfied point is contained within the rectangular region defined by - /// this . - /// - /// The x-coordinate of the given point. - /// The y-coordinate of the given point. - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Contains(int x, int y) => this.X <= x && x < this.Right && this.Y <= y && y < this.Bottom; - - /// - /// Determines if the specified point is contained within the rectangular region defined by this . - /// - /// The point - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Contains(Point point) => this.Contains(point.X, point.Y); - - /// - /// Determines if the rectangular region represented by is entirely contained - /// within the rectangular region represented by this . - /// - /// The rectangle - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Contains(Rectangle rectangle) => - (this.X <= rectangle.X) && (rectangle.Right <= this.Right) && - (this.Y <= rectangle.Y) && (rectangle.Bottom <= this.Bottom); - - /// - /// Determines if the specfied intersects the rectangular region defined by - /// this . - /// - /// The other Rectange - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool IntersectsWith(Rectangle rectangle) => - (rectangle.X < this.Right) && (this.X < rectangle.Right) && - (rectangle.Y < this.Bottom) && (this.Y < rectangle.Bottom); - - /// - /// Adjusts the location of this rectangle by the specified amount. - /// - /// The point - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Offset(Point point) => this.Offset(point.X, point.Y); - - /// - /// Adjusts the location of this rectangle by the specified amount. - /// - /// The amount to offset the x-coordinate. - /// The amount to offset the y-coordinate. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Offset(int dx, int dy) - { - unchecked - { - this.X += dx; - this.Y += dy; - } - } - - /// - public override int GetHashCode() => this.GetHashCode(this); - - /// - public override string ToString() - { - if (this.IsEmpty) - { - return "Rectangle [ Empty ]"; - } - - return $"Rectangle [ X={this.X}, Y={this.Y}, Width={this.Width}, Height={this.Height} ]"; - } - - /// - public override bool Equals(object obj) => obj is Rectangle && this.Equals((Rectangle)obj); - - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(Rectangle other) => this.X == other.X && this.Y == other.Y && this.Width == other.Width && this.Height == other.Height; - - private int GetHashCode(Rectangle rectangle) - { - unchecked - { - int hashCode = rectangle.X; - hashCode = (hashCode * 397) ^ rectangle.Y; - hashCode = (hashCode * 397) ^ rectangle.Width; - hashCode = (hashCode * 397) ^ rectangle.Height; - return hashCode; - } - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Numerics/RectangleF.cs b/src/ImageSharp/Numerics/RectangleF.cs deleted file mode 100644 index 7611c96029..0000000000 --- a/src/ImageSharp/Numerics/RectangleF.cs +++ /dev/null @@ -1,400 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - using System.ComponentModel; - using System.Numerics; - using System.Runtime.CompilerServices; - - /// - /// Stores a set of four single precision floating points that represent the location and size of a rectangle. - /// - /// - /// This struct is fully mutable. This is done (against the guidelines) for the sake of performance, - /// as it avoids the need to create new values for modification operations. - /// - public struct RectangleF : IEquatable - { - /// - /// Represents a that has X, Y, Width, and Height values set to zero. - /// - public static readonly RectangleF Empty = default(RectangleF); - - /// - /// Initializes a new instance of the struct. - /// - /// The horizontal position of the rectangle. - /// The vertical position of the rectangle. - /// The width of the rectangle. - /// The height of the rectangle. - public RectangleF(float x, float y, float width, float height) - { - this.X = x; - this.Y = y; - this.Width = width; - this.Height = height; - } - - /// - /// Initializes a new instance of the struct. - /// - /// - /// The which specifies the rectangles point in a two-dimensional plane. - /// - /// - /// The which specifies the rectangles height and width. - /// - public RectangleF(PointF point, SizeF size) - { - this.X = point.X; - this.Y = point.Y; - this.Width = size.Width; - this.Height = size.Height; - } - - /// - /// Gets or sets the x-coordinate of this . - /// - public float X { get; set; } - - /// - /// Gets or sets the y-coordinate of this . - /// - public float Y { get; set; } - - /// - /// Gets or sets the width of this . - /// - public float Width { get; set; } - - /// - /// Gets or sets the height of this . - /// - public float Height { get; set; } - - /// - /// Gets or sets the coordinates of the upper-left corner of the rectangular region represented by this . - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public PointF Location - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => new PointF(this.X, this.Y); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - set - { - this.X = value.X; - this.Y = value.Y; - } - } - - /// - /// Gets or sets the size of this . - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public SizeF Size - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => new SizeF(this.Width, this.Height); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - set - { - this.Width = value.Width; - this.Height = value.Height; - } - } - - /// - /// Gets a value indicating whether this is empty. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsEmpty => (this.Width <= 0) || (this.Height <= 0); - - /// - /// Gets the y-coordinate of the top edge of this . - /// - public float Top - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return this.Y; - } - } - - /// - /// Gets the x-coordinate of the right edge of this . - /// - public float Right - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return this.X + this.Width; - } - } - - /// - /// Gets the y-coordinate of the bottom edge of this . - /// - public float Bottom - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return this.Y + this.Height; - } - } - - /// - /// Gets the x-coordinate of the left edge of this . - /// - public float Left - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return this.X; - } - } - - /// - /// Creates a with the coordinates of the specified by truncating each coordinate. - /// - /// The rectangle - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator Rectangle(RectangleF rectangle) => Rectangle.Truncate(rectangle); - - /// - /// Compares two objects for equality. - /// - /// The on the left side of the operand. - /// The on the right side of the operand. - /// - /// True if the current left is equal to the parameter; otherwise, false. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator ==(RectangleF left, RectangleF right) => left.Equals(right); - - /// - /// Compares two objects for inequality. - /// - /// The on the left side of the operand. - /// The on the right side of the operand. - /// - /// True if the current left is unequal to the parameter; otherwise, false. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator !=(RectangleF left, RectangleF right) => !left.Equals(right); - - /// - /// Creates a new with the specified location and size. - /// The left coordinate of the rectangle - /// The top coordinate of the rectangle - /// The right coordinate of the rectangle - /// The bottom coordinate of the rectangle - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - - // ReSharper disable once InconsistentNaming - public static RectangleF FromLTRB(float left, float top, float right, float bottom) => new RectangleF(left, top, right - left, bottom - top); - - /// - /// Returns the center point of the given - /// - /// The rectangle - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static PointF Center(RectangleF rectangle) => new PointF(rectangle.Left + (rectangle.Width / 2), rectangle.Top + (rectangle.Height / 2)); - - /// - /// Creates a rectangle that represents the intersection between and - /// . If there is no intersection, an empty rectangle is returned. - /// - /// The first rectangle - /// The second rectangle - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static RectangleF Intersect(RectangleF a, RectangleF b) - { - float x1 = MathF.Max(a.X, b.X); - float x2 = MathF.Min(a.Right, b.Right); - float y1 = MathF.Max(a.Y, b.Y); - float y2 = MathF.Min(a.Bottom, b.Bottom); - - if (x2 >= x1 && y2 >= y1) - { - return new RectangleF(x1, y1, x2 - x1, y2 - y1); - } - - return Empty; - } - - /// - /// Creates a that is inflated by the specified amount. - /// - /// The rectangle - /// The amount to inflate the width by - /// The amount to inflate the height by - /// A new - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static RectangleF Inflate(RectangleF rectangle, float x, float y) - { - RectangleF r = rectangle; - r.Inflate(x, y); - return r; - } - - /// - /// Creates a rectangle that represents the union between and . - /// - /// The first rectangle - /// The second rectangle - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static RectangleF Union(RectangleF a, RectangleF b) - { - float x1 = MathF.Min(a.X, b.X); - float x2 = MathF.Max(a.Right, b.Right); - float y1 = MathF.Min(a.Y, b.Y); - float y2 = MathF.Max(a.Bottom, b.Bottom); - - return new RectangleF(x1, y1, x2 - x1, y2 - y1); - } - - /// - /// Creates a RectangleF that represents the intersection between this RectangleF and the . - /// - /// The rectangle - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Intersect(RectangleF rectangle) - { - RectangleF result = Intersect(rectangle, this); - - this.X = result.X; - this.Y = result.Y; - this.Width = result.Width; - this.Height = result.Height; - } - - /// - /// Inflates this by the specified amount. - /// - /// The width - /// The height - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Inflate(float width, float height) - { - this.X -= width; - this.Y -= height; - - this.Width += 2 * width; - this.Height += 2 * height; - } - - /// - /// Inflates this by the specified amount. - /// - /// The size - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Inflate(SizeF size) => this.Inflate(size.Width, size.Height); - - /// - /// Determines if the specfied point is contained within the rectangular region defined by - /// this . - /// - /// The x-coordinate of the given point. - /// The y-coordinate of the given point. - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Contains(float x, float y) => this.X <= x && x < this.Right && this.Y <= y && y < this.Bottom; - - /// - /// Determines if the specified point is contained within the rectangular region defined by this . - /// - /// The point - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Contains(PointF point) => this.Contains(point.X, point.Y); - - /// - /// Determines if the rectangular region represented by is entirely contained - /// within the rectangular region represented by this . - /// - /// The rectangle - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Contains(RectangleF rectangle) => - (this.X <= rectangle.X) && (rectangle.Right <= this.Right) && - (this.Y <= rectangle.Y) && (rectangle.Bottom <= this.Bottom); - - /// - /// Determines if the specfied intersects the rectangular region defined by - /// this . - /// - /// The other Rectange - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool IntersectsWith(RectangleF rectangle) => - (rectangle.X < this.Right) && (this.X < rectangle.Right) && - (rectangle.Y < this.Bottom) && (this.Y < rectangle.Bottom); - - /// - /// Adjusts the location of this rectangle by the specified amount. - /// - /// The point - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Offset(PointF point) => this.Offset(point.X, point.Y); - - /// - /// Adjusts the location of this rectangle by the specified amount. - /// - /// The amount to offset the x-coordinate. - /// The amount to offset the y-coordinate. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Offset(float dx, float dy) - { - this.X += dx; - this.Y += dy; - } - - /// - public override int GetHashCode() => this.GetHashCode(this); - - /// - public override string ToString() - { - if (this.IsEmpty) - { - return "RectangleF [ Empty ]"; - } - - return $"RectangleF [ X={this.X}, Y={this.Y}, Width={this.Width}, Height={this.Height} ]"; - } - - /// - public override bool Equals(object obj) => obj is RectangleF && this.Equals((RectangleF)obj); - - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(RectangleF other) => this.X.Equals(other.X) && this.Y.Equals(other.Y) && this.Width.Equals(other.Width) && this.Height.Equals(other.Height); - - private int GetHashCode(RectangleF rectangle) - { - unchecked - { - int hashCode = rectangle.X.GetHashCode(); - hashCode = (hashCode * 397) ^ rectangle.Y.GetHashCode(); - hashCode = (hashCode * 397) ^ rectangle.Width.GetHashCode(); - hashCode = (hashCode * 397) ^ rectangle.Height.GetHashCode(); - return hashCode; - } - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Numerics/Size.cs b/src/ImageSharp/Numerics/Size.cs deleted file mode 100644 index 79ee1ddead..0000000000 --- a/src/ImageSharp/Numerics/Size.cs +++ /dev/null @@ -1,225 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - using System.ComponentModel; - using System.Runtime.CompilerServices; - - /// - /// Stores an ordered pair of integers, which specify a height and width. - /// - /// - /// This struct is fully mutable. This is done (against the guidelines) for the sake of performance, - /// as it avoids the need to create new values for modification operations. - /// - public struct Size : IEquatable - { - /// - /// Represents a that has Width and Height values set to zero. - /// - public static readonly Size Empty = default(Size); - - /// - /// Initializes a new instance of the struct. - /// - /// The width and height of the size - public Size(int value) - : this() - { - this.Width = value; - this.Height = value; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The width of the size. - /// The height of the size. - public Size(int width, int height) - { - this.Width = width; - this.Height = height; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The size - public Size(Size size) - : this() - { - this.Width = size.Width; - this.Height = size.Height; - } - - /// - /// Initializes a new instance of the struct from the given . - /// - /// The point - public Size(Point point) - { - this.Width = point.X; - this.Height = point.Y; - } - - /// - /// Gets or sets the width of this . - /// - public int Width { get; set; } - - /// - /// Gets or sets the height of this . - /// - public int Height { get; set; } - - /// - /// Gets a value indicating whether this is empty. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsEmpty => this.Equals(Empty); - - /// - /// Creates a with the dimensions of the specified . - /// - /// The point - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static implicit operator SizeF(Size size) => new SizeF(size.Width, size.Height); - - /// - /// Converts the given into a . - /// - /// The size - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator Point(Size size) => new Point(size.Width, size.Height); - - /// - /// Computes the sum of adding two sizes. - /// - /// The size on the left hand of the operand. - /// The size on the right hand of the operand. - /// - /// The - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size operator +(Size left, Size right) => Add(left, right); - - /// - /// Computes the difference left by subtracting one size from another. - /// - /// The size on the left hand of the operand. - /// The size on the right hand of the operand. - /// - /// The - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size operator -(Size left, Size right) => Subtract(left, right); - - /// - /// Compares two objects for equality. - /// - /// - /// The on the left side of the operand. - /// - /// - /// The on the right side of the operand. - /// - /// - /// True if the current left is equal to the parameter; otherwise, false. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator ==(Size left, Size right) => left.Equals(right); - - /// - /// Compares two objects for inequality. - /// - /// - /// The on the left side of the operand. - /// - /// - /// The on the right side of the operand. - /// - /// - /// True if the current left is unequal to the parameter; otherwise, false. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator !=(Size left, Size right) => !left.Equals(right); - - /// - /// Performs vector addition of two objects. - /// - /// The size on the left hand of the operand. - /// The size on the right hand of the operand. - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Add(Size left, Size right) => new Size(unchecked(left.Width + right.Width), unchecked(left.Height + right.Height)); - - /// - /// Contracts a by another - /// - /// The size on the left hand of the operand. - /// The size on the right hand of the operand. - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Subtract(Size left, Size right) => new Size(unchecked(left.Width - right.Width), unchecked(left.Height - right.Height)); - - /// - /// Converts a to a by performing a ceiling operation on all the dimensions. - /// - /// The size - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Ceiling(SizeF size) => new Size(unchecked((int)MathF.Ceiling(size.Width)), unchecked((int)MathF.Ceiling(size.Height))); - - /// - /// Converts a to a by performing a round operation on all the dimensions. - /// - /// The size - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Round(SizeF size) => new Size(unchecked((int)MathF.Round(size.Width)), unchecked((int)MathF.Round(size.Height))); - - /// - /// Converts a to a by performing a round operation on all the dimensions. - /// - /// The size - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size Truncate(SizeF size) => new Size(unchecked((int)size.Width), unchecked((int)size.Height)); - - /// - public override int GetHashCode() => this.GetHashCode(this); - - /// - public override string ToString() - { - if (this.IsEmpty) - { - return "Size [ Empty ]"; - } - - return $"Size [ Width={this.Width}, Height={this.Height} ]"; - } - - /// - public override bool Equals(object obj) => obj is Size && this.Equals((Size)obj); - - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(Size other) => this.Width == other.Width && this.Height == other.Height; - - /// - /// Returns the hash code for this instance. - /// - /// - /// The instance of to return the hash code for. - /// - /// - /// A 32-bit signed integer that is the hash code for this instance. - /// - private int GetHashCode(Size size) => size.Width ^ size.Height; - } -} \ No newline at end of file diff --git a/src/ImageSharp/Numerics/SizeF.cs b/src/ImageSharp/Numerics/SizeF.cs deleted file mode 100644 index 78078fd01f..0000000000 --- a/src/ImageSharp/Numerics/SizeF.cs +++ /dev/null @@ -1,179 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - using System.ComponentModel; - using System.Runtime.CompilerServices; - - /// - /// Stores an ordered pair of single precision floating points, which specify a height and width. - /// - /// - /// This struct is fully mutable. This is done (against the guidelines) for the sake of performance, - /// as it avoids the need to create new values for modification operations. - /// - public struct SizeF : IEquatable - { - /// - /// Represents a that has Width and Height values set to zero. - /// - public static readonly SizeF Empty = default(SizeF); - - /// - /// Initializes a new instance of the struct. - /// - /// The width of the size. - /// The height of the size. - public SizeF(float width, float height) - { - this.Width = width; - this.Height = height; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The size - public SizeF(SizeF size) - : this() - { - this.Width = size.Width; - this.Height = size.Height; - } - - /// - /// Initializes a new instance of the struct from the given . - /// - /// The point - public SizeF(PointF point) - { - this.Width = point.X; - this.Height = point.Y; - } - - /// - /// Gets or sets the width of this . - /// - public float Width { get; set; } - - /// - /// Gets or sets the height of this . - /// - public float Height { get; set; } - - /// - /// Gets a value indicating whether this is empty. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public bool IsEmpty => this.Equals(Empty); - - /// - /// Creates a with the dimensions of the specified by truncating each of the dimensions. - /// - /// The size. - /// - /// The . - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator Size(SizeF size) => new Size(unchecked((int)size.Width), unchecked((int)size.Height)); - - /// - /// Converts the given into a . - /// - /// The size - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator PointF(SizeF size) => new PointF(size.Width, size.Height); - - /// - /// Computes the sum of adding two sizes. - /// - /// The size on the left hand of the operand. - /// The size on the right hand of the operand. - /// - /// The - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static SizeF operator +(SizeF left, SizeF right) => Add(left, right); - - /// - /// Computes the difference left by subtracting one size from another. - /// - /// The size on the left hand of the operand. - /// The size on the right hand of the operand. - /// - /// The - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static SizeF operator -(SizeF left, SizeF right) => Subtract(left, right); - - /// - /// Compares two objects for equality. - /// - /// The size on the left hand of the operand. - /// The size on the right hand of the operand. - /// - /// True if the current left is equal to the parameter; otherwise, false. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator ==(SizeF left, SizeF right) => left.Equals(right); - - /// - /// Compares two objects for inequality. - /// - /// The size on the left hand of the operand. - /// The size on the right hand of the operand. - /// - /// True if the current left is unequal to the parameter; otherwise, false. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator !=(SizeF left, SizeF right) => !left.Equals(right); - - /// - /// Performs vector addition of two objects. - /// - /// The size on the left hand of the operand. - /// The size on the right hand of the operand. - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static SizeF Add(SizeF left, SizeF right) => new SizeF(left.Width + right.Width, left.Height + right.Height); - - /// - /// Contracts a by another - /// - /// The size on the left hand of the operand. - /// The size on the right hand of the operand. - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static SizeF Subtract(SizeF left, SizeF right) => new SizeF(left.Width - right.Width, left.Height - right.Height); - - /// - public override int GetHashCode() - { - return this.GetHashCode(this); - } - - /// - public override string ToString() - { - if (this.IsEmpty) - { - return "SizeF [ Empty ]"; - } - - return $"SizeF [ Width={this.Width}, Height={this.Height} ]"; - } - - /// - public override bool Equals(object obj) => obj is SizeF && this.Equals((SizeF)obj); - - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool Equals(SizeF other) => this.Width.Equals(other.Width) && this.Height.Equals(other.Height); - - private int GetHashCode(SizeF size) => size.Width.GetHashCode() ^ size.Height.GetHashCode(); - } -} \ No newline at end of file diff --git a/src/ImageSharp/Processing/Binarization/BinaryThreshold.cs b/src/ImageSharp/Processing/Binarization/BinaryThreshold.cs index f50616aa30..e37f80c25a 100644 --- a/src/ImageSharp/Processing/Binarization/BinaryThreshold.cs +++ b/src/ImageSharp/Processing/Binarization/BinaryThreshold.cs @@ -10,6 +10,7 @@ namespace ImageSharp using ImageSharp.PixelFormats; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Binarization/Dither.cs b/src/ImageSharp/Processing/Binarization/Dither.cs index 2a359c0898..efaf63b06c 100644 --- a/src/ImageSharp/Processing/Binarization/Dither.cs +++ b/src/ImageSharp/Processing/Binarization/Dither.cs @@ -10,6 +10,7 @@ namespace ImageSharp using ImageSharp.Dithering; using ImageSharp.PixelFormats; using ImageSharp.Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs b/src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs index de543f2cd9..6a4e3807ba 100644 --- a/src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs +++ b/src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs @@ -11,6 +11,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs b/src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs index c48a862930..14641afba1 100644 --- a/src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs +++ b/src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs @@ -11,6 +11,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/ColorMatrix/Grayscale.cs b/src/ImageSharp/Processing/ColorMatrix/Grayscale.cs index daddf106c3..635b6747a6 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Grayscale.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Grayscale.cs @@ -9,6 +9,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/ColorMatrix/Hue.cs b/src/ImageSharp/Processing/ColorMatrix/Hue.cs index bcaf68d9a9..d218b3a104 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Hue.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Hue.cs @@ -11,6 +11,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs b/src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs index a302bb2e90..09eb131907 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs @@ -11,6 +11,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs b/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs index cbfeb7d055..bca4577e48 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs @@ -11,6 +11,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs b/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs index ac9f7391f1..b2d8515d6c 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs @@ -11,6 +11,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/ColorMatrix/Saturation.cs b/src/ImageSharp/Processing/ColorMatrix/Saturation.cs index ffe336c62d..88f3b15296 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Saturation.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Saturation.cs @@ -11,6 +11,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/ColorMatrix/Sepia.cs b/src/ImageSharp/Processing/ColorMatrix/Sepia.cs index 8488dcfe5a..000c0ffba8 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Sepia.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Sepia.cs @@ -11,6 +11,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Convolution/BoxBlur.cs b/src/ImageSharp/Processing/Convolution/BoxBlur.cs index 46c134ee20..ad5e477dc9 100644 --- a/src/ImageSharp/Processing/Convolution/BoxBlur.cs +++ b/src/ImageSharp/Processing/Convolution/BoxBlur.cs @@ -10,6 +10,7 @@ namespace ImageSharp using ImageSharp.PixelFormats; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Convolution/DetectEdges.cs b/src/ImageSharp/Processing/Convolution/DetectEdges.cs index 368688f624..1cc8b693ff 100644 --- a/src/ImageSharp/Processing/Convolution/DetectEdges.cs +++ b/src/ImageSharp/Processing/Convolution/DetectEdges.cs @@ -11,6 +11,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Convolution/GaussianBlur.cs b/src/ImageSharp/Processing/Convolution/GaussianBlur.cs index 0b8c5383c8..f9658fcb5d 100644 --- a/src/ImageSharp/Processing/Convolution/GaussianBlur.cs +++ b/src/ImageSharp/Processing/Convolution/GaussianBlur.cs @@ -11,6 +11,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Convolution/GaussianSharpen.cs b/src/ImageSharp/Processing/Convolution/GaussianSharpen.cs index 1a5d3c2df5..bb616cc67e 100644 --- a/src/ImageSharp/Processing/Convolution/GaussianSharpen.cs +++ b/src/ImageSharp/Processing/Convolution/GaussianSharpen.cs @@ -11,6 +11,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Effects/Alpha.cs b/src/ImageSharp/Processing/Effects/Alpha.cs index 73b682b93b..a0d218651a 100644 --- a/src/ImageSharp/Processing/Effects/Alpha.cs +++ b/src/ImageSharp/Processing/Effects/Alpha.cs @@ -10,6 +10,7 @@ namespace ImageSharp using ImageSharp.PixelFormats; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Effects/BackgroundColor.cs b/src/ImageSharp/Processing/Effects/BackgroundColor.cs index 975d2c24b2..a1e04c8a3d 100644 --- a/src/ImageSharp/Processing/Effects/BackgroundColor.cs +++ b/src/ImageSharp/Processing/Effects/BackgroundColor.cs @@ -10,6 +10,7 @@ namespace ImageSharp using ImageSharp.PixelFormats; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Effects/Brightness.cs b/src/ImageSharp/Processing/Effects/Brightness.cs index a28df82c09..165f897b80 100644 --- a/src/ImageSharp/Processing/Effects/Brightness.cs +++ b/src/ImageSharp/Processing/Effects/Brightness.cs @@ -10,6 +10,7 @@ namespace ImageSharp using ImageSharp.PixelFormats; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Effects/Contrast.cs b/src/ImageSharp/Processing/Effects/Contrast.cs index 8f226d08e2..0a55fd067b 100644 --- a/src/ImageSharp/Processing/Effects/Contrast.cs +++ b/src/ImageSharp/Processing/Effects/Contrast.cs @@ -10,6 +10,7 @@ namespace ImageSharp using ImageSharp.PixelFormats; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Effects/Invert.cs b/src/ImageSharp/Processing/Effects/Invert.cs index fe3bb7dc98..d9a0695566 100644 --- a/src/ImageSharp/Processing/Effects/Invert.cs +++ b/src/ImageSharp/Processing/Effects/Invert.cs @@ -10,6 +10,7 @@ namespace ImageSharp using ImageSharp.PixelFormats; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Effects/OilPainting.cs b/src/ImageSharp/Processing/Effects/OilPainting.cs index fd65542e04..3b300e9197 100644 --- a/src/ImageSharp/Processing/Effects/OilPainting.cs +++ b/src/ImageSharp/Processing/Effects/OilPainting.cs @@ -10,6 +10,7 @@ namespace ImageSharp using ImageSharp.PixelFormats; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Effects/Pixelate.cs b/src/ImageSharp/Processing/Effects/Pixelate.cs index eeffff0925..07fdd50a35 100644 --- a/src/ImageSharp/Processing/Effects/Pixelate.cs +++ b/src/ImageSharp/Processing/Effects/Pixelate.cs @@ -10,6 +10,7 @@ namespace ImageSharp using ImageSharp.PixelFormats; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/ImageProcessor.cs b/src/ImageSharp/Processing/ImageProcessor.cs index d42650e56f..dd2a93bc52 100644 --- a/src/ImageSharp/Processing/ImageProcessor.cs +++ b/src/ImageSharp/Processing/ImageProcessor.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Processing using System.Threading.Tasks; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Allows the application of processors to images. diff --git a/src/ImageSharp/Processing/Overlays/Glow.cs b/src/ImageSharp/Processing/Overlays/Glow.cs index 04c85e00c7..84f6bf10ae 100644 --- a/src/ImageSharp/Processing/Overlays/Glow.cs +++ b/src/ImageSharp/Processing/Overlays/Glow.cs @@ -8,6 +8,7 @@ namespace ImageSharp using ImageSharp.PixelFormats; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Overlays/Vignette.cs b/src/ImageSharp/Processing/Overlays/Vignette.cs index c04e887182..75c4611a1e 100644 --- a/src/ImageSharp/Processing/Overlays/Vignette.cs +++ b/src/ImageSharp/Processing/Overlays/Vignette.cs @@ -8,6 +8,7 @@ namespace ImageSharp using ImageSharp.PixelFormats; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs index a2fa1ddf39..ea1b759ab5 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// An to perform binary threshold filtering against an diff --git a/src/ImageSharp/Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs index 47811f0ec2..85522e2886 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Dithering; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// An that dithers an image using error diffusion. diff --git a/src/ImageSharp/Processing/Processors/Binarization/OrderedDitherProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/OrderedDitherProcessor.cs index 8983897778..a190bcd61b 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/OrderedDitherProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/OrderedDitherProcessor.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Dithering; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// An that dithers an image using error diffusion. diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs index 49af2667d4..1bac145bc9 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// The color matrix filter. Inherit from this class to perform operation involving color matrices. diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/LomographProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/LomographProcessor.cs index f6480c1837..bb33e51513 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/LomographProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/LomographProcessor.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Processing.Processors using System.Numerics; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Converts the colors of the image recreating an old Lomograph effect. diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs index 5df034add2..9e54574df9 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Processing.Processors using System.Numerics; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Converts the colors of the image recreating an old Polaroid effect. diff --git a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs index b97e070791..0a2162fb05 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Applies a Box blur sampler to the image. diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs index b6b56adb3a..708b6c6fd8 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Defines a sampler that uses two one-dimensional matrices to perform convolution against an image. diff --git a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs index efc00b08fd..ceb985b0b7 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Defines a sampler that uses two one-dimensional matrices to perform two-pass convolution against an image. diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs index 06607c87a2..cd2eb27004 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Defines a sampler that uses a 2 dimensional matrix to perform convolution against an image. diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs index 6f1057e007..ab0b459076 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Defines a sampler that detects edges within an image using two one-dimensional matrices. diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs index a03d126775..367c288fca 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Defines a sampler that detects edges within an image using a eight two dimensional matrices. diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs index 415b574b8a..1400b6317a 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Defines a sampler that detects edges within an image using a single two dimensional matrix. diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs index 4cd49e149e..ef6ddaa6a7 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Applies a Gaussian blur sampler to the image. diff --git a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs index 5bb29a67e2..594dda8cab 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Applies a Gaussian sharpening sampler to the image. diff --git a/src/ImageSharp/Processing/Processors/Effects/AlphaProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/AlphaProcessor.cs index a3894f8d34..0efca43b26 100644 --- a/src/ImageSharp/Processing/Processors/Effects/AlphaProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/AlphaProcessor.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// An to change the alpha component of an . diff --git a/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs index 153719191e..96fcf4d630 100644 --- a/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Sets the background color of the image. diff --git a/src/ImageSharp/Processing/Processors/Effects/BrightnessProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/BrightnessProcessor.cs index 121d25d1e0..3fbe1742ed 100644 --- a/src/ImageSharp/Processing/Processors/Effects/BrightnessProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/BrightnessProcessor.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// An to change the brightness of an . diff --git a/src/ImageSharp/Processing/Processors/Effects/ContrastProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/ContrastProcessor.cs index 1daead6e50..e40f8d5de5 100644 --- a/src/ImageSharp/Processing/Processors/Effects/ContrastProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/ContrastProcessor.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// An to change the contrast of an . diff --git a/src/ImageSharp/Processing/Processors/Effects/InvertProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/InvertProcessor.cs index dc0b134421..07a57db54a 100644 --- a/src/ImageSharp/Processing/Processors/Effects/InvertProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/InvertProcessor.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// An to invert the colors of an . diff --git a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs index 37cc8a9d9c..f484c8eec8 100644 --- a/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// An to apply an oil painting effect to an . diff --git a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs index ba6bb5c9d8..ff83117c5f 100644 --- a/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// An to pixelate the colors of an . diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs index 4e4a36a380..8a13eabca8 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// An that applies a radial glow effect an . diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs index 23ba5afe0f..8cb58739b0 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// An that applies a radial vignette effect to an . diff --git a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs index ade5fa8308..37f8867755 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Provides methods to allow the cropping of an image. diff --git a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs index 571c40939e..16f74f218b 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs @@ -8,6 +8,7 @@ namespace ImageSharp.Processing.Processors using System; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Provides methods to allow the cropping of an image to preserve areas of highest diff --git a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs index d4303c455e..cba60f928e 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Provides methods that allow the flipping of an image around its center point. diff --git a/src/ImageSharp/Processing/Processors/Transforms/Matrix3x2Processor.cs b/src/ImageSharp/Processing/Processors/Transforms/Matrix3x2Processor.cs index 4cc03d864b..d1a35659b3 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/Matrix3x2Processor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/Matrix3x2Processor.cs @@ -8,6 +8,7 @@ namespace ImageSharp.Processing.Processors using System.Numerics; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Provides methods to transform an image using a . diff --git a/src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.cs index 7245b961f8..0186a8fa8e 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Processing.Processors using System.Runtime.CompilerServices; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Provides methods that allow the resizing of images using various algorithms. diff --git a/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs index 68ff1397df..be1680cf1c 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Processing.Processors using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Provides methods that allow the resizing of images using various algorithms. diff --git a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs index 15d7ca641a..e6b1d180f1 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Provides methods that allow the rotating of images. diff --git a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs index 264cf4a531..9766caa696 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Processing.Processors using System.Threading.Tasks; using ImageSharp.Memory; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Provides methods that allow the skewing of images. diff --git a/src/ImageSharp/Processing/Transforms/Crop.cs b/src/ImageSharp/Processing/Transforms/Crop.cs index 1cdef56c48..94e9ba1f49 100644 --- a/src/ImageSharp/Processing/Transforms/Crop.cs +++ b/src/ImageSharp/Processing/Transforms/Crop.cs @@ -10,6 +10,7 @@ namespace ImageSharp using ImageSharp.PixelFormats; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs b/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs index 712efec121..7eae89eac0 100644 --- a/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs +++ b/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs @@ -8,6 +8,7 @@ namespace ImageSharp.Processing using System.Linq; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Provides methods to help calculate the target rectangle when resizing using the diff --git a/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs b/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs index 3c67cb9501..2ca2b1c39d 100644 --- a/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs +++ b/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs @@ -7,6 +7,7 @@ namespace ImageSharp.Processing { using System.Collections.Generic; using System.Linq; + using SixLabors.Primitives; /// /// The resize options for resizing images against certain modes. diff --git a/src/ImageSharp/Processing/Transforms/Pad.cs b/src/ImageSharp/Processing/Transforms/Pad.cs index 4bded07724..8138fd7654 100644 --- a/src/ImageSharp/Processing/Transforms/Pad.cs +++ b/src/ImageSharp/Processing/Transforms/Pad.cs @@ -11,6 +11,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Processing/Transforms/Resize.cs b/src/ImageSharp/Processing/Transforms/Resize.cs index 3399ff0e37..e00faf10ea 100644 --- a/src/ImageSharp/Processing/Transforms/Resize.cs +++ b/src/ImageSharp/Processing/Transforms/Resize.cs @@ -9,6 +9,7 @@ namespace ImageSharp using ImageSharp.Processing; using Processing.Processors; + using SixLabors.Primitives; /// /// Extension methods for the type. diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs index 183782d915..66104944ea 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs @@ -50,7 +50,7 @@ namespace ImageSharp.Benchmarks image.DrawBeziers( Rgba32.HotPink, 10, - new[] { + new SixLabors.Primitives.PointF[] { new Vector2(10, 500), new Vector2(30, 10), new Vector2(240, 30), diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs index 5ecdec2c29..a6af5a9769 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs @@ -48,7 +48,7 @@ namespace ImageSharp.Benchmarks image.DrawLines( Rgba32.HotPink, 10, - new[] { + new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(550, 50), new Vector2(200, 400) diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs index d3ff33956e..3abd3b889d 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs @@ -50,7 +50,7 @@ namespace ImageSharp.Benchmarks image.DrawPolygon( Rgba32.HotPink, 10, - new[] { + new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(550, 50), new Vector2(200, 400) diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs index deba595545..b7d1b96b74 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs @@ -57,7 +57,7 @@ namespace ImageSharp.Benchmarks { image.FillPolygon( Rgba32.HotPink, - new[] { + new SixLabors.Primitives.PointF[] { 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 a90a7a4c01..0738812a1c 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs @@ -9,8 +9,8 @@ namespace ImageSharp.Benchmarks using System.Drawing.Drawing2D; using BenchmarkDotNet.Attributes; - using CoreRectangle = ImageSharp.Rectangle; - using CoreSize = ImageSharp.Size; + using CoreRectangle = SixLabors.Primitives.Rectangle; + using CoreSize = SixLabors.Primitives.Size; using System.Numerics; @@ -52,7 +52,7 @@ namespace ImageSharp.Benchmarks { image.FillPolygon( Rgba32.HotPink, - new[] { + new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 10), new Vector2(200, 150), diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs b/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs index 3c327bd562..6f3a38b7fd 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Benchmarks.Image using CoreImage = ImageSharp.Image; - using CoreSize = ImageSharp.Size; + using CoreSize = SixLabors.Primitives.Size; public class DecodeBmp : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs b/tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs index 8f79386a67..ae1add172d 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; using ImageSharp; + using SixLabors.Primitives; using CoreImage = ImageSharp.Image; public class DecodeFilteredPng : BenchmarkBase @@ -30,11 +31,11 @@ namespace ImageSharp.Benchmarks.Image this.filter4 = new MemoryStream(File.ReadAllBytes("../ImageSharp.Tests/TestImages/Formats/Png/filter4.png")); } - private Size LoadPng(MemoryStream stream) + private SixLabors.Primitives.Size LoadPng(MemoryStream stream) { using (Image image = CoreImage.Load(stream)) { - return new Size(image.Width, image.Height); + return new SixLabors.Primitives.Size(image.Width, image.Height); } } diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs b/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs index b1e56c6bd2..3f908d3622 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Benchmarks.Image using CoreImage = ImageSharp.Image; - using CoreSize = ImageSharp.Size; + using CoreSize = SixLabors.Primitives.Size; public class DecodeGif : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs b/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs index 455af48ad2..ece93f912e 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Benchmarks.Image using CoreImage = ImageSharp.Image; - using CoreSize = ImageSharp.Size; + using CoreSize = SixLabors.Primitives.Size; public class DecodeJpeg : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/Image/DecodePng.cs b/tests/ImageSharp.Benchmarks/Image/DecodePng.cs index dd26a2cf73..be1633c044 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodePng.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodePng.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Benchmarks.Image using CoreImage = ImageSharp.Image; - using CoreSize = ImageSharp.Size; + using CoreSize = SixLabors.Primitives.Size; public class DecodePng : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs index 1da69f1a8f..01b2ae6c59 100644 --- a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs +++ b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs @@ -9,7 +9,7 @@ namespace ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; using ImageSharp.PixelFormats; - using CoreSize = ImageSharp.Size; + using CoreSize = SixLabors.Primitives.Size; using System.Numerics; using ImageSharp.Memory; diff --git a/tests/ImageSharp.Benchmarks/Samplers/Crop.cs b/tests/ImageSharp.Benchmarks/Samplers/Crop.cs index 9fa9794637..cb13378a13 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Crop.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Crop.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Benchmarks using ImageSharp.PixelFormats; - using CoreSize = ImageSharp.Size; + using CoreSize = SixLabors.Primitives.Size; public class Crop : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs index 049a00c1ca..2aa8df96ca 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs @@ -9,13 +9,14 @@ namespace ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; using ImageSharp.PixelFormats; using ImageSharp.Processing.Processors; - using CoreSize = ImageSharp.Size; + using CoreSize = SixLabors.Primitives.Size; using ImageSharp.Processing; using System.Numerics; using System; using System.Threading.Tasks; using ImageSharp.Memory; + using SixLabors.Primitives; public class Glow : BenchmarkBase { diff --git a/tests/ImageSharp.Benchmarks/Samplers/Resize.cs b/tests/ImageSharp.Benchmarks/Samplers/Resize.cs index d96be70f74..3873400698 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Resize.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Resize.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Benchmarks using ImageSharp.PixelFormats; - using CoreSize = ImageSharp.Size; + using CoreSize = SixLabors.Primitives.Size; public class Resize : BenchmarkBase { diff --git a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs index 3d49a70b81..ed2b7726c6 100644 --- a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs +++ b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs @@ -28,7 +28,7 @@ namespace ImageSharp.Tests.Drawing { image.BackgroundColor(Rgba32.Blue) .DrawBeziers(Rgba32.HotPink, 5, - new[] { + new SixLabors.Primitives.PointF[] { new Vector2(10, 400), new Vector2(30, 10), new Vector2(240, 30), @@ -71,7 +71,7 @@ namespace ImageSharp.Tests.Drawing image.BackgroundColor(Rgba32.Blue) .DrawBeziers(color, 10, - new[] { + new SixLabors.Primitives.PointF[] { new Vector2(10, 400), new Vector2(30, 10), new Vector2(240, 30), diff --git a/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs index 23f0569e75..648baa7b5a 100644 --- a/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs +++ b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Tests.Drawing using System.Text; using ImageSharp.PixelFormats; using Xunit; + using SixLabors.Primitives; public class BlendedShapes { diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index 42353a2aab..728ed749a2 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -8,6 +8,7 @@ namespace ImageSharp.Tests using System.IO; using System.Linq; using ImageSharp.PixelFormats; + using SixLabors.Primitives; using Xunit; public class DrawImageTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs index 4ba4a3a835..3df3a508c8 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs @@ -27,7 +27,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300)); - BezierLineSegment bazierSegment = new BezierLineSegment(new Vector2(50, 300), + CubicBezierLineSegment bazierSegment = new CubicBezierLineSegment(new Vector2(50, 300), new Vector2(500, 500), new Vector2(60, 10), new Vector2(10, 400)); @@ -68,7 +68,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(50, 300) ); - BezierLineSegment bazierSegment = new BezierLineSegment(new Vector2(50, 300), + CubicBezierLineSegment bazierSegment = new CubicBezierLineSegment(new Vector2(50, 300), new Vector2(500, 500), new Vector2(60, 10), new Vector2(10, 400)); @@ -112,7 +112,7 @@ namespace ImageSharp.Tests.Drawing for (int i = 0; i < 300; i += 20) { - image.DrawLines(pen, new Vector2[] { new Vector2(100, 2), new Vector2(-10, i) }); + image.DrawLines(pen, new SixLabors.Primitives.PointF[] { new Vector2(100, 2), new Vector2(-10, i) }); } using (FileStream output = File.OpenWrite($"{path}/ClippedLines.png")) diff --git a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs index 58e55c1245..b04a413857 100644 --- a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs @@ -23,7 +23,7 @@ namespace ImageSharp.Tests.Drawing [InlineData(false, 16, 4)] // we always do 4 sub=pixels when antialising is off. public void MinimumAntialiasSubpixelDepth(bool antialias, int antialiasSubpixelDepth, int expectedAntialiasSubpixelDepth) { - ImageSharp.Rectangle bounds = new ImageSharp.Rectangle(0, 0, 1, 1); + SixLabors.Primitives.Rectangle bounds = new SixLabors.Primitives.Rectangle(0, 0, 1, 1); Mock> brush = new Mock>(); Mock region = new Mock(); @@ -44,7 +44,7 @@ namespace ImageSharp.Tests.Drawing public void FillOffCanvas() { - ImageSharp.Rectangle bounds = new ImageSharp.Rectangle(-100, -10, 10, 10); + SixLabors.Primitives.Rectangle bounds = new SixLabors.Primitives.Rectangle(-100, -10, 10, 10); Mock> brush = new Mock>(); Mock region = new Mock(); @@ -79,7 +79,7 @@ namespace ImageSharp.Tests.Drawing using (var img = new Image(10, 10)) { - img.DrawLines(new Pen(Rgba32.Black, 10), new Vector2[] { + img.DrawLines(new Pen(Rgba32.Black, 10), new SixLabors.Primitives.PointF[] { new Vector2(-10, 5), new Vector2(20, 5), }); diff --git a/tests/ImageSharp.Tests/Drawing/LineTests.cs b/tests/ImageSharp.Tests/Drawing/LineTests.cs index e751557b6f..c2a5d240c7 100644 --- a/tests/ImageSharp.Tests/Drawing/LineTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineTests.cs @@ -28,7 +28,7 @@ namespace ImageSharp.Tests.Drawing image .BackgroundColor(Rgba32.Blue) .DrawLines(Rgba32.HotPink, 5, - new[] { + new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -58,7 +58,7 @@ namespace ImageSharp.Tests.Drawing image .BackgroundColor(Rgba32.Blue) .DrawLines(Rgba32.HotPink, 5, - new[] { + new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -89,7 +89,7 @@ namespace ImageSharp.Tests.Drawing image .BackgroundColor(Rgba32.Blue) .DrawLines(Pens.Dash(Rgba32.HotPink, 5), - new[] { + new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -110,7 +110,7 @@ namespace ImageSharp.Tests.Drawing image .BackgroundColor(Rgba32.Blue) .DrawLines(Pens.Dot(Rgba32.HotPink, 5), - new[] { + new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -131,7 +131,7 @@ namespace ImageSharp.Tests.Drawing image .BackgroundColor(Rgba32.Blue) .DrawLines(Pens.DashDot(Rgba32.HotPink, 5), - new[] { + new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -151,7 +151,7 @@ namespace ImageSharp.Tests.Drawing { image .BackgroundColor(Rgba32.Blue) - .DrawLines(Pens.DashDotDot(Rgba32.HotPink, 5), new[] { + .DrawLines(Pens.DashDotDot(Rgba32.HotPink, 5), new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -174,7 +174,7 @@ namespace ImageSharp.Tests.Drawing { image .BackgroundColor(Rgba32.Blue) - .DrawLines(color, 10, new[] { + .DrawLines(color, 10, new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -206,7 +206,7 @@ namespace ImageSharp.Tests.Drawing { image .BackgroundColor(Rgba32.Blue) - .DrawLines(Rgba32.HotPink, 10, new[] { + .DrawLines(Rgba32.HotPink, 10, new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 10), new Vector2(200, 150), diff --git a/tests/ImageSharp.Tests/Drawing/Paths/Extensions.cs b/tests/ImageSharp.Tests/Drawing/Paths/Extensions.cs deleted file mode 100644 index 24f2a6bd8b..0000000000 --- a/tests/ImageSharp.Tests/Drawing/Paths/Extensions.cs +++ /dev/null @@ -1,33 +0,0 @@ - -namespace ImageSharp.Tests.Drawing.Paths -{ - using System; - using System.IO; - using ImageSharp; - using ImageSharp.Drawing.Brushes; - using ImageSharp.Processing; - using System.Collections.Generic; - using Xunit; - using ImageSharp.Drawing; - using System.Numerics; - using SixLabors.Shapes; - using ImageSharp.Drawing.Processors; - using ImageSharp.Drawing.Pens; - - public class Extensions - { - [Theory] - [InlineData(0.5, 0.5, 5, 5, 0,0,6,6)] - [InlineData(1, 1, 5, 5, 1,1,5,5)] - public void ConvertRectangle(float x, float y, float width, float height, int expectedX, int expectedY, int expectedWidth, int expectedHeight) - { - SixLabors.Shapes.Rectangle src = new SixLabors.Shapes.Rectangle(x, y, width, height); - ImageSharp.Rectangle actual = src.Convert(); - - Assert.Equal(expectedX, actual.X); - Assert.Equal(expectedY, actual.Y); - Assert.Equal(expectedWidth, actual.Width); - Assert.Equal(expectedHeight, actual.Height); - } - } -} diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs index eb0127cb10..3a2b66c3c2 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs @@ -16,7 +16,7 @@ namespace ImageSharp.Tests.Drawing.Paths GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; SolidBrush brush = Brushes.Solid(Rgba32.HotPink); - IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] { + IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] { new Vector2(10,10), new Vector2(20,10), new Vector2(20,10), diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs index e60ac0c13d..24efa976e8 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPathCollection.cs @@ -16,13 +16,13 @@ namespace ImageSharp.Tests.Drawing.Paths GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; SolidBrush brush = Brushes.Solid(Rgba32.HotPink); - IPath path1 = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] { + IPath path1 = new SixLabors.Shapes.Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] { new Vector2(10,10), new Vector2(20,10), new Vector2(20,10), new Vector2(30,10), })); - IPath path2 = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] { + IPath path2 = new SixLabors.Shapes.Path(new LinearLineSegment(new SixLabors.Primitives.PointF[] { new Vector2(10,10), new Vector2(20,10), new Vector2(20,10), diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs index 3f912fe79f..b46d3d0d9c 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs @@ -16,7 +16,7 @@ namespace ImageSharp.Tests.Drawing.Paths GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; SolidBrush brush = Brushes.Solid(Rgba32.HotPink); - Vector2[] path = new Vector2[] { + SixLabors.Primitives.PointF[] path = new SixLabors.Primitives.PointF[] { new Vector2(10,10), new Vector2(20,10), new Vector2(20,10), diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs index 1f4774550e..7e6a3deee5 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs @@ -15,7 +15,7 @@ namespace ImageSharp.Tests.Drawing.Paths GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; SolidBrush brush = Brushes.Solid(Rgba32.HotPink); - ImageSharp.Rectangle rectangle = new ImageSharp.Rectangle(10, 10, 77, 76); + SixLabors.Primitives.Rectangle rectangle = new SixLabors.Primitives.Rectangle(10, 10, 77, 76); private ProcessorWatchingImage img; @@ -40,7 +40,7 @@ namespace ImageSharp.Tests.Drawing.Paths Assert.Equal(GraphicsOptions.Default, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); - SixLabors.Shapes.Rectangle rect = Assert.IsType(region.Shape); + SixLabors.Shapes.RectangularePolygon rect = Assert.IsType(region.Shape); Assert.Equal(rect.Location.X, rectangle.X); Assert.Equal(rect.Location.Y, rectangle.Y); Assert.Equal(rect.Size.Width, rectangle.Width); @@ -60,7 +60,7 @@ namespace ImageSharp.Tests.Drawing.Paths Assert.Equal(noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); - SixLabors.Shapes.Rectangle rect = Assert.IsType(region.Shape); + SixLabors.Shapes.RectangularePolygon rect = Assert.IsType(region.Shape); Assert.Equal(rect.Location.X, rectangle.X); Assert.Equal(rect.Location.Y, rectangle.Y); Assert.Equal(rect.Size.Width, rectangle.Width); @@ -80,7 +80,7 @@ namespace ImageSharp.Tests.Drawing.Paths Assert.Equal(GraphicsOptions.Default, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); - SixLabors.Shapes.Rectangle rect = Assert.IsType(region.Shape); + SixLabors.Shapes.RectangularePolygon rect = Assert.IsType(region.Shape); Assert.Equal(rect.Location.X, rectangle.X); Assert.Equal(rect.Location.Y, rectangle.Y); Assert.Equal(rect.Size.Width, rectangle.Width); @@ -101,7 +101,7 @@ namespace ImageSharp.Tests.Drawing.Paths Assert.Equal(noneDefault, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); - SixLabors.Shapes.Rectangle rect = Assert.IsType(region.Shape); + SixLabors.Shapes.RectangularePolygon rect = Assert.IsType(region.Shape); Assert.Equal(rect.Location.X, rectangle.X); Assert.Equal(rect.Location.Y, rectangle.Y); Assert.Equal(rect.Size.Width, rectangle.Width); diff --git a/tests/ImageSharp.Tests/Drawing/Paths/ProcessorWatchingImage.cs b/tests/ImageSharp.Tests/Drawing/Paths/ProcessorWatchingImage.cs index 0392160788..1670b33520 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/ProcessorWatchingImage.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/ProcessorWatchingImage.cs @@ -7,6 +7,7 @@ namespace ImageSharp.Tests.Drawing.Paths using ImageSharp.Processing; using System.Collections.Generic; using ImageSharp.PixelFormats; + using SixLabors.Primitives; /// /// Watches but does not actually run the processors against the image. diff --git a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs index 7765436f72..df183a8aff 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/ShapeRegionTests.cs @@ -15,17 +15,18 @@ namespace ImageSharp.Tests.Drawing.Paths using ImageSharp.Drawing.Pens; using Moq; using System.Collections.Immutable; + using SixLabors.Primitives; public class ShapeRegionTests { private readonly Mock pathMock; - private readonly SixLabors.Shapes.Rectangle bounds; + private readonly SixLabors.Primitives.RectangleF bounds; public ShapeRegionTests() { this.pathMock = new Mock(); - this.bounds = new SixLabors.Shapes.Rectangle(10.5f, 10, 10, 10); + this.bounds = new RectangleF(10.5f, 10, 10, 10); pathMock.Setup(x => x.Bounds).Returns(this.bounds); // wire up the 2 mocks to reference eachother pathMock.Setup(x => x.AsClosedPath()).Returns(() => pathMock.Object); @@ -73,8 +74,8 @@ namespace ImageSharp.Tests.Drawing.Paths int yToScan = 10; ShapeRegion region = new ShapeRegion(pathMock.Object); - pathMock.Setup(x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Callback((s, e, b, c, o) => { + pathMock.Setup(x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny>())) + .Callback>((s, e, b) => { Assert.Equal(yToScan, s.Y); Assert.Equal(yToScan, e.Y); Assert.True(s.X < bounds.Left); @@ -83,7 +84,7 @@ namespace ImageSharp.Tests.Drawing.Paths int i = region.Scan(yToScan, new float[0]); - pathMock.Verify(x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + pathMock.Verify(x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); } [Fact] @@ -92,8 +93,8 @@ namespace ImageSharp.Tests.Drawing.Paths int yToScan = 10; ShapeRegion region = new ShapeRegion(pathMock.Object); - pathMock.Setup(x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Callback((s, e, b, c, o) => { + pathMock.Setup(x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny>())) + .Callback>((s, e, b) => { Assert.Equal(yToScan, s.Y); Assert.Equal(yToScan, e.Y); Assert.True(s.X < bounds.Left); @@ -102,7 +103,7 @@ namespace ImageSharp.Tests.Drawing.Paths int i = region.Scan(yToScan, new float[0]); - pathMock.Verify(x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Once); + pathMock.Verify(x => x.FindIntersections(It.IsAny(), It.IsAny(), It.IsAny>()), Times.Once); } [Fact] diff --git a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs index 9bc918d37a..fcd5f3dc82 100644 --- a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs @@ -14,6 +14,7 @@ namespace ImageSharp.Tests.Drawing using System.Numerics; using ImageSharp.PixelFormats; + using SixLabors.Primitives; public class PolygonTests : FileTestBase { @@ -29,7 +30,7 @@ namespace ImageSharp.Tests.Drawing image .BackgroundColor(Rgba32.Blue) .DrawPolygon(Rgba32.HotPink, 5, - new[] { + new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -54,7 +55,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedPolygonOutlineWithOpacity() { string path = this.CreateOutputDirectory("Drawing", "Polygons"); - Vector2[] simplePath = new[] { + SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) diff --git a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs index 83419caaf4..4655f1c14e 100644 --- a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs @@ -12,6 +12,7 @@ namespace ImageSharp.Tests using ImageSharp.PixelFormats; using Xunit; + using SixLabors.Primitives; public class RecolorImageTest : FileTestBase { diff --git a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs index 6cab7778e0..b6b143b5d2 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs @@ -20,7 +20,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByFilledPolygon() { string path = this.CreateOutputDirectory("Drawing", "FilledBezier"); - Vector2[] simplePath = new[] { + SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 400), new Vector2(30, 10), new Vector2(240, 30), @@ -32,7 +32,7 @@ namespace ImageSharp.Tests.Drawing { image .BackgroundColor(Rgba32.Blue) - .Fill(Rgba32.HotPink, new Polygon(new BezierLineSegment(simplePath))) + .Fill(Rgba32.HotPink, new Polygon(new CubicBezierLineSegment(simplePath))) .Save(output); } @@ -53,7 +53,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByFilledPolygonOpacity() { string path = this.CreateOutputDirectory("Drawing", "FilledBezier"); - Vector2[] simplePath = new[] { + SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 400), new Vector2(30, 10), new Vector2(240, 30), @@ -67,7 +67,7 @@ namespace ImageSharp.Tests.Drawing { image .BackgroundColor(Rgba32.Blue) - .Fill(color, new Polygon(new BezierLineSegment(simplePath))) + .Fill(color, new Polygon(new CubicBezierLineSegment(simplePath))) .Save(output); } diff --git a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs index 8ffa62d815..b87f0a11d4 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs @@ -23,7 +23,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByFilledPolygon() { string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); - Vector2[] simplePath = new[] { + SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -49,7 +49,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByFilledPolygonWithPattern() { string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); - Vector2[] simplePath = new[] { + SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -75,7 +75,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByFilledPolygonNoAntialias() { string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); - Vector2[] simplePath = new[] { + SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -106,7 +106,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByFilledPolygonImage() { string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); - Vector2[] simplePath = new[] { + SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -129,7 +129,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByFilledPolygonOpacity() { string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); - Vector2[] simplePath = new[] { + SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -167,7 +167,7 @@ namespace ImageSharp.Tests.Drawing { image .BackgroundColor(Rgba32.Blue) - .Fill(Rgba32.HotPink, new SixLabors.Shapes.Rectangle(10, 10, 190, 140)) + .Fill(Rgba32.HotPink, new SixLabors.Shapes.RectangularePolygon(10, 10, 190, 140)) .Save(output); } @@ -242,7 +242,7 @@ namespace ImageSharp.Tests.Drawing { image .BackgroundColor(Rgba32.Blue) - .Fill(Rgba32.HotPink, new Ellipse(50, 50, 30, 50) + .Fill(Rgba32.HotPink, new EllipsePolygon(50, 50, 30, 50) .Rotate((float)(Math.PI / 3))) .Save(output); } @@ -262,7 +262,7 @@ namespace ImageSharp.Tests.Drawing { image .Fill(Rgba32.Blue) - .FillPolygon(Rgba32.HotPink, new[] + .FillPolygon(Rgba32.HotPink, new SixLabors.Primitives.PointF[] { new Vector2( 8, 8 ), new Vector2( 64, 8 ), diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs index 60fe44acdf..05a1f1e363 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs @@ -28,7 +28,7 @@ namespace ImageSharp.Tests.Drawing.Text IPath path = new SixLabors.Shapes.Path( new LinearLineSegment( - new Vector2[] { new Vector2(10, 10), new Vector2(20, 10), new Vector2(20, 10), new Vector2(30, 10), })); + new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(20, 10), new Vector2(20, 10), new Vector2(30, 10), })); private ProcessorWatchingImage img; @@ -39,7 +39,7 @@ namespace ImageSharp.Tests.Drawing.Text public DrawText_Path() { this.FontCollection = new FontCollection(); - this.Font = this.FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")); + this.Font = this.FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")).CreateFont(12); this.img = new ProcessorWatchingImage(10, 10); } diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs index 4718ed4196..1c8c9f1d16 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs @@ -28,7 +28,7 @@ namespace ImageSharp.Tests.Drawing.Text IPath path = new SixLabors.Shapes.Path( new LinearLineSegment( - new Vector2[] { new Vector2(10, 10), new Vector2(20, 10), new Vector2(20, 10), new Vector2(30, 10), })); + new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(20, 10), new Vector2(20, 10), new Vector2(30, 10), })); private ProcessorWatchingImage img; @@ -39,7 +39,7 @@ namespace ImageSharp.Tests.Drawing.Text public DrawText() { this.FontCollection = new FontCollection(); - this.Font = this.FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")); + this.Font = this.FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")).CreateFont(12); this.img = new ProcessorWatchingImage(10, 10); } diff --git a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs index 21646b03f3..ce2a5becf9 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs @@ -25,7 +25,7 @@ namespace ImageSharp.Tests.Drawing.Text public OutputText() { this.FontCollection = new FontCollection(); - this.Font = FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")); + this.Font = FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")).CreateFont(12); } [Fact] diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs index ab81c69b42..8c3e9ef84f 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs @@ -17,6 +17,7 @@ namespace ImageSharp.Tests using ImageSharp.Formats.Jpg; using ImageSharp.PixelFormats; using ImageSharp.Processing; + using SixLabors.Primitives; public class JpegEncoderTests : MeasureFixture { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/YCbCrImageTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/YCbCrImageTests.cs index b7cd281cd3..b911e11846 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/YCbCrImageTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/YCbCrImageTests.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests { using ImageSharp.Formats.Jpg; - + using SixLabors.Primitives; using Xunit; using Xunit.Abstractions; diff --git a/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs b/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs index a6c4b4545d..b59023340b 100644 --- a/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs +++ b/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs @@ -9,7 +9,7 @@ namespace ImageSharp.Tests using System.Numerics; using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; /// @@ -70,22 +70,6 @@ namespace ImageSharp.Tests } } - // TODO: Need a processor in the library with this signature - private static void Fill(Image image, Rectangle region, TPixel color) - where TPixel : struct, IPixel - { - using (PixelAccessor pixels = image.Lock()) - { - for (int y = region.Top; y < region.Bottom; y++) - { - for (int x = region.Left; x < region.Right; x++) - { - pixels[x, y] = color; - } - } - } - } - [Theory] [WithBlankImages(16, 16, PixelTypes.All, ComponentOrder.Xyz)] [WithBlankImages(16, 16, PixelTypes.All, ComponentOrder.Zyx)] @@ -98,7 +82,7 @@ namespace ImageSharp.Tests { using (Image srcImage = provider.GetImage()) { - Fill(srcImage, new Rectangle(4, 4, 8, 8), NamedColors.Red); + srcImage.Fill(NamedColors.Red, new Rectangle(4, 4, 8, 8)); using (PixelAccessor srcPixels = srcImage.Lock()) { using (PixelArea area = new PixelArea(8, 8, order)) diff --git a/tests/ImageSharp.Tests/ImageComparer.cs b/tests/ImageSharp.Tests/ImageComparer.cs index 9a30cc3633..6cd80e9e83 100644 --- a/tests/ImageSharp.Tests/ImageComparer.cs +++ b/tests/ImageSharp.Tests/ImageComparer.cs @@ -9,7 +9,7 @@ namespace ImageSharp.Tests using ImageSharp; using ImageSharp.Memory; using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; /// diff --git a/tests/ImageSharp.Tests/Numerics/PointFTests.cs b/tests/ImageSharp.Tests/Numerics/PointFTests.cs deleted file mode 100644 index 3b5a72a14c..0000000000 --- a/tests/ImageSharp.Tests/Numerics/PointFTests.cs +++ /dev/null @@ -1,192 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Tests.Numerics -{ - using System; - using System.Globalization; - using System.Numerics; - using System.Reflection; - using Xunit; - - public class PointFTests - { - [Fact] - public void DefaultConstructorTest() - { - Assert.Equal(PointF.Empty, new PointF()); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MinValue)] - [InlineData(float.MaxValue, float.MaxValue)] - [InlineData(float.MinValue, float.MaxValue)] - [InlineData(0.0, 0.0)] - public void NonDefaultConstructorTest(float x, float y) - { - var p1 = new PointF(x, y); - - Assert.Equal(x, p1.X); - Assert.Equal(y, p1.Y); - } - - [Fact] - public void IsEmptyDefaultsTest() - { - Assert.True(PointF.Empty.IsEmpty); - Assert.True(new PointF().IsEmpty); - Assert.True(new PointF(0, 0).IsEmpty); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MinValue)] - [InlineData(float.MaxValue, float.MaxValue)] - public void IsEmptyRandomTest(float x, float y) - { - Assert.False(new PointF(x, y).IsEmpty); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MinValue)] - [InlineData(float.MaxValue, float.MaxValue)] - [InlineData(0, 0)] - public void CoordinatesTest(float x, float y) - { - var p = new PointF(x, y); - Assert.Equal(x, p.X); - Assert.Equal(y, p.Y); - - p.X = 10; - Assert.Equal(10, p.X); - - p.Y = -10.123f; - Assert.Equal(-10.123, p.Y, 3); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue, int.MaxValue, int.MinValue)] - [InlineData(float.MinValue, float.MaxValue, int.MinValue, int.MaxValue)] - [InlineData(0, 0, 0, 0)] - public void ArithmeticTestWithSize(float x, float y, int x1, int y1) - { - var p = new PointF(x, y); - var s = new Size(x1, y1); - - var addExpected = new PointF(x + x1, y + y1); - var subExpected = new PointF(x - x1, y - y1); - Assert.Equal(addExpected, p + s); - Assert.Equal(subExpected, p - s); - Assert.Equal(addExpected, PointF.Add(p, s)); - Assert.Equal(subExpected, PointF.Subtract(p, s)); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MaxValue)] - [InlineData(0, 0)] - public void ArithmeticTestWithSizeF(float x, float y) - { - var p = new PointF(x, y); - var s = new SizeF(y, x); - - var addExpected = new PointF(x + y, y + x); - var subExpected = new PointF(x - y, y - x); - Assert.Equal(addExpected, p + s); - Assert.Equal(subExpected, p - s); - Assert.Equal(addExpected, PointF.Add(p, s)); - Assert.Equal(subExpected, PointF.Subtract(p, s)); - } - - [Fact] - public void RotateTest() - { - var p = new PointF(13, 17); - Matrix3x2 matrix = Matrix3x2Extensions.CreateRotation(45, PointF.Empty); - - var pout = PointF.Rotate(p, matrix); - - Assert.Equal(new PointF(-2.82842732F, 21.2132034F), pout); - } - - [Fact] - public void SkewTest() - { - var p = new PointF(13, 17); - Matrix3x2 matrix = Matrix3x2Extensions.CreateSkew(45, 45, PointF.Empty); - - var pout = PointF.Skew(p, matrix); - Assert.Equal(new PointF(30, 30), pout); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MaxValue)] - [InlineData(float.MinValue, float.MinValue)] - [InlineData(float.MaxValue, float.MaxValue)] - [InlineData(0, 0)] - public void EqualityTest(float x, float y) - { - var pLeft = new PointF(x, y); - var pRight = new PointF(y, x); - - if (x == y) - { - Assert.True(pLeft == pRight); - Assert.False(pLeft != pRight); - Assert.True(pLeft.Equals(pRight)); - Assert.True(pLeft.Equals((object)pRight)); - Assert.Equal(pLeft.GetHashCode(), pRight.GetHashCode()); - return; - } - - Assert.True(pLeft != pRight); - Assert.False(pLeft == pRight); - Assert.False(pLeft.Equals(pRight)); - Assert.False(pLeft.Equals((object)pRight)); - } - - [Fact] - public static void EqualityTest_NotPointF() - { - var point = new PointF(0, 0); - Assert.False(point.Equals(null)); - Assert.False(point.Equals(0)); - - // If PointF implements IEquatable (e.g. in .NET Core), then structs that are implicitly - // convertible to var can potentially be equal. - // See https://github.com/dotnet/corefx/issues/5255. - bool expectsImplicitCastToPointF = typeof(IEquatable).IsAssignableFrom(point.GetType()); - Assert.Equal(expectsImplicitCastToPointF, point.Equals(new Point(0, 0))); - - Assert.False(point.Equals((object)new Point(0, 0))); // No implicit cast - } - - [Fact] - public static void GetHashCodeTest() - { - var point = new PointF(10, 10); - Assert.Equal(point.GetHashCode(), new PointF(10, 10).GetHashCode()); - Assert.NotEqual(point.GetHashCode(), new PointF(20, 10).GetHashCode()); - Assert.NotEqual(point.GetHashCode(), new PointF(10, 20).GetHashCode()); - } - - [Fact] - public void ToStringTest() - { - var p = new PointF(5.1F, -5.123F); - Assert.Equal(string.Format(CultureInfo.CurrentCulture, "PointF [ X={0}, Y={1} ]", p.X, p.Y), p.ToString()); - } - - [Fact] - public void ToStringEmptyTest() - { - var p = new PointF(0, 0); - Assert.Equal("PointF [ Empty ]", p.ToString()); - } - } -} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Numerics/PointTests.cs b/tests/ImageSharp.Tests/Numerics/PointTests.cs deleted file mode 100644 index 9f7abe067a..0000000000 --- a/tests/ImageSharp.Tests/Numerics/PointTests.cs +++ /dev/null @@ -1,252 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Tests -{ - using System.Globalization; - using System.Numerics; - - using Xunit; - - public class PointTests - { - [Fact] - public void DefaultConstructorTest() - { - Assert.Equal(Point.Empty, new Point()); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(0, 0)] - public void NonDefaultConstructorTest(int x, int y) - { - var p1 = new Point(x, y); - var p2 = new Point(new Size(x, y)); - - Assert.Equal(p1, p2); - } - - [Theory] - [InlineData(int.MaxValue)] - [InlineData(int.MinValue)] - [InlineData(0)] - public void SingleIntConstructorTest(int x) - { - var p1 = new Point(x); - var p2 = new Point(unchecked((short)(x & 0xFFFF)), unchecked((short)((x >> 16) & 0xFFFF))); - - Assert.Equal(p1, p2); - } - - [Fact] - public void IsEmptyDefaultsTest() - { - Assert.True(Point.Empty.IsEmpty); - Assert.True(new Point().IsEmpty); - Assert.True(new Point(0, 0).IsEmpty); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - public void IsEmptyRandomTest(int x, int y) - { - Assert.False(new Point(x, y).IsEmpty); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(0, 0)] - public void CoordinatesTest(int x, int y) - { - var p = new Point(x, y); - Assert.Equal(x, p.X); - Assert.Equal(y, p.Y); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(0, 0)] - public void PointFConversionTest(int x, int y) - { - PointF p = new Point(x, y); - Assert.Equal(new PointF(x, y), p); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(0, 0)] - public void SizeConversionTest(int x, int y) - { - var sz = (Size)new Point(x, y); - Assert.Equal(new Size(x, y), sz); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(0, 0)] - public void ArithmeticTest(int x, int y) - { - Point addExpected, subExpected, p = new Point(x, y); - var s = new Size(y, x); - - unchecked - { - addExpected = new Point(x + y, y + x); - subExpected = new Point(x - y, y - x); - } - - Assert.Equal(addExpected, p + s); - Assert.Equal(subExpected, p - s); - Assert.Equal(addExpected, Point.Add(p, s)); - Assert.Equal(subExpected, Point.Subtract(p, s)); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MinValue)] - [InlineData(float.MaxValue, float.MaxValue)] - [InlineData(0, 0)] - public void PointFMathematicalTest(float x, float y) - { - var pf = new PointF(x, y); - Point pCeiling, pTruncate, pRound; - - unchecked - { - pCeiling = new Point((int)MathF.Ceiling(x), (int)MathF.Ceiling(y)); - pTruncate = new Point((int)x, (int)y); - pRound = new Point((int)MathF.Round(x), (int)MathF.Round(y)); - } - - Assert.Equal(pCeiling, Point.Ceiling(pf)); - Assert.Equal(pRound, Point.Round(pf)); - Assert.Equal(pTruncate, (Point)pf); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(0, 0)] - public void OffsetTest(int x, int y) - { - var p1 = new Point(x, y); - var p2 = new Point(y, x); - - p1.Offset(p2); - - Assert.Equal(unchecked(p2.X + p2.Y), p1.X); - Assert.Equal(p1.X, p1.Y); - - p2.Offset(x, y); - Assert.Equal(p1, p2); - } - - [Fact] - public void RotateTest() - { - var p = new Point(13, 17); - Matrix3x2 matrix = Matrix3x2Extensions.CreateRotation(45, Point.Empty); - - var pout = Point.Rotate(p, matrix); - - Assert.Equal(new Point(-3, 21), pout); - } - - [Fact] - public void SkewTest() - { - var p = new Point(13, 17); - Matrix3x2 matrix = Matrix3x2Extensions.CreateSkew(45, 45, Point.Empty); - - var pout = Point.Skew(p, matrix); - Assert.Equal(new Point(30, 30), pout); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(0, 0)] - public void EqualityTest(int x, int y) - { - var p1 = new Point(x, y); - var p2 = new Point(x / 2 - 1, y / 2 - 1); - var p3 = new Point(x, y); - - Assert.True(p1 == p3); - Assert.True(p1 != p2); - Assert.True(p2 != p3); - - Assert.True(p1.Equals(p3)); - Assert.False(p1.Equals(p2)); - Assert.False(p2.Equals(p3)); - - Assert.True(p1.Equals((object)p3)); - Assert.False(p1.Equals((object)p2)); - Assert.False(p2.Equals((object)p3)); - - Assert.Equal(p1.GetHashCode(), p3.GetHashCode()); - } - - [Fact] - public static void EqualityTest_NotPoint() - { - var point = new Point(0, 0); - Assert.False(point.Equals(null)); - Assert.False(point.Equals(0)); - Assert.False(point.Equals(new PointF(0, 0))); - } - - [Fact] - public static void GetHashCodeTest() - { - var point = new Point(10, 10); - Assert.Equal(point.GetHashCode(), new Point(10, 10).GetHashCode()); - Assert.NotEqual(point.GetHashCode(), new Point(20, 10).GetHashCode()); - Assert.NotEqual(point.GetHashCode(), new Point(10, 20).GetHashCode()); - } - - [Theory] - [InlineData(0, 0, 0, 0)] - [InlineData(1, -2, 3, -4)] - public void ConversionTest(int x, int y, int width, int height) - { - var rect = new Rectangle(x, y, width, height); - RectangleF rectF = rect; - Assert.Equal(x, rectF.X); - Assert.Equal(y, rectF.Y); - Assert.Equal(width, rectF.Width); - Assert.Equal(height, rectF.Height); - } - - [Fact] - public void ToStringTest() - { - var p = new Point(5, -5); - Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Point [ X={0}, Y={1} ]", p.X, p.Y), p.ToString()); - } - - [Fact] - public void ToStringEmptyTest() - { - var p = new Point(0, 0); - Assert.Equal("Point [ Empty ]", p.ToString()); - } - } -} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Numerics/RectangleFTests.cs b/tests/ImageSharp.Tests/Numerics/RectangleFTests.cs deleted file mode 100644 index 78fbc68f62..0000000000 --- a/tests/ImageSharp.Tests/Numerics/RectangleFTests.cs +++ /dev/null @@ -1,268 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Tests -{ - using System; - using System.Globalization; - using System.Reflection; - - using Xunit; - - /// - /// Tests the struct. - /// - public class RectangleFTests - { - [Fact] - public void DefaultConstructorTest() - { - Assert.Equal(RectangleF.Empty, new RectangleF()); - } - - [Theory] - [InlineData(0, 0, 0, 0)] - [InlineData(float.MaxValue, float.MinValue, float.MinValue, float.MaxValue)] - [InlineData(float.MaxValue, 0, 0, float.MaxValue)] - [InlineData(0, float.MinValue, float.MaxValue, 0)] - public void NonDefaultConstructorTest(float x, float y, float width, float height) - { - var rect1 = new RectangleF(x, y, width, height); - var p = new PointF(x, y); - var s = new SizeF(width, height); - var rect2 = new RectangleF(p, s); - - Assert.Equal(rect1, rect2); - } - - [Theory] - [InlineData(0, 0, 0, 0)] - [InlineData(float.MaxValue, float.MinValue, float.MinValue, float.MaxValue)] - [InlineData(float.MaxValue, 0, 0, float.MaxValue)] - [InlineData(0, float.MinValue, float.MaxValue, 0)] - public void FromLTRBTest(float left, float top, float right, float bottom) - { - var expected = new RectangleF(left, top, right - left, bottom - top); - var actual = RectangleF.FromLTRB(left, top, right, bottom); - - Assert.Equal(expected, actual); - } - - [Theory] - [InlineData(0, 0, 0, 0)] - [InlineData(float.MaxValue, float.MinValue, float.MinValue, float.MaxValue)] - [InlineData(float.MaxValue, 0, 0, float.MaxValue)] - [InlineData(0, float.MinValue, float.MaxValue, 0)] - public void DimensionsTest(float x, float y, float width, float height) - { - var rect = new RectangleF(x, y, width, height); - var p = new PointF(x, y); - var s = new SizeF(width, height); - - Assert.Equal(p, rect.Location); - Assert.Equal(s, rect.Size); - Assert.Equal(x, rect.X); - Assert.Equal(y, rect.Y); - Assert.Equal(width, rect.Width); - Assert.Equal(height, rect.Height); - Assert.Equal(x, rect.Left); - Assert.Equal(y, rect.Top); - Assert.Equal(x + width, rect.Right); - Assert.Equal(y + height, rect.Bottom); - } - - [Fact] - public void IsEmptyTest() - { - Assert.True(RectangleF.Empty.IsEmpty); - Assert.True(new RectangleF().IsEmpty); - Assert.True(new RectangleF(1, -2, -10, 10).IsEmpty); - Assert.True(new RectangleF(1, -2, 10, -10).IsEmpty); - Assert.True(new RectangleF(1, -2, 0, 0).IsEmpty); - - Assert.False(new RectangleF(0, 0, 10, 10).IsEmpty); - } - - [Theory] - [InlineData(0, 0)] - [InlineData(float.MaxValue, float.MinValue)] - public static void LocationSetTest(float x, float y) - { - var point = new PointF(x, y); - var rect = new RectangleF(10, 10, 10, 10) { Location = point }; - Assert.Equal(point, rect.Location); - Assert.Equal(point.X, rect.X); - Assert.Equal(point.Y, rect.Y); - } - - [Theory] - [InlineData(0, 0)] - [InlineData(float.MaxValue, float.MinValue)] - public static void SizeSetTest(float x, float y) - { - var size = new SizeF(x, y); - var rect = new RectangleF(10, 10, 10, 10) { Size = size }; - Assert.Equal(size, rect.Size); - Assert.Equal(size.Width, rect.Width); - Assert.Equal(size.Height, rect.Height); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue, float.MinValue, float.MaxValue)] - [InlineData(float.MaxValue, 0, 0, float.MaxValue)] - [InlineData(0, float.MinValue, float.MaxValue, 0)] - public void EqualityTest(float x, float y, float width, float height) - { - var rect1 = new RectangleF(x, y, width, height); - var rect2 = new RectangleF(width, height, x, y); - - Assert.True(rect1 != rect2); - Assert.False(rect1 == rect2); - Assert.False(rect1.Equals(rect2)); - Assert.False(rect1.Equals((object)rect2)); - } - - [Fact] - public static void EqualityTestNotRectangleF() - { - var rectangle = new RectangleF(0, 0, 0, 0); - Assert.False(rectangle.Equals(null)); - Assert.False(rectangle.Equals(0)); - - // If RectangleF implements IEquatable (e.g. in .NET Core), then classes that are implicitly - // convertible to RectangleF can potentially be equal. - // See https://github.com/dotnet/corefx/issues/5255. - bool expectsImplicitCastToRectangleF = typeof(IEquatable).IsAssignableFrom(rectangle.GetType()); - Assert.Equal(expectsImplicitCastToRectangleF, rectangle.Equals(new Rectangle(0, 0, 0, 0))); - - Assert.False(rectangle.Equals((object)new Rectangle(0, 0, 0, 0))); // No implicit cast - } - - [Fact] - public static void GetHashCodeTest() - { - var rect1 = new RectangleF(10, 10, 10, 10); - var rect2 = new RectangleF(10, 10, 10, 10); - Assert.Equal(rect1.GetHashCode(), rect2.GetHashCode()); - Assert.NotEqual(rect1.GetHashCode(), new RectangleF(20, 10, 10, 10).GetHashCode()); - Assert.NotEqual(rect1.GetHashCode(), new RectangleF(10, 20, 10, 10).GetHashCode()); - Assert.NotEqual(rect1.GetHashCode(), new RectangleF(10, 10, 20, 10).GetHashCode()); - Assert.NotEqual(rect1.GetHashCode(), new RectangleF(10, 10, 10, 20).GetHashCode()); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue, float.MinValue, float.MaxValue)] - [InlineData(0, float.MinValue, float.MaxValue, 0)] - public void ContainsTest(float x, float y, float width, float height) - { - var rect = new RectangleF(x, y, width, height); - float X = (x + width) / 2; - float Y = (y + height) / 2; - var p = new PointF(X, Y); - var r = new RectangleF(X, Y, width / 2, height / 2); - - Assert.False(rect.Contains(X, Y)); - Assert.False(rect.Contains(p)); - Assert.False(rect.Contains(r)); - } - - [Theory] - [InlineData(0, 0, 0, 0)] - [InlineData(float.MaxValue / 2, float.MinValue / 2, float.MinValue / 2, float.MaxValue / 2)] - [InlineData(0, float.MinValue, float.MaxValue, 0)] - public void InflateTest(float x, float y, float width, float height) - { - var rect = new RectangleF(x, y, width, height); - var inflatedRect = new RectangleF(x - width, y - height, width + 2 * width, height + 2 * height); - - rect.Inflate(width, height); - Assert.Equal(inflatedRect, rect); - - var s = new SizeF(x, y); - inflatedRect = RectangleF.Inflate(rect, x, y); - - rect.Inflate(s); - Assert.Equal(inflatedRect, rect); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue, float.MaxValue / 2, float.MinValue / 2)] - [InlineData(0, float.MinValue, float.MaxValue, 0)] - public void IntersectTest(float x, float y, float width, float height) - { - var rect1 = new RectangleF(x, y, width, height); - var rect2 = new RectangleF(y, x, width, height); - var expectedRect = RectangleF.Intersect(rect1, rect2); - rect1.Intersect(rect2); - Assert.Equal(expectedRect, rect1); - Assert.False(rect1.IntersectsWith(expectedRect)); - } - - [Fact] - public static void IntersectIntersectingRectsTest() - { - var rect1 = new RectangleF(0, 0, 5, 5); - var rect2 = new RectangleF(1, 1, 3, 3); - var expected = new RectangleF(1, 1, 3, 3); - - Assert.Equal(expected, RectangleF.Intersect(rect1, rect2)); - } - - [Theory] - [InlineData(0, 0, 0, 0)] - [InlineData(float.MaxValue, float.MinValue, float.MinValue, float.MaxValue)] - [InlineData(float.MaxValue, 0, 0, float.MaxValue)] - [InlineData(0, float.MinValue, float.MaxValue, 0)] - public void UnionTest(float x, float y, float width, float height) - { - var a = new RectangleF(x, y, width, height); - var b = new RectangleF(width, height, x, y); - - float x1 = Math.Min(a.X, b.X); - float x2 = Math.Max(a.X + a.Width, b.X + b.Width); - float y1 = Math.Min(a.Y, b.Y); - float y2 = Math.Max(a.Y + a.Height, b.Y + b.Height); - - var expectedRectangle = new RectangleF(x1, y1, x2 - x1, y2 - y1); - - Assert.Equal(expectedRectangle, RectangleF.Union(a, b)); - } - - [Theory] - [InlineData(0, 0, 0, 0)] - [InlineData(float.MaxValue, float.MinValue, float.MinValue, float.MaxValue)] - [InlineData(float.MaxValue, 0, 0, float.MaxValue)] - [InlineData(0, float.MinValue, float.MaxValue, 0)] - public void OffsetTest(float x, float y, float width, float height) - { - var r1 = new RectangleF(x, y, width, height); - var expectedRect = new RectangleF(x + width, y + height, width, height); - var p = new PointF(width, height); - - r1.Offset(p); - Assert.Equal(expectedRect, r1); - - expectedRect.Offset(p); - r1.Offset(width, height); - Assert.Equal(expectedRect, r1); - } - - [Fact] - public void ToStringTest() - { - var r = new RectangleF(5, 5.1F, 1.3F, 1); - Assert.Equal(string.Format(CultureInfo.CurrentCulture, "RectangleF [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString()); - } - - [Theory] - [InlineData(0, 0, 0, 0)] - [InlineData(5, -5, 0.2, -1.3)] - public void ToStringTestEmpty(float x, float y, float width, float height) - { - var r = new RectangleF(x, y, width, height); - Assert.Equal("RectangleF [ Empty ]", r.ToString()); - } - } -} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Numerics/RectangleTests.cs b/tests/ImageSharp.Tests/Numerics/RectangleTests.cs deleted file mode 100644 index 1ef03f0c64..0000000000 --- a/tests/ImageSharp.Tests/Numerics/RectangleTests.cs +++ /dev/null @@ -1,308 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Tests -{ - using System; - using System.Globalization; - - using Xunit; - - /// - /// Tests the struct. - /// - public class RectangleTests - { - [Fact] - public void DefaultConstructorTest() - { - Assert.Equal(Rectangle.Empty, new Rectangle()); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue, int.MaxValue, int.MinValue)] - [InlineData(int.MaxValue, 0, int.MinValue, 0)] - [InlineData(0, 0, 0, 0)] - [InlineData(0, int.MinValue, 0, int.MaxValue)] - public void NonDefaultConstructorTest(int x, int y, int width, int height) - { - var rect1 = new Rectangle(x, y, width, height); - var rect2 = new Rectangle(new Point(x, y), new Size(width, height)); - - Assert.Equal(rect1, rect2); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue, int.MaxValue, int.MinValue)] - [InlineData(int.MaxValue, 0, int.MinValue, 0)] - [InlineData(0, 0, 0, 0)] - [InlineData(0, int.MinValue, 0, int.MaxValue)] - public void FromLTRBTest(int left, int top, int right, int bottom) - { - var rect1 = new Rectangle(left, top, unchecked(right - left), unchecked(bottom - top)); - var rect2 = Rectangle.FromLTRB(left, top, right, bottom); - - Assert.Equal(rect1, rect2); - } - - [Fact] - public void EmptyTest() - { - Assert.True(Rectangle.Empty.IsEmpty); - Assert.True(new Rectangle(0, 0, 0, 0).IsEmpty); - Assert.True(new Rectangle().IsEmpty); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue, int.MaxValue, int.MinValue)] - [InlineData(int.MaxValue, 0, int.MinValue, 0)] - [InlineData(int.MinValue, int.MaxValue, int.MinValue, int.MaxValue)] - [InlineData(0, int.MinValue, 0, int.MaxValue)] - public void NonEmptyTest(int x, int y, int width, int height) - { - Assert.False(new Rectangle(x, y, width, height).IsEmpty); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue, int.MaxValue, int.MinValue)] - [InlineData(int.MaxValue, 0, int.MinValue, 0)] - [InlineData(0, 0, 0, 0)] - [InlineData(0, int.MinValue, 0, int.MaxValue)] - [InlineData(int.MinValue, int.MaxValue, int.MinValue, int.MaxValue)] - public void DimensionsTest(int x, int y, int width, int height) - { - var rect = new Rectangle(x, y, width, height); - Assert.Equal(new Point(x, y), rect.Location); - Assert.Equal(new Size(width, height), rect.Size); - - Assert.Equal(x, rect.X); - Assert.Equal(y, rect.Y); - Assert.Equal(width, rect.Width); - Assert.Equal(height, rect.Height); - Assert.Equal(x, rect.Left); - Assert.Equal(y, rect.Top); - Assert.Equal(unchecked(x + width), rect.Right); - Assert.Equal(unchecked(y + height), rect.Bottom); - - var p = new Point(width, height); - var s = new Size(x, y); - rect.Location = p; - rect.Size = s; - - Assert.Equal(p, rect.Location); - Assert.Equal(s, rect.Size); - - Assert.Equal(width, rect.X); - Assert.Equal(height, rect.Y); - Assert.Equal(x, rect.Width); - Assert.Equal(y, rect.Height); - Assert.Equal(width, rect.Left); - Assert.Equal(height, rect.Top); - Assert.Equal(unchecked(x + width), rect.Right); - Assert.Equal(unchecked(y + height), rect.Bottom); - } - - [Theory] - [InlineData(0, 0)] - [InlineData(int.MaxValue, int.MinValue)] - public static void LocationSetTest(int x, int y) - { - var point = new Point(x, y); - var rect = new Rectangle(10, 10, 10, 10) { Location = point }; - Assert.Equal(point, rect.Location); - Assert.Equal(point.X, rect.X); - Assert.Equal(point.Y, rect.Y); - } - - [Theory] - [InlineData(0, 0)] - [InlineData(int.MaxValue, int.MinValue)] - public static void SizeSetTest(int x, int y) - { - var size = new Size(x, y); - var rect = new Rectangle(10, 10, 10, 10) { Size = size }; - Assert.Equal(size, rect.Size); - Assert.Equal(size.Width, rect.Width); - Assert.Equal(size.Height, rect.Height); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue, int.MaxValue, int.MinValue)] - [InlineData(int.MaxValue, 0, int.MinValue, 0)] - [InlineData(0, int.MinValue, 0, int.MaxValue)] - [InlineData(int.MinValue, int.MaxValue, int.MinValue, int.MaxValue)] - public void EqualityTest(int x, int y, int width, int height) - { - var rect1 = new Rectangle(x, y, width, height); - var rect2 = new Rectangle(width / 2, height / 2, x, y); - - Assert.True(rect1 != rect2); - Assert.False(rect1 == rect2); - Assert.False(rect1.Equals(rect2)); - Assert.False(rect1.Equals((object)rect2)); - } - - [Fact] - public static void EqualityTestNotRectangle() - { - var rectangle = new Rectangle(0, 0, 0, 0); - Assert.False(rectangle.Equals(null)); - Assert.False(rectangle.Equals(0)); - Assert.False(rectangle.Equals(new RectangleF(0, 0, 0, 0))); - } - - [Fact] - public static void GetHashCodeTest() - { - var rect1 = new Rectangle(10, 10, 10, 10); - var rect2 = new Rectangle(10, 10, 10, 10); - Assert.Equal(rect1.GetHashCode(), rect2.GetHashCode()); - Assert.NotEqual(rect1.GetHashCode(), new Rectangle(20, 10, 10, 10).GetHashCode()); - Assert.NotEqual(rect1.GetHashCode(), new Rectangle(10, 20, 10, 10).GetHashCode()); - Assert.NotEqual(rect1.GetHashCode(), new Rectangle(10, 10, 20, 10).GetHashCode()); - Assert.NotEqual(rect1.GetHashCode(), new Rectangle(10, 10, 10, 20).GetHashCode()); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue, float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MaxValue, float.MinValue, float.MaxValue)] - [InlineData(0, 0, 0, 0)] - public void RectangleFConversionTest(float x, float y, float width, float height) - { - var rect = new RectangleF(x, y, width, height); - Rectangle rCeiling, rTruncate, rRound; - - unchecked - { - rCeiling = new Rectangle((int)Math.Ceiling(x), (int)Math.Ceiling(y), - (int)Math.Ceiling(width), (int)Math.Ceiling(height)); - rTruncate = new Rectangle((int)x, (int)y, (int)width, (int)height); - rRound = new Rectangle((int)Math.Round(x), (int)Math.Round(y), - (int)Math.Round(width), (int)Math.Round(height)); - } - - Assert.Equal(rCeiling, Rectangle.Ceiling(rect)); - Assert.Equal(rTruncate, Rectangle.Truncate(rect)); - Assert.Equal(rRound, Rectangle.Round(rect)); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue, int.MinValue, int.MaxValue)] - [InlineData(0, int.MinValue, int.MaxValue, 0)] - public void ContainsTest(int x, int y, int width, int height) - { - var rect = new Rectangle(unchecked(2 * x - width), unchecked(2 * y - height), width, height); - var p = new Point(x, y); - var r = new Rectangle(x, y, width / 2, height / 2); - - Assert.False(rect.Contains(x, y)); - Assert.False(rect.Contains(p)); - Assert.False(rect.Contains(r)); - } - - [Theory] - [InlineData(0, 0, 0, 0)] - [InlineData(int.MaxValue, int.MinValue, int.MinValue, int.MaxValue)] - [InlineData(0, int.MinValue, int.MaxValue, 0)] - public void InflateTest(int x, int y, int width, int height) - { - Rectangle inflatedRect, rect = new Rectangle(x, y, width, height); - unchecked - { - inflatedRect = new Rectangle(x - width, y - height, width + 2 * width, height + 2 * height); - } - - Assert.Equal(inflatedRect, Rectangle.Inflate(rect, width, height)); - - rect.Inflate(width, height); - Assert.Equal(inflatedRect, rect); - - var s = new Size(x, y); - unchecked - { - inflatedRect = new Rectangle(rect.X - x, rect.Y - y, rect.Width + 2 * x, rect.Height + 2 * y); - } - - rect.Inflate(s); - Assert.Equal(inflatedRect, rect); - } - - [Theory] - [InlineData(0, 0, 0, 0)] - [InlineData(int.MaxValue, int.MinValue, int.MinValue, int.MaxValue)] - [InlineData(0, int.MinValue, int.MaxValue, 0)] - public void IntersectTest(int x, int y, int width, int height) - { - var rect = new Rectangle(x, y, width, height); - var expectedRect = Rectangle.Intersect(rect, rect); - rect.Intersect(rect); - Assert.Equal(expectedRect, rect); - Assert.False(rect.IntersectsWith(expectedRect)); - } - - [Fact] - public static void IntersectIntersectingRectsTest() - { - var rect1 = new Rectangle(0, 0, 5, 5); - var rect2 = new Rectangle(1, 1, 3, 3); - var expected = new Rectangle(1, 1, 3, 3); - - Assert.Equal(expected, Rectangle.Intersect(rect1, rect2)); - } - - [Theory] - [InlineData(0, 0, 0, 0)] - [InlineData(int.MaxValue, int.MinValue, int.MinValue, int.MaxValue)] - [InlineData(int.MaxValue, 0, 0, int.MaxValue)] - [InlineData(0, int.MinValue, int.MaxValue, 0)] - public void UnionTest(int x, int y, int width, int height) - { - var a = new Rectangle(x, y, width, height); - var b = new Rectangle(width, height, x, y); - - int x1 = Math.Min(a.X, b.X); - int x2 = Math.Max(a.X + a.Width, b.X + b.Width); - int y1 = Math.Min(a.Y, b.Y); - int y2 = Math.Max(a.Y + a.Height, b.Y + b.Height); - - var expectedRectangle = new Rectangle(x1, y1, x2 - x1, y2 - y1); - - Assert.Equal(expectedRectangle, Rectangle.Union(a, b)); - } - - [Theory] - [InlineData(0, 0, 0, 0)] - [InlineData(int.MaxValue, int.MinValue, int.MinValue, int.MaxValue)] - [InlineData(int.MaxValue, 0, 0, int.MaxValue)] - [InlineData(0, int.MinValue, int.MaxValue, 0)] - public void OffsetTest(int x, int y, int width, int height) - { - var r1 = new Rectangle(x, y, width, height); - var expectedRect = new Rectangle(x + width, y + height, width, height); - var p = new Point(width, height); - - r1.Offset(p); - Assert.Equal(expectedRect, r1); - - expectedRect.Offset(p); - r1.Offset(width, height); - Assert.Equal(expectedRect, r1); - } - - [Fact] - public void ToStringTest() - { - var r = new Rectangle(5, -5, 0, 1); - Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Rectangle [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString()); - } - - [Fact] - public void ToStringTestEmpty() - { - var r = new Rectangle(0, 0, 0, 0); - Assert.Equal("Rectangle [ Empty ]", r.ToString()); - } - } -} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Numerics/SizeFTests.cs b/tests/ImageSharp.Tests/Numerics/SizeFTests.cs deleted file mode 100644 index dfeee762f5..0000000000 --- a/tests/ImageSharp.Tests/Numerics/SizeFTests.cs +++ /dev/null @@ -1,163 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Tests -{ - using System; - using System.Globalization; - using System.Reflection; - using Xunit; - - public class SizeFTests - { - [Fact] - public void DefaultConstructorTest() - { - Assert.Equal(SizeF.Empty, new SizeF()); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MinValue)] - [InlineData(float.MaxValue, float.MaxValue)] - [InlineData(0, 0)] - public void NonDefaultConstructorAndDimensionsTest(float width, float height) - { - var s1 = new SizeF(width, height); - var p1 = new PointF(width, height); - var s2 = new SizeF(s1); - - Assert.Equal(s1, s2); - Assert.Equal(s1, new SizeF(p1)); - Assert.Equal(s2, new SizeF(p1)); - - Assert.Equal(width, s1.Width); - Assert.Equal(height, s1.Height); - - s1.Width = 10; - Assert.Equal(10, s1.Width); - - s1.Height = -10.123f; - Assert.Equal(-10.123, s1.Height, 3); - } - - [Fact] - public void IsEmptyDefaultsTest() - { - Assert.True(SizeF.Empty.IsEmpty); - Assert.True(new SizeF().IsEmpty); - Assert.True(new SizeF(0, 0).IsEmpty); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MinValue)] - [InlineData(float.MaxValue, float.MaxValue)] - public void IsEmptyRandomTest(float width, float height) - { - Assert.False(new SizeF(width, height).IsEmpty); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MinValue)] - [InlineData(float.MaxValue, float.MaxValue)] - [InlineData(0, 0)] - public void ArithmeticTest(float width, float height) - { - var s1 = new SizeF(width, height); - var s2 = new SizeF(height, width); - var addExpected = new SizeF(width + height, width + height); - var subExpected = new SizeF(width - height, height - width); - - Assert.Equal(addExpected, s1 + s2); - Assert.Equal(addExpected, SizeF.Add(s1, s2)); - - Assert.Equal(subExpected, s1 - s2); - Assert.Equal(subExpected, SizeF.Subtract(s1, s2)); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MinValue)] - [InlineData(float.MaxValue, float.MaxValue)] - [InlineData(0, 0)] - public void EqualityTest(float width, float height) - { - var sLeft = new SizeF(width, height); - var sRight = new SizeF(height, width); - - if (width == height) - { - Assert.True(sLeft == sRight); - Assert.False(sLeft != sRight); - Assert.True(sLeft.Equals(sRight)); - Assert.True(sLeft.Equals((object)sRight)); - Assert.Equal(sLeft.GetHashCode(), sRight.GetHashCode()); - return; - } - - Assert.True(sLeft != sRight); - Assert.False(sLeft == sRight); - Assert.False(sLeft.Equals(sRight)); - Assert.False(sLeft.Equals((object)sRight)); - } - - [Fact] - public static void EqualityTest_NotSizeF() - { - var size = new SizeF(0, 0); - Assert.False(size.Equals(null)); - Assert.False(size.Equals(0)); - - // If SizeF implements IEquatable (e.g in .NET Core), then classes that are implicitly - // convertible to SizeF can potentially be equal. - // See https://github.com/dotnet/corefx/issues/5255. - bool expectsImplicitCastToSizeF = typeof(IEquatable).IsAssignableFrom(size.GetType()); - Assert.Equal(expectsImplicitCastToSizeF, size.Equals(new Size(0, 0))); - - Assert.False(size.Equals((object)new Size(0, 0))); // No implicit cast - } - - [Fact] - public static void GetHashCodeTest() - { - var size = new SizeF(10, 10); - Assert.Equal(size.GetHashCode(), new SizeF(10, 10).GetHashCode()); - Assert.NotEqual(size.GetHashCode(), new SizeF(20, 10).GetHashCode()); - Assert.NotEqual(size.GetHashCode(), new SizeF(10, 20).GetHashCode()); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MinValue)] - [InlineData(float.MaxValue, float.MaxValue)] - [InlineData(0, 0)] - public void ConversionTest(float width, float height) - { - var s1 = new SizeF(width, height); - var p1 = (PointF)s1; - var s2 = new Size(unchecked((int)width), unchecked((int)height)); - - Assert.Equal(new PointF(width, height), p1); - Assert.Equal(p1, (PointF)s1); - Assert.Equal(s2, (Size)s1); - } - - [Fact] - public void ToStringTest() - { - var sz = new SizeF(10, 5); - Assert.Equal(string.Format(CultureInfo.CurrentCulture, "SizeF [ Width={0}, Height={1} ]", sz.Width, sz.Height), sz.ToString()); - } - - [Fact] - public void ToStringTestEmpty() - { - var sz = new SizeF(0, 0); - Assert.Equal("SizeF [ Empty ]", sz.ToString()); - } - } -} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Numerics/SizeTests.cs b/tests/ImageSharp.Tests/Numerics/SizeTests.cs deleted file mode 100644 index 010cdad3c4..0000000000 --- a/tests/ImageSharp.Tests/Numerics/SizeTests.cs +++ /dev/null @@ -1,195 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Tests -{ - using System.Globalization; - using Xunit; - - /// - /// Tests the struct. - /// - public class SizeTests - { - [Fact] - public void DefaultConstructorTest() - { - Assert.Equal(Size.Empty, new Size()); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(0, 0)] - public void NonDefaultConstructorTest(int width, int height) - { - var s1 = new Size(width, height); - var s2 = new Size(new Point(width, height)); - - Assert.Equal(s1, s2); - - s1.Width = 10; - Assert.Equal(10, s1.Width); - - s1.Height = -10; - Assert.Equal(-10, s1.Height); - } - - [Fact] - public void IsEmptyDefaultsTest() - { - Assert.True(Size.Empty.IsEmpty); - Assert.True(new Size().IsEmpty); - Assert.True(new Size(0, 0).IsEmpty); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - public void IsEmptyRandomTest(int width, int height) - { - Assert.False(new Size(width, height).IsEmpty); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(0, 0)] - public void DimensionsTest(int width, int height) - { - var p = new Size(width, height); - Assert.Equal(width, p.Width); - Assert.Equal(height, p.Height); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(0, 0)] - public void PointFConversionTest(int width, int height) - { - SizeF sz = new Size(width, height); - Assert.Equal(new SizeF(width, height), sz); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(0, 0)] - public void SizeConversionTest(int width, int height) - { - var sz = (Point)new Size(width, height); - Assert.Equal(new Point(width, height), sz); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(0, 0)] - public void ArithmeticTest(int width, int height) - { - var sz1 = new Size(width, height); - var sz2 = new Size(height, width); - Size addExpected, subExpected; - - unchecked - { - addExpected = new Size(width + height, height + width); - subExpected = new Size(width - height, height - width); - } - - Assert.Equal(addExpected, sz1 + sz2); - Assert.Equal(subExpected, sz1 - sz2); - Assert.Equal(addExpected, Size.Add(sz1, sz2)); - Assert.Equal(subExpected, Size.Subtract(sz1, sz2)); - } - - [Theory] - [InlineData(float.MaxValue, float.MinValue)] - [InlineData(float.MinValue, float.MinValue)] - [InlineData(float.MaxValue, float.MaxValue)] - [InlineData(0, 0)] - public void PointFMathematicalTest(float width, float height) - { - var szF = new SizeF(width, height); - Size pCeiling, pTruncate, pRound; - - unchecked - { - pCeiling = new Size((int)MathF.Ceiling(width), (int)MathF.Ceiling(height)); - pTruncate = new Size((int)width, (int)height); - pRound = new Size((int)MathF.Round(width), (int)MathF.Round(height)); - } - - Assert.Equal(pCeiling, Size.Ceiling(szF)); - Assert.Equal(pRound, Size.Round(szF)); - Assert.Equal(pTruncate, (Size)szF); - } - - [Theory] - [InlineData(int.MaxValue, int.MinValue)] - [InlineData(int.MinValue, int.MinValue)] - [InlineData(int.MaxValue, int.MaxValue)] - [InlineData(0, 0)] - public void EqualityTest(int width, int height) - { - var p1 = new Size(width, height); - var p2 = new Size(unchecked(width - 1), unchecked(height - 1)); - var p3 = new Size(width, height); - - Assert.True(p1 == p3); - Assert.True(p1 != p2); - Assert.True(p2 != p3); - - Assert.True(p1.Equals(p3)); - Assert.False(p1.Equals(p2)); - Assert.False(p2.Equals(p3)); - - Assert.True(p1.Equals((object)p3)); - Assert.False(p1.Equals((object)p2)); - Assert.False(p2.Equals((object)p3)); - - Assert.Equal(p1.GetHashCode(), p3.GetHashCode()); - } - - [Fact] - public static void EqualityTest_NotSize() - { - var size = new Size(0, 0); - Assert.False(size.Equals(null)); - Assert.False(size.Equals(0)); - Assert.False(size.Equals(new SizeF(0, 0))); - } - - [Fact] - public static void GetHashCodeTest() - { - var size = new Size(10, 10); - Assert.Equal(size.GetHashCode(), new Size(10, 10).GetHashCode()); - Assert.NotEqual(size.GetHashCode(), new Size(20, 10).GetHashCode()); - Assert.NotEqual(size.GetHashCode(), new Size(10, 20).GetHashCode()); - } - - [Fact] - public void ToStringTest() - { - var sz = new Size(10, 5); - Assert.Equal(string.Format(CultureInfo.CurrentCulture, "Size [ Width={0}, Height={1} ]", sz.Width, sz.Height), sz.ToString()); - } - - [Fact] - public void ToStringTestEmpty() - { - var sz = new Size(0, 0); - Assert.Equal("Size [ Empty ]", sz.ToString()); - } - } -} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs index e792de22f0..642df598a3 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.Binarization { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class BinaryThresholdTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Binarization/DitherTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/DitherTest.cs index 2948c10460..a06397c864 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/DitherTest.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/DitherTest.cs @@ -8,7 +8,7 @@ namespace ImageSharp.Tests.Processing.Binarization using ImageSharp.Dithering; using ImageSharp.Dithering.Ordered; using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class DitherTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/ColorMatrix/BlackWhiteTest.cs b/tests/ImageSharp.Tests/Processing/ColorMatrix/BlackWhiteTest.cs index d825b4993a..4dc70fb0f5 100644 --- a/tests/ImageSharp.Tests/Processing/ColorMatrix/BlackWhiteTest.cs +++ b/tests/ImageSharp.Tests/Processing/ColorMatrix/BlackWhiteTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.ColorMatrix { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class BlackWhiteTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/ColorMatrix/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/ColorMatrix/ColorBlindnessTest.cs index b56ec3471a..bc1c8ad226 100644 --- a/tests/ImageSharp.Tests/Processing/ColorMatrix/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/ColorMatrix/ColorBlindnessTest.cs @@ -7,7 +7,7 @@ namespace ImageSharp.Tests.Processing.ColorMatrix { using ImageSharp.PixelFormats; using ImageSharp.Processing; - + using SixLabors.Primitives; using Xunit; public class ColorBlindnessTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/ColorMatrix/GrayscaleTest.cs b/tests/ImageSharp.Tests/Processing/ColorMatrix/GrayscaleTest.cs index 89a388e4d4..9bf55a6d25 100644 --- a/tests/ImageSharp.Tests/Processing/ColorMatrix/GrayscaleTest.cs +++ b/tests/ImageSharp.Tests/Processing/ColorMatrix/GrayscaleTest.cs @@ -7,7 +7,7 @@ namespace ImageSharp.Tests.Processing.ColorMatrix { using ImageSharp.PixelFormats; using ImageSharp.Processing; - + using SixLabors.Primitives; using Xunit; public class GrayscaleTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/ColorMatrix/HueTest.cs b/tests/ImageSharp.Tests/Processing/ColorMatrix/HueTest.cs index b71905374a..ba1cf2b8f7 100644 --- a/tests/ImageSharp.Tests/Processing/ColorMatrix/HueTest.cs +++ b/tests/ImageSharp.Tests/Processing/ColorMatrix/HueTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.ColorMatrix { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class HueTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/ColorMatrix/KodachromeTest.cs b/tests/ImageSharp.Tests/Processing/ColorMatrix/KodachromeTest.cs index 3a5d4f0d34..971cdb6d81 100644 --- a/tests/ImageSharp.Tests/Processing/ColorMatrix/KodachromeTest.cs +++ b/tests/ImageSharp.Tests/Processing/ColorMatrix/KodachromeTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.ColorMatrix { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class KodachromeTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/ColorMatrix/LomographTest.cs b/tests/ImageSharp.Tests/Processing/ColorMatrix/LomographTest.cs index bfa37eef4e..5b41cdb3b7 100644 --- a/tests/ImageSharp.Tests/Processing/ColorMatrix/LomographTest.cs +++ b/tests/ImageSharp.Tests/Processing/ColorMatrix/LomographTest.cs @@ -8,7 +8,7 @@ namespace ImageSharp.Tests using System.IO; using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class LomographTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/ColorMatrix/PolaroidTest.cs b/tests/ImageSharp.Tests/Processing/ColorMatrix/PolaroidTest.cs index 2bf1c36989..48f7a6c0a8 100644 --- a/tests/ImageSharp.Tests/Processing/ColorMatrix/PolaroidTest.cs +++ b/tests/ImageSharp.Tests/Processing/ColorMatrix/PolaroidTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.ColorMatrix { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class PolaroidTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/ColorMatrix/SaturationTest.cs b/tests/ImageSharp.Tests/Processing/ColorMatrix/SaturationTest.cs index 9212c09e83..a4a4f3bb51 100644 --- a/tests/ImageSharp.Tests/Processing/ColorMatrix/SaturationTest.cs +++ b/tests/ImageSharp.Tests/Processing/ColorMatrix/SaturationTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.ColorMatrix { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class SaturationTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/ColorMatrix/SepiaTest.cs b/tests/ImageSharp.Tests/Processing/ColorMatrix/SepiaTest.cs index de536050ba..af554e30d8 100644 --- a/tests/ImageSharp.Tests/Processing/ColorMatrix/SepiaTest.cs +++ b/tests/ImageSharp.Tests/Processing/ColorMatrix/SepiaTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.ColorMatrix { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class SepiaTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs index b5ee876de7..ef049a539a 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/BoxBlurTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.Convolution { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class BoxBlurTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs index 220c0f4664..d5817ab14f 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs @@ -7,7 +7,7 @@ namespace ImageSharp.Tests.Processing.Convolution { using ImageSharp.PixelFormats; using ImageSharp.Processing; - + using SixLabors.Primitives; using Xunit; public class DetectEdgesTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs index dbaed9290c..fa4e4b0b6b 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.Convolution { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class GaussianBlurTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs b/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs index 44296d9751..d15042ee69 100644 --- a/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs +++ b/tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.Convolution { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class GaussianSharpenTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Effects/AlphaTest.cs b/tests/ImageSharp.Tests/Processing/Effects/AlphaTest.cs index 63366dc1da..34a24e70be 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/AlphaTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/AlphaTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.Effects { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class AlphaTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs index c3fda4cd4b..63efbf3e73 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.Effects { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class BackgroundColorTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Effects/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Effects/BrightnessTest.cs index 4c0217fed0..c3b37705a9 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/BrightnessTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.Effects { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class BrightnessTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Effects/ContrastTest.cs b/tests/ImageSharp.Tests/Processing/Effects/ContrastTest.cs index ac217e9f6a..892eb93622 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/ContrastTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/ContrastTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.Effects { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class ContrastTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Effects/InvertTest.cs b/tests/ImageSharp.Tests/Processing/Effects/InvertTest.cs index 80e3450926..3d8b3d1a1f 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/InvertTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/InvertTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.Effects { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class InvertTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs index 7d02ace3da..3d0e8f1177 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class OilPaintTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs index 740b78c558..253f1f4598 100644 --- a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs +++ b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.Effects { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class PixelateTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs index a233e204cb..d0633dca59 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.Overlays { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class GlowTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs index 85ccfca6f0..56fcf0ee0d 100644 --- a/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs +++ b/tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs @@ -6,7 +6,7 @@ namespace ImageSharp.Tests.Processing.Overlays { using ImageSharp.PixelFormats; - + using SixLabors.Primitives; using Xunit; public class VignetteTest : FileTestBase diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs index 008d041e7e..fb195254e3 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs @@ -7,7 +7,7 @@ namespace ImageSharp.Tests.Processing.Transforms { using ImageSharp.PixelFormats; using ImageSharp.Processing; - + using SixLabors.Primitives; using Xunit; public class ResizeTests : FileTestBase