csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
4.2 KiB
135 lines
4.2 KiB
using System.Threading.Tasks;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls.Shapes;
|
|
using Avalonia.Media;
|
|
using Xunit;
|
|
|
|
namespace Avalonia.Skia.RenderTests
|
|
{
|
|
public class PolylineTests : TestBase
|
|
{
|
|
public PolylineTests()
|
|
: base(@"Shapes\Polyline")
|
|
{
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(FillRule.EvenOdd)]
|
|
[InlineData(FillRule.NonZero)]
|
|
public async Task Polyline_FillRule(FillRule fillRule)
|
|
{
|
|
var target = new Decorator
|
|
{
|
|
Padding = new Thickness(8),
|
|
Width = 260,
|
|
Height = 180,
|
|
Child = new Polyline
|
|
{
|
|
Stroke = Brushes.Black,
|
|
StrokeThickness = 2,
|
|
Fill = Brushes.OrangeRed,
|
|
Points = new Points
|
|
{
|
|
new Point(10, 170),
|
|
new Point(60, 20),
|
|
new Point(110, 170),
|
|
new Point(20, 70),
|
|
new Point(240, 70),
|
|
new Point(130, 170),
|
|
new Point(190, 20),
|
|
new Point(10, 170),
|
|
},
|
|
Stretch = Stretch.Uniform,
|
|
FillRule = fillRule
|
|
}
|
|
};
|
|
|
|
var testName = $"{nameof(Polyline_FillRule)}_{fillRule}";
|
|
await RenderToFile(target, testName);
|
|
CompareImages(testName);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Polyline_FillRule_NoFill()
|
|
{
|
|
var target = new Decorator
|
|
{
|
|
Padding = new Thickness(8),
|
|
Width = 260,
|
|
Height = 180,
|
|
Child = new Polyline
|
|
{
|
|
Stroke = Brushes.Black,
|
|
StrokeThickness = 2,
|
|
Fill = null,
|
|
Points = new Points
|
|
{
|
|
new Point(10, 170),
|
|
new Point(60, 20),
|
|
new Point(110, 170),
|
|
new Point(20, 70),
|
|
new Point(240, 70),
|
|
new Point(130, 170),
|
|
new Point(190, 20),
|
|
new Point(10, 170),
|
|
},
|
|
Stretch = Stretch.Uniform,
|
|
FillRule = FillRule.EvenOdd
|
|
}
|
|
};
|
|
|
|
await RenderToFile(target);
|
|
CompareImages();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Polyline_1px_Stroke()
|
|
{
|
|
var polylinePoints = new Points { new Point(0, 0), new Point(5, 0), new Point(6, -2), new Point(7, 3), new Point(8, -3),
|
|
new Point(9, 1), new Point(10, 0), new Point(15, 0) };
|
|
|
|
Decorator target = new Decorator
|
|
{
|
|
Padding = new Thickness(8),
|
|
Width = 400,
|
|
Height = 200,
|
|
Child = new Polyline
|
|
{
|
|
Stroke = Brushes.Brown,
|
|
Points = polylinePoints,
|
|
Stretch = Stretch.Uniform,
|
|
StrokeThickness = 1
|
|
}
|
|
};
|
|
|
|
await RenderToFile(target);
|
|
CompareImages();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Polyline_10px_Stroke_PenLineJoin()
|
|
{
|
|
var polylinePoints = new Points { new Point(0, 0), new Point(5, 0), new Point(6, -2), new Point(7, 3), new Point(8, -3),
|
|
new Point(9, 1), new Point(10, 0), new Point(15, 0) };
|
|
|
|
Decorator target = new Decorator
|
|
{
|
|
Padding = new Thickness(8),
|
|
Width = 400,
|
|
Height = 200,
|
|
Child = new Polyline
|
|
{
|
|
Stroke = Brushes.Brown,
|
|
Points = polylinePoints,
|
|
Stretch = Stretch.Uniform,
|
|
StrokeJoin = PenLineJoin.Round,
|
|
StrokeLineCap = PenLineCap.Round,
|
|
StrokeThickness = 10
|
|
}
|
|
};
|
|
|
|
await RenderToFile(target);
|
|
CompareImages();
|
|
}
|
|
}
|
|
}
|
|
|