Browse Source

drop PointF and use Vector2 instead

af/merge-core
Scott Williams 10 years ago
parent
commit
e0f973f550
  1. 14
      ImageSharp.v2.ncrunchsolution
  2. 170
      src/ImageSharp/Drawing/Draw.cs
  3. 39
      src/ImageSharp/Drawing/Fill.cs
  4. 29
      src/ImageSharp/Drawing/Paths/BezierLineSegment.cs
  5. 31
      src/ImageSharp/Drawing/Paths/LinearLineSegment.cs
  6. 13
      src/ImageSharp/Drawing/Shapes/BezierPolygon.cs
  7. 15
      src/ImageSharp/Drawing/Shapes/LinearPolygon.cs
  8. 287
      src/ImageSharp/Numerics/PointF.cs
  9. 14
      tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs
  10. 12
      tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs
  11. 12
      tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs
  12. 8
      tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs
  13. 16
      tests/ImageSharp.Tests/Drawing/BeziersTests.cs
  14. 57
      tests/ImageSharp.Tests/Drawing/DrawPathTests.cs
  15. 48
      tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs
  16. 44
      tests/ImageSharp.Tests/Drawing/LineTests.cs
  17. 69
      tests/ImageSharp.Tests/Drawing/PolygonTests.cs
  18. 16
      tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs
  19. 36
      tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs
  20. 20
      tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs

14
ImageSharp.v2.ncrunchsolution

@ -0,0 +1,14 @@
<SolutionConfiguration>
<FileVersion>1</FileVersion>
<InferProjectReferencesUsingAssemblyNames>false</InferProjectReferencesUsingAssemblyNames>
<AllowParallelTestExecution>false</AllowParallelTestExecution>
<AllowTestsToRunInParallelWithThemselves>true</AllowTestsToRunInParallelWithThemselves>
<FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>
<FrameworkUtilisationTypeForGallio>UseStaticAnalysis</FrameworkUtilisationTypeForGallio>
<FrameworkUtilisationTypeForMSpec>UseStaticAnalysis</FrameworkUtilisationTypeForMSpec>
<FrameworkUtilisationTypeForMSTest>UseStaticAnalysis</FrameworkUtilisationTypeForMSTest>
<FrameworkUtilisationTypeForXUnit2>UseDynamicAnalysis</FrameworkUtilisationTypeForXUnit2>
<NCrunchCacheStoragePath />
<MetricsExclusionList>
</MetricsExclusionList>
</SolutionConfiguration>

170
src/ImageSharp/Drawing/Draw.cs

@ -5,6 +5,7 @@
namespace ImageSharp
{
using System.Numerics;
using Drawing;
using Drawing.Brushes;
using Drawing.Paths;
@ -78,7 +79,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, IBrush<TColor, TPacked> brush, float thickness, PointF[] points)
public static Image<TColor, TPacked> DrawPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, IBrush<TColor, TPacked> brush, float thickness, Vector2[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -95,7 +96,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, float thickness, PointF[] points)
public static Image<TColor, TPacked> DrawPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, float thickness, Vector2[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -111,57 +112,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, IPen<TColor, TPacked> pen, PointF[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
return source.DrawPolygon(pen, new Polygon(new LinearLineSegment(points)));
}
/// <summary>
/// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness.
/// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam>
/// <typeparam name="TPacked">The type of the packed.</typeparam>
/// <param name="source">The source.</param>
/// <param name="brush">The brush.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, IBrush<TColor, TPacked> brush, float thickness, Point[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
return source.DrawPolygon(new Pen<TColor, TPacked>(brush, thickness), new Polygon(new LinearLineSegment(points)));
}
/// <summary>
/// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness.
/// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam>
/// <typeparam name="TPacked">The type of the packed.</typeparam>
/// <param name="source">The source.</param>
/// <param name="color">The color.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, float thickness, Point[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
return source.DrawPolygon(new SolidBrush<TColor, TPacked>(color), thickness, points);
}
/// <summary>
/// Draws the provided Points as a closed Linear Polygon with the provided Pen.
/// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam>
/// <typeparam name="TPacked">The type of the packed.</typeparam>
/// <param name="source">The source.</param>
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, IPen<TColor, TPacked> pen, Point[] points)
public static Image<TColor, TPacked> DrawPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, IPen<TColor, TPacked> pen, Vector2[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -228,7 +179,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawLines<TColor, TPacked>(this Image<TColor, TPacked> source, IBrush<TColor, TPacked> brush, float thickness, PointF[] points)
public static Image<TColor, TPacked> DrawLines<TColor, TPacked>(this Image<TColor, TPacked> source, IBrush<TColor, TPacked> brush, float thickness, Vector2[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -245,7 +196,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawLines<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, float thickness, PointF[] points)
public static Image<TColor, TPacked> DrawLines<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, float thickness, Vector2[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -261,112 +212,13 @@ namespace ImageSharp
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawLines<TColor, TPacked>(this Image<TColor, TPacked> source, IPen<TColor, TPacked> pen, PointF[] points)
public static Image<TColor, TPacked> DrawLines<TColor, TPacked>(this Image<TColor, TPacked> source, IPen<TColor, TPacked> pen, Vector2[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
return source.DrawPath(pen, new Path(new LinearLineSegment(points)));
}
/// <summary>
/// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush
/// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam>
/// <typeparam name="TPacked">The type of the packed.</typeparam>
/// <param name="source">The source.</param>
/// <param name="brush">The brush.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawLines<TColor, TPacked>(this Image<TColor, TPacked> source, IBrush<TColor, TPacked> brush, float thickness, Point[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
return source.DrawPath(new Pen<TColor, TPacked>(brush, thickness), new Path(new LinearLineSegment(points)));
}
/// <summary>
/// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush
/// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam>
/// <typeparam name="TPacked">The type of the packed.</typeparam>
/// <param name="source">The source.</param>
/// <param name="color">The color.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawLines<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, float thickness, Point[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
return source.DrawLines(new SolidBrush<TColor, TPacked>(color), thickness, points);
}
/// <summary>
/// Draws the provided Points as an open Linear path with the supplied pen
/// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam>
/// <typeparam name="TPacked">The type of the packed.</typeparam>
/// <param name="source">The source.</param>
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawLines<TColor, TPacked>(this Image<TColor, TPacked> source, IPen<TColor, TPacked> pen, Point[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
return source.DrawPath(pen, new Path(new LinearLineSegment(points)));
}
/// <summary>
/// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush
/// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam>
/// <typeparam name="TPacked">The type of the packed.</typeparam>
/// <param name="source">The source.</param>
/// <param name="brush">The brush.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawBeziers<TColor, TPacked>(this Image<TColor, TPacked> source, IBrush<TColor, TPacked> brush, float thickness, PointF[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
return source.DrawPath(new Pen<TColor, TPacked>(brush, thickness), new Path(new BezierLineSegment(points)));
}
/// <summary>
/// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush
/// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam>
/// <typeparam name="TPacked">The type of the packed.</typeparam>
/// <param name="source">The source.</param>
/// <param name="color">The color.</param>
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawBeziers<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, float thickness, PointF[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
return source.DrawBeziers(new SolidBrush<TColor, TPacked>(color), thickness, points);
}
/// <summary>
/// Draws the provided Points as an open Bezier path with the supplied pen
/// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam>
/// <typeparam name="TPacked">The type of the packed.</typeparam>
/// <param name="source">The source.</param>
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawBeziers<TColor, TPacked>(this Image<TColor, TPacked> source, IPen<TColor, TPacked> pen, PointF[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
return source.DrawPath(pen, new Path(new BezierLineSegment(points)));
}
/// <summary>
/// Draws the provided Points as an open Bezier path at the provided thickness with the supplied brush
@ -378,7 +230,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawBeziers<TColor, TPacked>(this Image<TColor, TPacked> source, IBrush<TColor, TPacked> brush, float thickness, Point[] points)
public static Image<TColor, TPacked> DrawBeziers<TColor, TPacked>(this Image<TColor, TPacked> source, IBrush<TColor, TPacked> brush, float thickness, Vector2[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -395,7 +247,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawBeziers<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, float thickness, Point[] points)
public static Image<TColor, TPacked> DrawBeziers<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, float thickness, Vector2[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -411,7 +263,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> DrawBeziers<TColor, TPacked>(this Image<TColor, TPacked> source, IPen<TColor, TPacked> pen, Point[] points)
public static Image<TColor, TPacked> DrawBeziers<TColor, TPacked>(this Image<TColor, TPacked> source, IPen<TColor, TPacked> pen, Vector2[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{

39
src/ImageSharp/Drawing/Fill.cs

@ -5,6 +5,7 @@
namespace ImageSharp
{
using System.Numerics;
using Drawing;
using Drawing.Brushes;
using Drawing.Paths;
@ -88,7 +89,7 @@ namespace ImageSharp
/// <param name="brush">The brush.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> FillPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, IBrush<TColor, TPacked> brush, PointF[] points)
public static Image<TColor, TPacked> FillPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, IBrush<TColor, TPacked> brush, Vector2[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
@ -105,46 +106,12 @@ namespace ImageSharp
/// <param name="color">The color.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> FillPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, PointF[] points)
public static Image<TColor, TPacked> FillPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, Vector2[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
// using Polygon directly instead of LinearPolygon as its will have less indirection
return source.Fill(new SolidBrush<TColor, TPacked>(color), new Polygon(new LinearLineSegment(points)));
}
/// <summary>
/// Flood fills the image in the shape of a Linear polygon described by the points
/// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam>
/// <typeparam name="TPacked">The type of the packed.</typeparam>
/// <param name="source">The source.</param>
/// <param name="brush">The brush.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> FillPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, IBrush<TColor, TPacked> brush, Point[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
// using Polygon directly instead of LinearPolygon as its will have less indirection
return source.Fill(brush, new Polygon(new LinearLineSegment(points)));
}
/// <summary>
/// Flood fills the image in the shape of a Linear polygon described by the points
/// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam>
/// <typeparam name="TPacked">The type of the packed.</typeparam>
/// <param name="source">The source.</param>
/// <param name="color">The color.</param>
/// <param name="points">The points.</param>
/// <returns>The Image</returns>
public static Image<TColor, TPacked> FillPolygon<TColor, TPacked>(this Image<TColor, TPacked> source, TColor color, Point[] points)
where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct
{
// using Polygon directly instead of LinearPolygon as its will have less indirection
return source.Fill(new SolidBrush<TColor, TPacked>(color), new Polygon(new LinearLineSegment(points)));
}
}
}

29
src/ImageSharp/Drawing/Paths/BezierLineSegment.cs

@ -23,38 +23,11 @@ namespace ImageSharp.Drawing.Paths
private Vector2[] linePoints;
/// <summary>
/// Initializes a new instance of the <see cref="BezierLineSegment" /> class.
/// </summary>
/// <param name="points">The points.</param>
public BezierLineSegment(IEnumerable<PointF> points)
: this(points?.Select(x => x.ToVector2()).ToArray())
{
}
/// <summary>
/// Initializes a new instance of the <see cref="BezierLineSegment"/> class.
/// </summary>
/// <param name="points">The points.</param>
public BezierLineSegment(IEnumerable<Point> points)
: this(points?.Select(x => x.ToVector2()).ToArray())
{
}
/// <summary>
/// Initializes a new instance of the <see cref="BezierLineSegment"/> class.
/// </summary>
/// <param name="points">The points.</param>
public BezierLineSegment(params PointF[] points)
: this(points?.Select(x => x.ToVector2()).ToArray())
{
}
/// <summary>
/// Initializes a new instance of the <see cref="BezierLineSegment"/> class.
/// </summary>
/// <param name="points">The points.</param>
internal BezierLineSegment(Vector2[] points)
public BezierLineSegment(params Vector2[] points)
{
Guard.NotNull(points, nameof(points));
Guard.MustBeGreaterThanOrEqualTo(points.Length, 4, nameof(points));

31
src/ImageSharp/Drawing/Paths/LinearLineSegment.cs

@ -20,39 +20,12 @@ namespace ImageSharp.Drawing.Paths
{
private Vector2[] points;
/// <summary>
/// Initializes a new instance of the <see cref="LinearLineSegment"/> class.
/// </summary>
/// <param name="points">The points.</param>
public LinearLineSegment(IEnumerable<PointF> points)
: this(points?.Select(x => x.ToVector2()).ToArray())
{
}
/// <summary>
/// Initializes a new instance of the <see cref="LinearLineSegment"/> class.
/// </summary>
/// <param name="points">The points.</param>
public LinearLineSegment(IEnumerable<Point> points)
: this(points?.Select(x => x.ToVector2()).ToArray())
{
}
/// <summary>
/// Initializes a new instance of the <see cref="LinearLineSegment"/> class.
/// </summary>
/// <param name="points">The points.</param>
public LinearLineSegment(params PointF[] points)
: this(points?.Select(x => x.ToVector2()).ToArray())
{
}
/// <summary>
/// Initializes a new instance of the <see cref="LinearLineSegment"/> class.
/// </summary>
/// <param name="start">The start.</param>
/// <param name="end">The end.</param>
internal LinearLineSegment(Vector2 start, Vector2 end)
public LinearLineSegment(Vector2 start, Vector2 end)
: this(new[] { start, end })
{
}
@ -61,7 +34,7 @@ namespace ImageSharp.Drawing.Paths
/// Initializes a new instance of the <see cref="LinearLineSegment"/> class.
/// </summary>
/// <param name="points">The points.</param>
internal LinearLineSegment(Vector2[] points)
public LinearLineSegment(params Vector2[] points)
{
Guard.NotNull(points, nameof(points));
Guard.MustBeGreaterThanOrEqualTo(points.Count(), 2, nameof(points));

13
src/ImageSharp/Drawing/Shapes/BezierPolygon.cs

@ -7,7 +7,7 @@ namespace ImageSharp.Drawing.Shapes
{
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using Paths;
/// <summary>
@ -21,16 +21,7 @@ namespace ImageSharp.Drawing.Shapes
/// Initializes a new instance of the <see cref="BezierPolygon"/> class.
/// </summary>
/// <param name="points">The points.</param>
public BezierPolygon(params Point[] points)
{
this.innerPolygon = new Polygon(new BezierLineSegment(points));
}
/// <summary>
/// Initializes a new instance of the <see cref="BezierPolygon"/> class.
/// </summary>
/// <param name="points">The points.</param>
public BezierPolygon(params PointF[] points)
public BezierPolygon(params Vector2[] points)
{
this.innerPolygon = new Polygon(new BezierLineSegment(points));
}

15
src/ImageSharp/Drawing/Shapes/LinearPolygon.cs

@ -7,7 +7,7 @@ namespace ImageSharp.Drawing.Shapes
{
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using Paths;
/// <summary>
@ -21,20 +21,11 @@ namespace ImageSharp.Drawing.Shapes
/// Initializes a new instance of the <see cref="LinearPolygon"/> class.
/// </summary>
/// <param name="points">The points.</param>
public LinearPolygon(params Point[] points)
{
this.innerPolygon = new Polygon(new LinearLineSegment(points));
}
/// <summary>
/// Initializes a new instance of the <see cref="LinearPolygon"/> class.
/// </summary>
/// <param name="points">The points.</param>
public LinearPolygon(params PointF[] points)
public LinearPolygon(params Vector2[] points)
{
this.innerPolygon = new Polygon(new LinearLineSegment(points));
}
/// <summary>
/// Gets the bounding box of this shape.
/// </summary>

287
src/ImageSharp/Numerics/PointF.cs

@ -1,287 +0,0 @@
// <copyright file="PointF.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Represents an ordered pair of floating point x- and y-coordinates that defines a point in
/// a two-dimensional plane.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
public struct PointF : IEquatable<PointF>
{
/// <summary>
/// Represents a <see cref="Point"/> that has X and Y values set to zero.
/// </summary>
public static readonly PointF Empty = default(PointF);
private Vector2 backingVector;
/// <summary>
/// Initializes a new instance of the <see cref="PointF"/> struct.
/// </summary>
/// <param name="x">The horizontal position of the point.</param>
/// <param name="y">The vertical position of the point.</param>
public PointF(float x, float y)
: this(new Vector2(x, y))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="PointF"/> struct.
/// </summary>
/// <param name="vector">
/// The vector representing the width and height.
/// </param>
public PointF(Vector2 vector)
{
this.backingVector = vector;
}
/// <summary>
/// Gets or sets the x-coordinate of this <see cref="PointF"/>.
/// </summary>
public float X
{
get { return this.backingVector.X; }
set { this.backingVector.X = value; }
}
/// <summary>
/// Gets or sets the y-coordinate of this <see cref="PointF"/>.
/// </summary>
public float Y
{
get { return this.backingVector.Y; }
set { this.backingVector.Y = value; }
}
/// <summary>
/// Gets a value indicating whether this <see cref="PointF"/> is empty.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsEmpty => this.Equals(Empty);
/// <summary>
/// Performs an implicit conversion from <see cref="Point"/> to <see cref="PointF"/>.
/// </summary>
/// <param name="d">The d.</param>
/// <returns>
/// The result of the conversion.
/// </returns>
public static implicit operator PointF(Point d)
{
return new PointF(d.ToVector2());
}
/// <summary>
/// Computes the sum of adding two points.
/// </summary>
/// <param name="left">The point on the left hand of the operand.</param>
/// <param name="right">The point on the right hand of the operand.</param>
/// <returns>
/// The <see cref="Point"/>
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static PointF operator +(PointF left, PointF right)
{
return new PointF(left.backingVector + right.backingVector);
}
/// <summary>
/// Computes the difference left by subtracting one point from another.
/// </summary>
/// <param name="left">The point on the left hand of the operand.</param>
/// <param name="right">The point on the right hand of the operand.</param>
/// <returns>
/// The <see cref="PointF"/>
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static PointF operator -(PointF left, PointF right)
{
return new PointF(left.backingVector - right.backingVector);
}
/// <summary>
/// Compares two <see cref="PointF"/> objects for equality.
/// </summary>
/// <param name="left">
/// The <see cref="PointF"/> on the left side of the operand.
/// </param>
/// <param name="right">
/// The <see cref="PointF"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(PointF left, PointF right)
{
return left.Equals(right);
}
/// <summary>
/// Compares two <see cref="Point"/> objects for inequality.
/// </summary>
/// <param name="left">
/// The <see cref="Point"/> on the left side of the operand.
/// </param>
/// <param name="right">
/// The <see cref="Point"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(PointF left, PointF right)
{
return !left.Equals(right);
}
/// <summary>
/// Creates a rotation matrix for the given point and angle.
/// </summary>
/// <param name="origin">The origin point to rotate around</param>
/// <param name="degrees">Rotation in degrees</param>
/// <returns>The rotation <see cref="Matrix3x2"/></returns>
public static Matrix3x2 CreateRotation(PointF origin, float degrees)
{
float radians = ImageMaths.DegreesToRadians(degrees);
return Matrix3x2.CreateRotation(radians, new Vector2(origin.X, origin.Y));
}
/// <summary>
/// Rotates a point around a given a rotation matrix.
/// </summary>
/// <param name="point">The point to rotate</param>
/// <param name="rotation">Rotation matrix used</param>
/// <returns>The rotated <see cref="Point"/></returns>
public static PointF Rotate(PointF point, Matrix3x2 rotation)
{
return new PointF(Vector2.Transform(new Vector2(point.X, point.Y), rotation));
}
/// <summary>
/// Rotates a point around a given origin by the specified angle in degrees.
/// </summary>
/// <param name="point">The point to rotate</param>
/// <param name="origin">The center point to rotate around.</param>
/// <param name="degrees">The angle in degrees.</param>
/// <returns>The rotated <see cref="Point"/></returns>
public static PointF Rotate(PointF point, PointF origin, float degrees)
{
return new PointF(Vector2.Transform(new Vector2(point.X, point.Y), CreateRotation(origin, degrees)));
}
/// <summary>
/// Creates a skew matrix for the given point and angle.
/// </summary>
/// <param name="origin">The origin point to rotate around</param>
/// <param name="degreesX">The x-angle in degrees.</param>
/// <param name="degreesY">The y-angle in degrees.</param>
/// <returns>The rotation <see cref="Matrix3x2"/></returns>
public static Matrix3x2 CreateSkew(PointF origin, float degreesX, float degreesY)
{
float radiansX = ImageMaths.DegreesToRadians(degreesX);
float radiansY = ImageMaths.DegreesToRadians(degreesY);
return Matrix3x2.CreateSkew(radiansX, radiansY, origin.backingVector);
}
/// <summary>
/// Skews a point using a given a skew matrix.
/// </summary>
/// <param name="point">The point to rotate</param>
/// <param name="skew">Rotation matrix used</param>
/// <returns>The rotated <see cref="Point"/></returns>
public static PointF Skew(PointF point, Matrix3x2 skew)
{
return new PointF(Vector2.Transform(point.backingVector, skew));
}
/// <summary>
/// Skews a point around a given origin by the specified angles in degrees.
/// </summary>
/// <param name="point">The point to skew.</param>
/// <param name="origin">The center point to rotate around.</param>
/// <param name="degreesX">The x-angle in degrees.</param>
/// <param name="degreesY">The y-angle in degrees.</param>
/// <returns>The skewed <see cref="Point"/></returns>
public static PointF Skew(PointF point, PointF origin, float degreesX, float degreesY)
{
return new PointF(Vector2.Transform(point.backingVector, CreateSkew(origin, degreesX, degreesY)));
}
/// <summary>
/// Gets a <see cref="Vector2"/> representation for this <see cref="Point"/>.
/// </summary>
/// <returns>A <see cref="Vector2"/> representation for this object.</returns>
public Vector2 ToVector2()
{
// should this be a return of the mutable vector2 backing vector instead of a copy?
return new Vector2(this.X, this.Y);
}
/// <summary>
/// Translates this <see cref="Point"/> by the specified amount.
/// </summary>
/// <param name="dx">The amount to offset the x-coordinate.</param>
/// <param name="dy">The amount to offset the y-coordinate.</param>
public void Offset(float dx, float dy)
{
this.backingVector += new Vector2(dx, dy);
}
/// <summary>
/// Translates this <see cref="PointF"/> by the specified amount.
/// </summary>
/// <param name="p">The <see cref="PointF"/> used offset this <see cref="PointF"/>.</param>
public void Offset(PointF p)
{
this.backingVector += p.backingVector;
}
/// <inheritdoc/>
public override int GetHashCode()
{
return this.backingVector.GetHashCode();
}
/// <inheritdoc/>
public override string ToString()
{
if (this.IsEmpty)
{
return "Point [ Empty ]";
}
return $"Point [ X={this.X}, Y={this.Y} ]";
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
if (obj is PointF)
{
return this.Equals((PointF)obj);
}
return false;
}
/// <inheritdoc/>
public bool Equals(PointF other)
{
return this.backingVector == other.backingVector;
}
}
}

14
tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs

@ -11,10 +11,10 @@ namespace ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using CoreImage = ImageSharp.Image;
using CorePoint = ImageSharp.Point;
using CorePointF= ImageSharp.PointF;
using CoreColor= ImageSharp.Color;
using CoreColor = ImageSharp.Color;
using System.IO;
using System.Numerics;
public class DrawBeziers
{
[Benchmark(Baseline = true, Description = "System.Drawing Draw Beziers")]
@ -49,10 +49,10 @@ namespace ImageSharp.Benchmarks
CoreImage image = new CoreImage(800, 800);
image.DrawBeziers(CoreColor.HotPink, 10, new[] {
new CorePointF(10, 500),
new CorePointF(30, 10),
new CorePointF(240, 30),
new CorePointF(300, 500)
new Vector2(10, 500),
new Vector2(30, 10),
new Vector2(240, 30),
new Vector2(300, 500)
});
using (MemoryStream ms = new MemoryStream())

12
tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs

@ -11,10 +11,10 @@ namespace ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using CoreImage = ImageSharp.Image;
using CorePoint = ImageSharp.Point;
using CorePointF= ImageSharp.PointF;
using CoreColor= ImageSharp.Color;
using CoreColor = ImageSharp.Color;
using System.IO;
using System.Numerics;
public class DrawLines
{
[Benchmark(Baseline = true, Description = "System.Drawing Draw Lines")]
@ -48,9 +48,9 @@ namespace ImageSharp.Benchmarks
CoreImage image = new CoreImage(800, 800);
image.DrawLines(CoreColor.HotPink, 10, new[] {
new CorePointF(10, 10),
new CorePointF(550, 50),
new CorePointF(200, 400)
new Vector2(10, 10),
new Vector2(550, 50),
new Vector2(200, 400)
});
using (MemoryStream ms = new MemoryStream())

12
tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs

@ -11,10 +11,10 @@ namespace ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using CoreImage = ImageSharp.Image;
using CorePoint = ImageSharp.Point;
using CorePointF= ImageSharp.PointF;
using CoreColor= ImageSharp.Color;
using CoreColor = ImageSharp.Color;
using System.IO;
using System.Numerics;
public class DrawPolygon
{
[Benchmark(Baseline = true, Description = "System.Drawing Draw Polygon")]
@ -48,9 +48,9 @@ namespace ImageSharp.Benchmarks
CoreImage image = new CoreImage(800, 800);
image.DrawPolygon(CoreColor.HotPink, 10, new[] {
new CorePointF(10, 10),
new CorePointF(550, 50),
new CorePointF(200, 400)
new Vector2(10, 10),
new Vector2(550, 50),
new Vector2(200, 400)
});
using (MemoryStream ms = new MemoryStream())

8
tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs

@ -10,9 +10,9 @@ namespace ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using CoreImage = ImageSharp.Image;
using CorePoint = ImageSharp.Point;
using CoreColor = ImageSharp.Color;
using System.IO;
using System.Numerics;
public class FillPolygon
{
@ -44,9 +44,9 @@ namespace ImageSharp.Benchmarks
CoreImage image = new CoreImage(800, 800);
image.FillPolygon(CoreColor.HotPink,
new[] {
new CorePoint(10, 10),
new CorePoint(550, 50),
new CorePoint(200, 400)
new Vector2(10, 10),
new Vector2(550, 50),
new Vector2(200, 400)
}
);

16
tests/ImageSharp.Tests/Drawing/BeziersTests.cs

@ -28,10 +28,10 @@ using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
image
.BackgroundColor(Color.Blue)
.DrawBeziers(Color.HotPink, 5, new[] {
new PointF(10, 400),
new PointF(30, 10),
new PointF(240, 30),
new PointF(300, 400)
new Vector2(10, 400),
new Vector2(30, 10),
new Vector2(240, 30),
new Vector2(300, 400)
})
.Save(output);
}
@ -70,10 +70,10 @@ using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
image
.BackgroundColor(Color.Blue)
.DrawBeziers(color, 10, new[] {
new PointF(10, 400),
new PointF(30, 10),
new PointF(240, 30),
new PointF(300, 400)
new Vector2(10, 400),
new Vector2(30, 10),
new Vector2(240, 30),
new Vector2(300, 400)
})
.Save(output);
}

57
tests/ImageSharp.Tests/Drawing/DrawPathTests.cs

@ -23,27 +23,26 @@ namespace ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByPath()
{
string path = CreateOutputDirectory("Drawing", "Path");
var image = new Image(500, 500);
var image = new Image(500, 500);
var linerSegemnt = new LinearLineSegment(
new Point(10, 10),
new Point(200, 150),
new Point(50, 300)
);
var bazierSegment = new BezierLineSegment(new Point(50, 300),
new Point(500, 500),
new Point(60, 10),
new Point(10, 400));
var linerSegemnt = new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300));
var bazierSegment = new BezierLineSegment(new Vector2(50, 300),
new Vector2(500, 500),
new Vector2(60, 10),
new Vector2(10, 400));
var p = new CorePath(linerSegemnt, bazierSegment);
var p = new CorePath(linerSegemnt, bazierSegment);
using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawPath(Color.HotPink, 5, p)
.Save(output);
}
using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawPath(Color.HotPink, 5, p)
.Save(output);
}
using (var sourcePixels = image.Lock())
{
@ -66,19 +65,19 @@ using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
var linerSegemnt = new LinearLineSegment(
new Point(10, 10),
new Point(200, 150),
new Point(50, 300)
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
);
var bazierSegment = new BezierLineSegment(new Point(50, 300),
new Point(500, 500),
new Point(60, 10),
new Point(10, 400));
var bazierSegment = new BezierLineSegment(new Vector2(50, 300),
new Vector2(500, 500),
new Vector2(60, 10),
new Vector2(10, 400));
var p = new CorePath(linerSegemnt, bazierSegment);
var image = new Image(500, 500);
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{
@ -89,7 +88,7 @@ using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
}
//shift background color towards forground color by the opacity amount
var mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f/255f));
var mergedColor = new Color(Vector4.Lerp(Color.Blue.ToVector4(), Color.HotPink.ToVector4(), 150f / 255f));
using (var sourcePixels = image.Lock())
{
@ -100,6 +99,6 @@ using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
Assert.Equal(Color.Blue, sourcePixels[50, 50]);
}
}
}
}
}

48
tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs

@ -22,14 +22,14 @@ namespace ImageSharp.Tests.Drawing
{
string path = CreateOutputDirectory("Drawing", "LineComplexPolygon");
var simplePath = new LinearPolygon(
new Point(10, 10),
new Point(200, 150),
new Point(50, 300));
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300));
var hole1 = new LinearPolygon(
new Point(37, 85),
new Point(93, 85),
new Point(65, 137));
new Vector2(37, 85),
new Vector2(93, 85),
new Vector2(65, 137));
var image = new Image(500, 500);
@ -72,14 +72,14 @@ namespace ImageSharp.Tests.Drawing
{
string path = CreateOutputDirectory("Drawing", "LineComplexPolygon");
var simplePath = new LinearPolygon(
new Point(10, 10),
new Point(200, 150),
new Point(50, 300));
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300));
var hole1 = new LinearPolygon(
new Point(37, 85),
new Point(130, 40),
new Point(65, 137));
new Vector2(37, 85),
new Vector2(130, 40),
new Vector2(65, 137));
var image = new Image(500, 500);
@ -117,14 +117,14 @@ namespace ImageSharp.Tests.Drawing
{
string path = CreateOutputDirectory("Drawing", "LineComplexPolygon");
var simplePath = new LinearPolygon(
new Point(10, 10),
new Point(200, 150),
new Point(50, 300));
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300));
var hole1 = new LinearPolygon(
new Point(37, 85),
new Point(93, 85),
new Point(65, 137));
new Vector2(37, 85),
new Vector2(93, 85),
new Vector2(65, 137));
var image = new Image(500, 500);
@ -143,14 +143,14 @@ namespace ImageSharp.Tests.Drawing
{
string path = CreateOutputDirectory("Drawing", "LineComplexPolygon");
var simplePath = new LinearPolygon(
new Point(10, 10),
new Point(200, 150),
new Point(50, 300));
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300));
var hole1 = new LinearPolygon(
new Point(37, 85),
new Point(93, 85),
new Point(65, 137));
new Vector2(37, 85),
new Vector2(93, 85),
new Vector2(65, 137));
var color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
var image = new Image(500, 500);

44
tests/ImageSharp.Tests/Drawing/LineTests.cs

@ -29,9 +29,9 @@ namespace ImageSharp.Tests.Drawing
image
.BackgroundColor(Color.Blue)
.DrawLines(Color.HotPink, 5, new[] {
new Point(10, 10),
new Point(200, 150),
new Point(50, 300)
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
})
.Save(output);
}
@ -59,9 +59,9 @@ namespace ImageSharp.Tests.Drawing
image
.BackgroundColor(Color.Blue)
.DrawLines(Pens.Dash(Color.HotPink, 5), new[] {
new Point(10, 10),
new Point(200, 150),
new Point(50, 300)
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
})
.Save(output);
}
@ -79,9 +79,9 @@ namespace ImageSharp.Tests.Drawing
image
.BackgroundColor(Color.Blue)
.DrawLines(Pens.Dot(Color.HotPink, 5), new[] {
new Point(10, 10),
new Point(200, 150),
new Point(50, 300)
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
})
.Save(output);
}
@ -98,9 +98,9 @@ namespace ImageSharp.Tests.Drawing
image
.BackgroundColor(Color.Blue)
.DrawLines(Pens.DashDot(Color.HotPink, 5), new[] {
new Point(10, 10),
new Point(200, 150),
new Point(50, 300)
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
})
.Save(output);
}
@ -118,9 +118,9 @@ namespace ImageSharp.Tests.Drawing
image
.BackgroundColor(Color.Blue)
.DrawLines(Pens.DashDotDot(Color.HotPink, 5), new[] {
new Point(10, 10),
new Point(200, 150),
new Point(50, 300)
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
})
.Save(output);
}
@ -141,9 +141,9 @@ namespace ImageSharp.Tests.Drawing
image
.BackgroundColor(Color.Blue)
.DrawLines(color, 10, new[] {
new Point(10, 10),
new Point(200, 150),
new Point(50, 300)
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
})
.Save(output);
}
@ -173,10 +173,10 @@ namespace ImageSharp.Tests.Drawing
image
.BackgroundColor(Color.Blue)
.DrawLines(Color.HotPink, 10, new[] {
new Point(10, 10),
new Point(200, 10),
new Point(200, 150),
new Point(10, 150)
new Vector2(10, 10),
new Vector2(200, 10),
new Vector2(200, 150),
new Vector2(10, 150)
})
.Save(output);
}

69
tests/ImageSharp.Tests/Drawing/PolygonTests.cs

@ -19,25 +19,20 @@ namespace ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByPolygonOutline()
{
string path = CreateOutputDirectory("Drawing", "Polygons");
var simplePath = new[] {
new Point(10, 10),
new Point(200, 150),
new Point(50, 300)
};
var image = new Image(500, 500);
var image = new Image(500, 500);
using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawPolygon(Color.HotPink, 5, new[] {
new Point(10, 10),
new Point(200, 150),
new Point(50, 300)
})
.Save(output);
}
using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawPolygon(Color.HotPink, 5, new[] {
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
})
.Save(output);
}
using (var sourcePixels = image.Lock())
{
@ -57,9 +52,9 @@ using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
{
string path = CreateOutputDirectory("Drawing", "Polygons");
var simplePath = new[] {
new Point(10, 10),
new Point(200, 150),
new Point(50, 300)
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
};
var color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
@ -93,27 +88,21 @@ using (FileStream output = File.OpenWrite($"{path}/Simple.png"))
public void ImageShouldBeOverlayedByRectangleOutline()
{
string path = CreateOutputDirectory("Drawing", "Polygons");
var simplePath = new[] {
new Point(10, 10),
new Point(200, 10),
new Point(200, 150),
new Point(10, 150)
};
var image = new Image(500, 500);
var image = new Image(500, 500);
using (FileStream output = File.OpenWrite($"{path}/Rectangle.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawPolygon(Color.HotPink, 10, new[] {
new Point(10, 10),
new Point(200, 10),
new Point(200, 150),
new Point(10, 150)
})
.Save(output);
}
using (FileStream output = File.OpenWrite($"{path}/Rectangle.png"))
{
image
.BackgroundColor(Color.Blue)
.DrawPolygon(Color.HotPink, 10, new[] {
new Vector2(10, 10),
new Vector2(200, 10),
new Vector2(200, 150),
new Vector2(10, 150)
})
.Save(output);
}
using (var sourcePixels = image.Lock())
{
@ -129,4 +118,4 @@ using (FileStream output = File.OpenWrite($"{path}/Rectangle.png"))
}
}
}
}
}

16
tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs

@ -21,10 +21,10 @@ namespace ImageSharp.Tests.Drawing
{
string path = CreateOutputDirectory("Drawing", "FilledBezier");
var simplePath = new[] {
new PointF(10, 400),
new PointF(30, 10),
new PointF(240, 30),
new PointF(300, 400)
new Vector2(10, 400),
new Vector2(30, 10),
new Vector2(240, 30),
new Vector2(300, 400)
};
var image = new Image(500, 500);
@ -59,10 +59,10 @@ namespace ImageSharp.Tests.Drawing
{
string path = CreateOutputDirectory("Drawing", "FilledBezier");
var simplePath = new[] {
new PointF(10, 400),
new PointF(30, 10),
new PointF(240, 30),
new PointF(300, 400)
new Vector2(10, 400),
new Vector2(30, 10),
new Vector2(240, 30),
new Vector2(300, 400)
};
var color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);

36
tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs

@ -21,14 +21,14 @@ namespace ImageSharp.Tests.Drawing
{
string path = CreateOutputDirectory("Drawing", "ComplexPolygon");
var simplePath = new LinearPolygon(
new Point(10, 10),
new Point(200, 150),
new Point(50, 300));
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300));
var hole1 = new LinearPolygon(
new Point(37, 85),
new Point(93, 85),
new Point(65, 137));
new Vector2(37, 85),
new Vector2(93, 85),
new Vector2(65, 137));
var image = new Image(500, 500);
@ -61,14 +61,14 @@ namespace ImageSharp.Tests.Drawing
{
string path = CreateOutputDirectory("Drawing", "ComplexPolygon");
var simplePath = new LinearPolygon(
new Point(10, 10),
new Point(200, 150),
new Point(50, 300));
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300));
var hole1 = new LinearPolygon(
new Point(37, 85),
new Point(130, 40),
new Point(65, 137));
new Vector2(37, 85),
new Vector2(130, 40),
new Vector2(65, 137));
var image = new Image(500, 500);
@ -100,14 +100,14 @@ namespace ImageSharp.Tests.Drawing
{
string path = CreateOutputDirectory("Drawing", "ComplexPolygon");
var simplePath = new LinearPolygon(
new Point(10, 10),
new Point(200, 150),
new Point(50, 300));
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300));
var hole1 = new LinearPolygon(
new Point(37, 85),
new Point(93, 85),
new Point(65, 137));
new Vector2(37, 85),
new Vector2(93, 85),
new Vector2(65, 137));
var color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
var image = new Image(500, 500);

20
tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs

@ -20,9 +20,9 @@ namespace ImageSharp.Tests.Drawing
{
string path = CreateOutputDirectory("Drawing", "FilledPolygons");
var simplePath = new[] {
new Point(10, 10),
new Point(200, 150),
new Point(50, 300)
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
};
var image = new Image(500, 500);
@ -51,9 +51,9 @@ namespace ImageSharp.Tests.Drawing
{
string path = CreateOutputDirectory("Drawing", "FilledPolygons");
var simplePath = new[] {
new Point(10, 10),
new Point(200, 150),
new Point(50, 300)
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)
};
var color = new Color(Color.HotPink.R, Color.HotPink.G, Color.HotPink.B, 150);
@ -87,10 +87,10 @@ namespace ImageSharp.Tests.Drawing
{
string path = CreateOutputDirectory("Drawing", "FilledPolygons");
var simplePath = new[] {
new Point(10, 10),
new Point(200, 10),
new Point(200, 150),
new Point(10, 150)
new Vector2(10, 10),
new Vector2(200, 10),
new Vector2(200, 150),
new Vector2(10, 150)
};
var image = new Image(500, 500);

Loading…
Cancel
Save