22// Licensed under the Apache License, Version 2.0.
33
44using System ;
5- using System . Linq ;
65using Xunit ;
76
87namespace SixLabors . ImageSharp . Drawing . Tests
@@ -85,26 +84,6 @@ private static InternalPath Create(PointF location, SizeF size, bool closed = tr
8584 } ,
8685 } ;
8786
88- [ Theory ]
89- [ MemberData ( nameof ( PointInPolygonTheoryData ) ) ]
90- public void PointInPolygon ( TestPoint location , TestSize size , TestPoint point , bool isInside )
91- {
92- InternalPath shape = Create ( location , size ) ;
93- Assert . Equal ( isInside , shape . PointInPolygon ( point ) ) ;
94- }
95-
96- [ Fact ]
97- public void PointInPolygon_OpenPath ( )
98- {
99- var seg1 = new LinearLineSegment ( new PointF ( 0 , 0 ) , new PointF ( 0 , 10 ) , new PointF ( 10 , 10 ) , new PointF ( 10 , 0 ) ) ;
100-
101- var p = new InternalPath ( seg1 , false ) ;
102- Assert . False ( p . PointInPolygon ( new PointF ( 5 , 5 ) ) ) ;
103-
104- var p2 = new InternalPath ( seg1 , true ) ;
105- Assert . True ( p2 . PointInPolygon ( new PointF ( 5 , 5f ) ) ) ;
106- }
107-
10887 private const float HalfPi = ( float ) ( Math . PI / 2 ) ;
10988 private const float Pi = ( float ) Math . PI ;
11089
@@ -123,114 +102,5 @@ public void PointOnPath(float distance, float expectedX, float expectedY, float
123102 Assert . Equal ( expectedY , point . Point . Y , 4 ) ;
124103 Assert . Equal ( expectedAngle , point . Angle , 4 ) ;
125104 }
126-
127- [ Fact ]
128- public void Intersections_buffer ( )
129- {
130- InternalPath shape = Create ( new PointF ( 0 , 0 ) , new Size ( 10 , 10 ) ) ;
131- var intersections = new PointF [ shape . PointCount ] ;
132- var orientations = new PointOrientation [ shape . PointCount ] ;
133- int hits = shape . FindIntersections ( new PointF ( 5 , - 10 ) , new PointF ( 5 , 20 ) , intersections , orientations ) ;
134-
135- Assert . Equal ( 2 , hits ) ;
136- Assert . Equal ( new PointF ( 5 , 0 ) , intersections [ 0 ] ) ;
137- Assert . Equal ( new PointF ( 5 , 10 ) , intersections [ 1 ] ) ;
138- }
139-
140- [ Fact ]
141- public void Intersections_enumerabe ( )
142- {
143- InternalPath shape = Create ( new PointF ( 0 , 0 ) , new Size ( 10 , 10 ) ) ;
144- PointF [ ] buffer = shape . FindIntersections ( new PointF ( 5 , - 10 ) , new PointF ( 5 , 20 ) ) . ToArray ( ) ;
145-
146- Assert . Equal ( 2 , buffer . Length ) ;
147- Assert . Equal ( new PointF ( 5 , 0 ) , buffer [ 0 ] ) ;
148- Assert . Equal ( new PointF ( 5 , 10 ) , buffer [ 1 ] ) ;
149- }
150-
151- [ Fact ]
152- public void Intersections_enumerabe_openpath ( )
153- {
154- InternalPath shape = Create ( new PointF ( 0 , 0 ) , new Size ( 10 , 10 ) , false ) ;
155- PointF [ ] buffer = shape . FindIntersections ( new PointF ( 5 , - 10 ) , new PointF ( 5 , 20 ) ) . ToArray ( ) ;
156-
157- Assert . Equal ( 2 , buffer . Length ) ;
158- Assert . Equal ( new PointF ( 5 , 0 ) , buffer [ 0 ] ) ;
159- Assert . Equal ( new PointF ( 5 , 10 ) , buffer [ 1 ] ) ;
160- }
161-
162- [ Fact ]
163- public void Intersections_Diagonal ( )
164- {
165- var shape = new InternalPath ( new LinearLineSegment ( new PointF ( 0 , 0 ) , new PointF ( 10 , 10 ) ) , false ) ;
166-
167- PointF [ ] buffer = shape . FindIntersections ( new PointF ( 0 , 10 ) , new PointF ( 10 , 0 ) ) . ToArray ( ) ;
168-
169- Assert . Single ( buffer ) ;
170- Assert . Equal ( new PointF ( 5 , 5 ) , buffer [ 0 ] ) ;
171- }
172-
173- [ Fact ]
174- public void Intersections_Diagonal_NoHit ( )
175- {
176- var shape = new InternalPath ( new LinearLineSegment ( new PointF ( 0 , 0 ) , new PointF ( 4 , 4 ) ) , false ) ;
177-
178- PointF [ ] buffer = shape . FindIntersections ( new PointF ( 0 , 10 ) , new PointF ( 10 , 0 ) ) . ToArray ( ) ;
179-
180- Assert . Empty ( buffer ) ;
181- }
182-
183- [ Fact ]
184- public void Intersections_Diagonal_and_straight_NoHit ( )
185- {
186- var shape = new InternalPath ( new LinearLineSegment ( new PointF ( 0 , 0 ) , new PointF ( 4 , 4 ) ) , false ) ;
187-
188- PointF [ ] buffer = shape . FindIntersections ( new PointF ( 3 , 10 ) , new PointF ( 3 , 3.5f ) ) . ToArray ( ) ;
189-
190- Assert . Empty ( buffer ) ;
191- }
192-
193- [ Fact ]
194- public void Intersections_IntersectionRule_OddEven ( )
195- {
196- var shape = new InternalPath (
197- new LinearLineSegment (
198- new PointF ( 1 , 3 ) ,
199- new PointF ( 1 , 2 ) ,
200- new PointF ( 5 , 2 ) ,
201- new PointF ( 5 , 5 ) ,
202- new PointF ( 2 , 5 ) ,
203- new PointF ( 2 , 1 ) ,
204- new PointF ( 3 , 1 ) ,
205- new PointF ( 3 , 4 ) ,
206- new PointF ( 4 , 4 ) ,
207- new PointF ( 3 , 4 ) ) , true ) ;
208-
209- PointF [ ] buffer = shape . FindIntersections ( new PointF ( 0 , 2.5f ) , new PointF ( 6 , 2.5f ) , IntersectionRule . OddEven ) . ToArray ( ) ;
210-
211- Assert . Equal ( 4 , buffer . Length ) ;
212- }
213-
214- [ Fact ]
215- public void Intersections_IntersectionRule_Nonezero ( )
216- {
217- var shape = new InternalPath (
218- new LinearLineSegment (
219- new PointF ( 1 , 3 ) ,
220- new PointF ( 1 , 2 ) ,
221- new PointF ( 5 , 2 ) ,
222- new PointF ( 5 , 5 ) ,
223- new PointF ( 2 , 5 ) ,
224- new PointF ( 2 , 1 ) ,
225- new PointF ( 3 , 1 ) ,
226- new PointF ( 3 , 4 ) ,
227- new PointF ( 4 , 4 ) ,
228- new PointF ( 3 , 4 ) ) ,
229- true ) ;
230-
231- PointF [ ] buffer = shape . FindIntersections ( new PointF ( 0 , 2.5f ) , new PointF ( 6 , 2.5f ) , IntersectionRule . Nonzero ) . ToArray ( ) ;
232-
233- Assert . Equal ( 2 , buffer . Length ) ;
234- }
235105 }
236106}
0 commit comments