22// Licensed under the Apache License, Version 2.0.
33
44using System ;
5+ using System . Numerics ;
56using SixLabors . ImageSharp . Drawing . Processing ;
67using SixLabors . ImageSharp . PixelFormats ;
78using SixLabors . ImageSharp . Processing ;
@@ -13,18 +14,26 @@ namespace SixLabors.ImageSharp.Drawing.Tests.Drawing
1314 public class ClipTests
1415 {
1516 [ Theory ]
16- [ WithBasicTestPatternImages ( 250 , 350 , PixelTypes . Rgba32 ) ]
17- public void Clip < TPixel > ( TestImageProvider < TPixel > provider )
17+ [ WithBasicTestPatternImages ( 250 , 350 , PixelTypes . Rgba32 , 0 , 0 ) ]
18+ [ WithBasicTestPatternImages ( 250 , 350 , PixelTypes . Rgba32 , - 20 , - 20 ) ]
19+ [ WithBasicTestPatternImages ( 250 , 350 , PixelTypes . Rgba32 , 20 , 20 ) ]
20+ public void Clip < TPixel > ( TestImageProvider < TPixel > provider , float dx , float dy )
1821 where TPixel : unmanaged, IPixel < TPixel >
19- => provider . RunValidatingProcessorTest (
20- x =>
21- {
22- Size size = x . GetCurrentSize ( ) ;
23- int outerRadii = Math . Min ( size . Width , size . Height ) / 2 ;
24- var star = new Star ( new PointF ( size . Width / 2 , size . Height / 2 ) , 5 , outerRadii / 2 , outerRadii ) ;
25- x . Clip ( star , x => x . DetectEdges ( ) ) ;
26- } ,
27- appendPixelTypeToFileName : false ,
28- appendSourceFileOrDescription : false ) ;
22+ {
23+ FormattableString testDetails = $ "offset_x{ dx } _y{ dy } ";
24+ provider . RunValidatingProcessorTest (
25+ x =>
26+ {
27+ Size size = x . GetCurrentSize ( ) ;
28+ int outerRadii = Math . Min ( size . Width , size . Height ) / 2 ;
29+ var star = new Star ( new PointF ( size . Width / 2 , size . Height / 2 ) , 5 , outerRadii / 2 , outerRadii ) ;
30+
31+ var builder = Matrix3x2 . CreateTranslation ( new Vector2 ( dx , dy ) ) ;
32+ x . Clip ( star . Transform ( builder ) , x => x . DetectEdges ( ) ) ;
33+ } ,
34+ testOutputDetails : testDetails ,
35+ appendPixelTypeToFileName : false ,
36+ appendSourceFileOrDescription : false ) ;
37+ }
2938 }
3039}
0 commit comments