mirror of https://github.com/SixLabors/ImageSharp
19 changed files with 116 additions and 1516 deletions
@ -1,110 +0,0 @@ |
|||
// <copyright file="DrawPath.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp |
|||
{ |
|||
using Drawing; |
|||
using Drawing.Brushes; |
|||
using Drawing.Pens; |
|||
using Drawing.Processors; |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
/// <summary>
|
|||
/// Extension methods for the <see cref="Image{TPixel}"/> type.
|
|||
/// </summary>
|
|||
public static partial class ImageExtensions |
|||
{ |
|||
/// <summary>
|
|||
/// Draws the outline of the region with the provided pen.
|
|||
/// </summary>
|
|||
/// <typeparam name="TPixel">The type of the color.</typeparam>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="pen">The pen.</param>
|
|||
/// <param name="path">The path.</param>
|
|||
/// <param name="options">The options.</param>
|
|||
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|||
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, Drawable path, GraphicsOptions options) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
return source.Apply(new DrawPathProcessor<TPixel>(pen, path, options)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Draws the outline of the polygon with the provided pen.
|
|||
/// </summary>
|
|||
/// <typeparam name="TPixel">The type of the color.</typeparam>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="pen">The pen.</param>
|
|||
/// <param name="path">The path.</param>
|
|||
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|||
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, Drawable path) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
return source.Draw(pen, path, GraphicsOptions.Default); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Draws the outline of the polygon with the provided brush at the provided thickness.
|
|||
/// </summary>
|
|||
/// <typeparam name="TPixel">The type of the color.</typeparam>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="brush">The brush.</param>
|
|||
/// <param name="thickness">The thickness.</param>
|
|||
/// <param name="path">The path.</param>
|
|||
/// <param name="options">The options.</param>
|
|||
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|||
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, Drawable path, GraphicsOptions options) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
return source.Draw(new Pen<TPixel>(brush, thickness), path, options); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Draws the outline of the polygon with the provided brush at the provided thickness.
|
|||
/// </summary>
|
|||
/// <typeparam name="TPixel">The type of the color.</typeparam>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="brush">The brush.</param>
|
|||
/// <param name="thickness">The thickness.</param>
|
|||
/// <param name="path">The path.</param>
|
|||
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|||
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, Drawable path) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
return source.Draw(new Pen<TPixel>(brush, thickness), path); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Draws the outline of the polygon with the provided brush at the provided thickness.
|
|||
/// </summary>
|
|||
/// <typeparam name="TPixel">The type of the color.</typeparam>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="color">The color.</param>
|
|||
/// <param name="thickness">The thickness.</param>
|
|||
/// <param name="path">The path.</param>
|
|||
/// <param name="options">The options.</param>
|
|||
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|||
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, TPixel color, float thickness, Drawable path, GraphicsOptions options) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
return source.Draw(new SolidBrush<TPixel>(color), thickness, path, options); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Draws the outline of the polygon with the provided brush at the provided thickness.
|
|||
/// </summary>
|
|||
/// <typeparam name="TPixel">The type of the color.</typeparam>
|
|||
/// <param name="source">The image this method extends.</param>
|
|||
/// <param name="color">The color.</param>
|
|||
/// <param name="thickness">The thickness.</param>
|
|||
/// <param name="path">The path.</param>
|
|||
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
|
|||
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, TPixel color, float thickness, Drawable path) |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
return source.Draw(new SolidBrush<TPixel>(color), thickness, path); |
|||
} |
|||
} |
|||
} |
|||
@ -1,51 +0,0 @@ |
|||
// <copyright file="Drawable.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Drawing |
|||
{ |
|||
/// <summary>
|
|||
/// Represents a path or set of paths that can be drawn as an outline.
|
|||
/// </summary>
|
|||
public abstract class Drawable |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the maximum number of intersections to could be returned.
|
|||
/// </summary>
|
|||
public abstract int MaxIntersections { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the bounds.
|
|||
/// </summary>
|
|||
public abstract Rectangle Bounds { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the point information for the specified x and y location.
|
|||
/// </summary>
|
|||
/// <param name="x">The x.</param>
|
|||
/// <param name="y">The y.</param>
|
|||
/// <returns>Information about the point in relation to a drawable edge</returns>
|
|||
public abstract PointInfo GetPointInfo(int x, int y); |
|||
|
|||
/// <summary>
|
|||
/// Scans the X axis for intersections.
|
|||
/// </summary>
|
|||
/// <param name="x">The x.</param>
|
|||
/// <param name="buffer">The buffer.</param>
|
|||
/// <param name="length">The length.</param>
|
|||
/// <param name="offset">The offset.</param>
|
|||
/// <returns>The number of intersections found.</returns>
|
|||
public abstract int ScanX(int x, float[] buffer, int length, int offset); |
|||
|
|||
/// <summary>
|
|||
/// Scans the Y axis for intersections.
|
|||
/// </summary>
|
|||
/// <param name="y">The position along the y axis to find intersections.</param>
|
|||
/// <param name="buffer">The buffer.</param>
|
|||
/// <param name="length">The length.</param>
|
|||
/// <param name="offset">The offset.</param>
|
|||
/// <returns>The number of intersections found.</returns>
|
|||
public abstract int ScanY(int y, float[] buffer, int length, int offset); |
|||
} |
|||
} |
|||
@ -1,140 +0,0 @@ |
|||
// <copyright file="DrawPathProcessor.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Drawing.Processors |
|||
{ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
|
|||
using ImageSharp.Memory; |
|||
using ImageSharp.PixelFormats; |
|||
using ImageSharp.Processing; |
|||
using Pens; |
|||
|
|||
/// <summary>
|
|||
/// Draws a path using the processor pipeline
|
|||
/// </summary>
|
|||
/// <typeparam name="TPixel">The type of the color.</typeparam>
|
|||
/// <seealso cref="ImageSharp.Processing.ImageProcessor{TPixel}" />
|
|||
internal class DrawPathProcessor<TPixel> : ImageProcessor<TPixel> |
|||
where TPixel : struct, IPixel<TPixel> |
|||
{ |
|||
private const float AntialiasFactor = 1f; |
|||
private const int PaddingFactor = 1; // needs to been the same or greater than AntialiasFactor
|
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="DrawPathProcessor{TPixel}" /> class.
|
|||
/// </summary>
|
|||
/// <param name="pen">The details how to draw the outline/path.</param>
|
|||
/// <param name="drawable">The details of the paths and outlines to draw.</param>
|
|||
/// <param name="options">The drawing configuration options.</param>
|
|||
public DrawPathProcessor(IPen<TPixel> pen, Drawable drawable, GraphicsOptions options) |
|||
{ |
|||
this.Path = drawable; |
|||
this.Pen = pen; |
|||
this.Options = options; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the graphics options.
|
|||
/// </summary>
|
|||
public GraphicsOptions Options { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the pen.
|
|||
/// </summary>
|
|||
public IPen<TPixel> Pen { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the path.
|
|||
/// </summary>
|
|||
public Drawable Path { get; } |
|||
|
|||
/// <inheritdoc/>
|
|||
protected override void OnApply(ImageBase<TPixel> source, Rectangle sourceRectangle) |
|||
{ |
|||
using (PenApplicator<TPixel> applicator = this.Pen.CreateApplicator(source, this.Path.Bounds, this.Options)) |
|||
{ |
|||
var rect = Rectangle.Ceiling(applicator.RequiredRegion); |
|||
|
|||
int polyStartY = rect.Y - PaddingFactor; |
|||
int polyEndY = rect.Bottom + PaddingFactor; |
|||
int startX = rect.X - PaddingFactor; |
|||
int endX = rect.Right + PaddingFactor; |
|||
|
|||
int minX = Math.Max(sourceRectangle.Left, startX); |
|||
int maxX = Math.Min(sourceRectangle.Right, endX); |
|||
int minY = Math.Max(sourceRectangle.Top, polyStartY); |
|||
int maxY = Math.Min(sourceRectangle.Bottom, polyEndY); |
|||
|
|||
// Align start/end positions.
|
|||
minX = Math.Max(0, minX); |
|||
maxX = Math.Min(source.Width, maxX); |
|||
minY = Math.Max(0, minY); |
|||
maxY = Math.Min(source.Height, maxY); |
|||
|
|||
// Reset offset if necessary.
|
|||
if (minX > 0) |
|||
{ |
|||
startX = 0; |
|||
} |
|||
|
|||
if (minY > 0) |
|||
{ |
|||
polyStartY = 0; |
|||
} |
|||
|
|||
int width = maxX - minX; |
|||
PixelBlender<TPixel> blender = PixelOperations<TPixel>.Instance.GetPixelBlender(this.Options.BlenderMode); |
|||
|
|||
Parallel.For( |
|||
minY, |
|||
maxY, |
|||
this.ParallelOptions, |
|||
y => |
|||
{ |
|||
int offsetY = y - polyStartY; |
|||
|
|||
using (var amount = new Buffer<float>(width)) |
|||
using (var colors = new Buffer<TPixel>(width)) |
|||
{ |
|||
for (int i = 0; i < width; i++) |
|||
{ |
|||
int x = i + minX; |
|||
int offsetX = x - startX; |
|||
PointInfo info = this.Path.GetPointInfo(offsetX, offsetY); |
|||
ColoredPointInfo<TPixel> color = applicator.GetColor(offsetX, offsetY, info); |
|||
amount[i] = (this.Opacity(color.DistanceFromElement) * this.Options.BlendPercentage).Clamp(0, 1); |
|||
colors[i] = color.Color; |
|||
} |
|||
|
|||
Span<TPixel> destination = source.GetRowSpan(offsetY).Slice(minX - startX, width); |
|||
blender.Blend(destination, destination, colors, amount); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns the correct opacity for the given distance.
|
|||
/// </summary>
|
|||
/// <param name="distance">Thw distance from the central point.</param>
|
|||
/// <returns>The <see cref="float"/></returns>
|
|||
private float Opacity(float distance) |
|||
{ |
|||
if (distance <= 0) |
|||
{ |
|||
return 1; |
|||
} |
|||
|
|||
if (this.Options.Antialias && distance < AntialiasFactor) |
|||
{ |
|||
return 1 - (distance / AntialiasFactor); |
|||
} |
|||
|
|||
return 0; |
|||
} |
|||
} |
|||
} |
|||
@ -1,163 +0,0 @@ |
|||
|
|||
namespace ImageSharp.Tests.Drawing.Paths |
|||
{ |
|||
using System; |
|||
|
|||
using ImageSharp.Drawing.Brushes; |
|||
|
|||
using Xunit; |
|||
using ImageSharp.Drawing; |
|||
using System.Numerics; |
|||
using SixLabors.Shapes; |
|||
using ImageSharp.Drawing.Processors; |
|||
using ImageSharp.Drawing.Pens; |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
public class DrawBeziersTests : IDisposable |
|||
{ |
|||
float thickness = 7.2f; |
|||
GraphicsOptions noneDefault = new GraphicsOptions(); |
|||
Rgba32 color = Rgba32.HotPink; |
|||
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink); |
|||
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Firebrick, 99.9f); |
|||
Vector2[] points = new Vector2[] { |
|||
new Vector2(10,10), |
|||
new Vector2(20,10), |
|||
new Vector2(20,10), |
|||
new Vector2(30,10), |
|||
}; |
|||
private ProcessorWatchingImage img; |
|||
|
|||
public DrawBeziersTests() |
|||
{ |
|||
this.img = new Paths.ProcessorWatchingImage(10, 10); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
img.Dispose(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsBrushThicknessAndPoints() |
|||
{ |
|||
img.DrawBeziers(brush, thickness, points); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
Assert.NotNull(path.Path); |
|||
|
|||
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path); |
|||
|
|||
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(brush, pen.Brush); |
|||
Assert.Equal(thickness, pen.Width); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsBrushThicknessPointsAndOptions() |
|||
{ |
|||
img.DrawBeziers(brush, thickness, points, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path); |
|||
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(brush, pen.Brush); |
|||
Assert.Equal(thickness, pen.Width); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsColorThicknessAndPoints() |
|||
{ |
|||
img.DrawBeziers(color, thickness, points); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path); |
|||
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(thickness, pen.Width); |
|||
|
|||
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(pen.Brush); |
|||
Assert.Equal(color, brush.Color); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsColorThicknessPointsAndOptions() |
|||
{ |
|||
img.DrawBeziers(color, thickness, points, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path); |
|||
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(thickness, pen.Width); |
|||
|
|||
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(pen.Brush); |
|||
Assert.Equal(color, brush.Color); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsPenAndPoints() |
|||
{ |
|||
img.DrawBeziers(pen, points); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path); |
|||
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Assert.Equal(pen, processor.Pen); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsPenPointsAndOptions() |
|||
{ |
|||
img.DrawBeziers(pen, points, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path); |
|||
BezierLineSegment segment = Assert.IsType<BezierLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Assert.Equal(pen, processor.Pen); |
|||
} |
|||
} |
|||
} |
|||
@ -1,160 +0,0 @@ |
|||
|
|||
namespace ImageSharp.Tests.Drawing.Paths |
|||
{ |
|||
using System; |
|||
|
|||
using ImageSharp.Drawing.Brushes; |
|||
using Xunit; |
|||
using ImageSharp.Drawing; |
|||
using System.Numerics; |
|||
using SixLabors.Shapes; |
|||
using ImageSharp.Drawing.Processors; |
|||
using ImageSharp.Drawing.Pens; |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
public class DrawLinesTests : IDisposable |
|||
{ |
|||
float thickness = 7.2f; |
|||
GraphicsOptions noneDefault = new GraphicsOptions(); |
|||
Rgba32 color = Rgba32.HotPink; |
|||
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink); |
|||
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Gray, 99.9f); |
|||
Vector2[] points = new Vector2[] { |
|||
new Vector2(10,10), |
|||
new Vector2(20,10), |
|||
new Vector2(20,10), |
|||
new Vector2(30,10), |
|||
}; |
|||
private ProcessorWatchingImage img; |
|||
|
|||
public DrawLinesTests() |
|||
{ |
|||
this.img = new Paths.ProcessorWatchingImage(10, 10); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
img.Dispose(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsBrushThicknessAndPoints() |
|||
{ |
|||
img.DrawLines(brush, thickness, points); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path); |
|||
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(brush, pen.Brush); |
|||
Assert.Equal(thickness, pen.Width); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsBrushThicknessPointsAndOptions() |
|||
{ |
|||
img.DrawLines(brush, thickness, points, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path); |
|||
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(brush, pen.Brush); |
|||
Assert.Equal(thickness, pen.Width); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsColorThicknessAndPoints() |
|||
{ |
|||
img.DrawLines(color, thickness, points); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path); |
|||
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(thickness, pen.Width); |
|||
|
|||
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(pen.Brush); |
|||
Assert.Equal(color, brush.Color); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsColorThicknessPointsAndOptions() |
|||
{ |
|||
img.DrawLines(color, thickness, points, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path); |
|||
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(thickness, pen.Width); |
|||
|
|||
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(pen.Brush); |
|||
Assert.Equal(color, brush.Color); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsPenAndPoints() |
|||
{ |
|||
img.DrawLines(pen, points); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path); |
|||
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Assert.Equal(pen, processor.Pen); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsPenPointsAndOptions() |
|||
{ |
|||
img.DrawLines(pen, points, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Path vector = Assert.IsType<SixLabors.Shapes.Path>(path.Path); |
|||
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Assert.Equal(pen, processor.Pen); |
|||
} |
|||
} |
|||
} |
|||
@ -1,149 +0,0 @@ |
|||
|
|||
namespace ImageSharp.Tests.Drawing.Paths |
|||
{ |
|||
using System; |
|||
|
|||
using ImageSharp.Drawing.Brushes; |
|||
|
|||
using Xunit; |
|||
using ImageSharp.Drawing; |
|||
using System.Numerics; |
|||
using SixLabors.Shapes; |
|||
using ImageSharp.Drawing.Processors; |
|||
using ImageSharp.Drawing.Pens; |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
public class DrawPath : IDisposable |
|||
{ |
|||
float thickness = 7.2f; |
|||
GraphicsOptions noneDefault = new GraphicsOptions(); |
|||
Rgba32 color = Rgba32.HotPink; |
|||
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink); |
|||
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Gray, 99.9f); |
|||
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), |
|||
})); |
|||
private ProcessorWatchingImage img; |
|||
|
|||
public DrawPath() |
|||
{ |
|||
this.img = new Paths.ProcessorWatchingImage(10, 10); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
img.Dispose(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsBrushThicknessAndPath() |
|||
{ |
|||
img.Draw(brush, thickness, path); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); |
|||
Assert.Equal(path, shapepath.Path); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(brush, pen.Brush); |
|||
Assert.Equal(thickness, pen.Width); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsBrushThicknessPathAndOptions() |
|||
{ |
|||
img.Draw(brush, thickness, path, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); |
|||
Assert.Equal(path, shapepath.Path); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(brush, pen.Brush); |
|||
Assert.Equal(thickness, pen.Width); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsColorThicknessAndPath() |
|||
{ |
|||
img.Draw(color, thickness, path); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); |
|||
Assert.Equal(path, shapepath.Path); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(thickness, pen.Width); |
|||
|
|||
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(pen.Brush); |
|||
Assert.Equal(color, brush.Color); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsColorThicknessPathAndOptions() |
|||
{ |
|||
img.Draw(color, thickness, path, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); |
|||
Assert.Equal(path, shapepath.Path); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(thickness, pen.Width); |
|||
|
|||
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(pen.Brush); |
|||
Assert.Equal(color, brush.Color); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsPenAndPath() |
|||
{ |
|||
img.Draw(pen, path); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); |
|||
Assert.Equal(path, shapepath.Path); |
|||
|
|||
Assert.Equal(pen, processor.Pen); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsPenPathAndOptions() |
|||
{ |
|||
img.Draw(pen, path, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); |
|||
Assert.Equal(path, shapepath.Path); |
|||
|
|||
Assert.Equal(pen, processor.Pen); |
|||
} |
|||
} |
|||
} |
|||
@ -1,161 +0,0 @@ |
|||
|
|||
namespace ImageSharp.Tests.Drawing.Paths |
|||
{ |
|||
using System; |
|||
|
|||
using ImageSharp.Drawing.Brushes; |
|||
|
|||
using Xunit; |
|||
using ImageSharp.Drawing; |
|||
using System.Numerics; |
|||
using SixLabors.Shapes; |
|||
using ImageSharp.Drawing.Processors; |
|||
using ImageSharp.Drawing.Pens; |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
public class DrawPolygon : IDisposable |
|||
{ |
|||
float thickness = 7.2f; |
|||
GraphicsOptions noneDefault = new GraphicsOptions(); |
|||
Rgba32 color = Rgba32.HotPink; |
|||
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink); |
|||
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Gray, 99.9f); |
|||
Vector2[] points = new Vector2[] { |
|||
new Vector2(10,10), |
|||
new Vector2(20,10), |
|||
new Vector2(20,10), |
|||
new Vector2(30,10), |
|||
}; |
|||
private ProcessorWatchingImage img; |
|||
|
|||
public DrawPolygon() |
|||
{ |
|||
this.img = new Paths.ProcessorWatchingImage(10, 10); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
img.Dispose(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsBrushThicknessAndPoints() |
|||
{ |
|||
img.DrawPolygon(brush, thickness, points); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path); |
|||
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(brush, pen.Brush); |
|||
Assert.Equal(thickness, pen.Width); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsBrushThicknessPointsAndOptions() |
|||
{ |
|||
img.DrawPolygon(brush, thickness, points, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path); |
|||
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(brush, pen.Brush); |
|||
Assert.Equal(thickness, pen.Width); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsColorThicknessAndPoints() |
|||
{ |
|||
img.DrawPolygon(color, thickness, points); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path); |
|||
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(thickness, pen.Width); |
|||
|
|||
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(pen.Brush); |
|||
Assert.Equal(color, brush.Color); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsColorThicknessPointsAndOptions() |
|||
{ |
|||
img.DrawPolygon(color, thickness, points, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path); |
|||
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(thickness, pen.Width); |
|||
|
|||
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(pen.Brush); |
|||
Assert.Equal(color, brush.Color); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsPenAndPoints() |
|||
{ |
|||
img.DrawPolygon(pen, points); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path); |
|||
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Assert.Equal(pen, processor.Pen); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsPenPointsAndOptions() |
|||
{ |
|||
img.DrawPolygon(pen, points, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath path = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
Polygon vector = Assert.IsType<SixLabors.Shapes.Polygon>(path.Path); |
|||
LinearLineSegment segment = Assert.IsType<LinearLineSegment>(vector.LineSegments[0]); |
|||
|
|||
Assert.Equal(pen, processor.Pen); |
|||
} |
|||
} |
|||
} |
|||
@ -1,177 +0,0 @@ |
|||
|
|||
namespace ImageSharp.Tests.Drawing.Paths |
|||
{ |
|||
using System; |
|||
using ImageSharp; |
|||
using ImageSharp.Drawing.Brushes; |
|||
using Xunit; |
|||
using ImageSharp.Drawing; |
|||
using ImageSharp.Drawing.Processors; |
|||
using ImageSharp.Drawing.Pens; |
|||
using ImageSharp.PixelFormats; |
|||
|
|||
public class DrawRectangle : IDisposable |
|||
{ |
|||
float thickness = 7.2f; |
|||
GraphicsOptions noneDefault = new GraphicsOptions(); |
|||
Rgba32 color = Rgba32.HotPink; |
|||
SolidBrush<Rgba32> brush = Brushes.Solid(Rgba32.HotPink); |
|||
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Gray, 99.9f); |
|||
ImageSharp.Rectangle rectangle = new ImageSharp.Rectangle(10, 10, 98, 324); |
|||
|
|||
private ProcessorWatchingImage img; |
|||
|
|||
public DrawRectangle() |
|||
{ |
|||
this.img = new Paths.ProcessorWatchingImage(10, 10); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
img.Dispose(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsBrushThicknessAndRectangle() |
|||
{ |
|||
img.Draw(brush, thickness, rectangle); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); |
|||
SixLabors.Shapes.Rectangle rect = Assert.IsType<SixLabors.Shapes.Rectangle>(shapepath.Path); |
|||
|
|||
Assert.Equal(rect.Location.X, rectangle.X); |
|||
Assert.Equal(rect.Location.Y, rectangle.Y); |
|||
Assert.Equal(rect.Size.Width, rectangle.Width); |
|||
Assert.Equal(rect.Size.Height, rectangle.Height); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(brush, pen.Brush); |
|||
Assert.Equal(thickness, pen.Width); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsBrushThicknessRectangleAndOptions() |
|||
{ |
|||
img.Draw(brush, thickness, rectangle, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Rectangle rect = Assert.IsType<SixLabors.Shapes.Rectangle>(shapepath.Path); |
|||
|
|||
Assert.Equal(rect.Location.X, rectangle.X); |
|||
Assert.Equal(rect.Location.Y, rectangle.Y); |
|||
Assert.Equal(rect.Size.Width, rectangle.Width); |
|||
Assert.Equal(rect.Size.Height, rectangle.Height); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(brush, pen.Brush); |
|||
Assert.Equal(thickness, pen.Width); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsColorThicknessAndRectangle() |
|||
{ |
|||
img.Draw(color, thickness, rectangle); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Rectangle rect = Assert.IsType<SixLabors.Shapes.Rectangle>(shapepath.Path); |
|||
|
|||
Assert.Equal(rect.Location.X, rectangle.X); |
|||
Assert.Equal(rect.Location.Y, rectangle.Y); |
|||
Assert.Equal(rect.Size.Width, rectangle.Width); |
|||
Assert.Equal(rect.Size.Height, rectangle.Height); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(thickness, pen.Width); |
|||
|
|||
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(pen.Brush); |
|||
Assert.Equal(color, brush.Color); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsColorThicknessRectangleAndOptions() |
|||
{ |
|||
img.Draw(color, thickness, rectangle, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Rectangle rect = Assert.IsType<SixLabors.Shapes.Rectangle>(shapepath.Path); |
|||
|
|||
Assert.Equal(rect.Location.X, rectangle.X); |
|||
Assert.Equal(rect.Location.Y, rectangle.Y); |
|||
Assert.Equal(rect.Size.Width, rectangle.Width); |
|||
Assert.Equal(rect.Size.Height, rectangle.Height); |
|||
|
|||
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen); |
|||
Assert.Equal(thickness, pen.Width); |
|||
|
|||
SolidBrush<Rgba32> brush = Assert.IsType<SolidBrush<Rgba32>>(pen.Brush); |
|||
Assert.Equal(color, brush.Color); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsPenAndRectangle() |
|||
{ |
|||
img.Draw(pen, rectangle); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(GraphicsOptions.Default, processor.Options); |
|||
|
|||
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Rectangle rect = Assert.IsType<SixLabors.Shapes.Rectangle>(shapepath.Path); |
|||
|
|||
Assert.Equal(rect.Location.X, rectangle.X); |
|||
Assert.Equal(rect.Location.Y, rectangle.Y); |
|||
Assert.Equal(rect.Size.Width, rectangle.Width); |
|||
Assert.Equal(rect.Size.Height, rectangle.Height); |
|||
|
|||
Assert.Equal(pen, processor.Pen); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CorrectlySetsPenRectangleAndOptions() |
|||
{ |
|||
img.Draw(pen, rectangle, noneDefault); |
|||
|
|||
Assert.NotEmpty(img.ProcessorApplications); |
|||
DrawPathProcessor<Rgba32> processor = Assert.IsType<DrawPathProcessor<Rgba32>>(img.ProcessorApplications[0].processor); |
|||
|
|||
Assert.Equal(noneDefault, processor.Options); |
|||
|
|||
ShapePath shapepath = Assert.IsType<ShapePath>(processor.Path); |
|||
|
|||
SixLabors.Shapes.Rectangle rect = Assert.IsType<SixLabors.Shapes.Rectangle>(shapepath.Path); |
|||
|
|||
Assert.Equal(rect.Location.X, rectangle.X); |
|||
Assert.Equal(rect.Location.Y, rectangle.Y); |
|||
Assert.Equal(rect.Size.Width, rectangle.Width); |
|||
Assert.Equal(rect.Size.Height, rectangle.Height); |
|||
|
|||
Assert.Equal(pen, processor.Pen); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue