Skip to content

Commit b5b6008

Browse files
committed
Add tests for EndCapStyle and JointStyle properties
1 parent c6da73c commit b5b6008

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

tests/ImageSharp.Drawing.Tests/Drawing/DrawLinesTests.cs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,78 @@ public void DrawLines_DashDotDot<TPixel>(TestImageProvider<TPixel> provider, str
7070
DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen);
7171
}
7272

73+
[Theory]
74+
[WithBasicTestPatternImages(250, 350, PixelTypes.Rgba32, "Yellow", 1f, 5, true)]
75+
public void DrawLines_EndCapRound<TPixel>(TestImageProvider<TPixel> provider, string colorName, float alpha, float thickness, bool antialias)
76+
where TPixel : unmanaged, IPixel<TPixel>
77+
{
78+
Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha);
79+
var pen = new Pen(color, thickness);
80+
pen.EndCap = EndCapStyle.Round;
81+
82+
DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen);
83+
}
84+
85+
[Theory]
86+
[WithBasicTestPatternImages(250, 350, PixelTypes.Rgba32, "Yellow", 1f, 5, true)]
87+
public void DrawLines_EndCapButt<TPixel>(TestImageProvider<TPixel> provider, string colorName, float alpha, float thickness, bool antialias)
88+
where TPixel : unmanaged, IPixel<TPixel>
89+
{
90+
Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha);
91+
var pen = new Pen(color, thickness);
92+
pen.EndCap = EndCapStyle.Butt;
93+
94+
DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen);
95+
}
96+
97+
[Theory]
98+
[WithBasicTestPatternImages(250, 350, PixelTypes.Rgba32, "Yellow", 1f, 5, true)]
99+
public void DrawLines_EndCapSquare<TPixel>(TestImageProvider<TPixel> provider, string colorName, float alpha, float thickness, bool antialias)
100+
where TPixel : unmanaged, IPixel<TPixel>
101+
{
102+
Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha);
103+
var pen = new Pen(color, thickness);
104+
pen.EndCap = EndCapStyle.Square;
105+
106+
DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen);
107+
}
108+
109+
[Theory]
110+
[WithBasicTestPatternImages(250, 350, PixelTypes.Rgba32, "Yellow", 1f, 5, true)]
111+
public void DrawLines_JointStyleRound<TPixel>(TestImageProvider<TPixel> provider, string colorName, float alpha, float thickness, bool antialias)
112+
where TPixel : unmanaged, IPixel<TPixel>
113+
{
114+
Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha);
115+
var pen = new Pen(color, thickness);
116+
pen.JointStyle = JointStyle.Round;
117+
118+
DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen);
119+
}
120+
121+
[Theory]
122+
[WithBasicTestPatternImages(250, 350, PixelTypes.Rgba32, "Yellow", 1f, 5, true)]
123+
public void DrawLines_JointStyleSquare<TPixel>(TestImageProvider<TPixel> provider, string colorName, float alpha, float thickness, bool antialias)
124+
where TPixel : unmanaged, IPixel<TPixel>
125+
{
126+
Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha);
127+
var pen = new Pen(color, thickness);
128+
pen.JointStyle = JointStyle.Square;
129+
130+
DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen);
131+
}
132+
133+
[Theory]
134+
[WithBasicTestPatternImages(250, 350, PixelTypes.Rgba32, "Yellow", 1f, 5, true)]
135+
public void DrawLines_JointStyleMiter<TPixel>(TestImageProvider<TPixel> provider, string colorName, float alpha, float thickness, bool antialias)
136+
where TPixel : unmanaged, IPixel<TPixel>
137+
{
138+
Color color = TestUtils.GetColorByName(colorName).WithAlpha(alpha);
139+
var pen = new Pen(color, thickness);
140+
pen.JointStyle = JointStyle.Miter;
141+
142+
DrawLinesImpl(provider, colorName, alpha, thickness, antialias, pen);
143+
}
144+
73145
private static void DrawLinesImpl<TPixel>(
74146
TestImageProvider<TPixel> provider,
75147
string colorName,

0 commit comments

Comments
 (0)