2 using NUnit.Framework;
\r
3 using System.Drawing.Drawing2D;
\r
4 using System.Drawing;
\r
6 using DrawingTestHelper;
\r
8 namespace Test.Sys.Drawing
\r
11 public class GraphicsPathIteratorFixture
\r
14 public virtual void NextSubpath_Int_Int_Bool()
\r
16 GraphicsPath path = new GraphicsPath ();
\r
17 path.AddLine (new Point (100, 100), new Point (400, 100));
\r
18 path.AddLine (new Point (400, 200), new Point (10, 100));
\r
19 path.StartFigure ();
\r
21 path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
\r
22 path.CloseFigure ();
\r
23 path.StartFigure ();
\r
25 path.AddRectangle (new Rectangle (10, 20, 300, 400));
\r
26 path.StartFigure ();
\r
28 path.AddLine (new Point (400, 400), new Point (400, 10));
\r
30 GraphicsPathIterator iterator = new GraphicsPathIterator (path);
\r
36 int count = iterator.NextSubpath (out start, out end, out isClosed);
\r
37 Assert.AreEqual (4, count);
\r
38 Assert.AreEqual (0, start);
\r
39 Assert.AreEqual (3, end);
\r
40 Assert.IsFalse (isClosed);
\r
42 count = iterator.NextSubpath (out start, out end, out isClosed);
\r
43 Assert.AreEqual (4, count);
\r
44 Assert.AreEqual (4, start);
\r
45 Assert.AreEqual (7, end);
\r
46 Assert.IsTrue (isClosed);
\r
48 count = iterator.NextSubpath (out start, out end, out isClosed);
\r
49 Assert.AreEqual (4, count);
\r
50 Assert.AreEqual (8, start);
\r
51 Assert.AreEqual (11, end);
\r
52 Assert.IsTrue (isClosed);
\r
54 count = iterator.NextSubpath (out start, out end, out isClosed);
\r
55 Assert.AreEqual (2, count);
\r
56 Assert.AreEqual (12, start);
\r
57 Assert.AreEqual (13, end);
\r
58 Assert.IsFalse (isClosed);
\r
60 count = iterator.NextSubpath (out start, out end, out isClosed);
\r
61 Assert.AreEqual (0, count);
\r
62 Assert.AreEqual (0, start);
\r
63 Assert.AreEqual (0, end);
\r
64 Assert.IsTrue (isClosed);
\r
68 public virtual void NextSubpath_GraphicsPath_Bool()
\r
70 GraphicsPath path = new GraphicsPath ();
\r
71 path.AddLine (new Point (100, 100), new Point (400, 100));
\r
72 path.AddLine (new Point (400, 200), new Point (10, 100));
\r
73 path.StartFigure ();
\r
75 path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
\r
76 path.CloseFigure ();
\r
77 path.StartFigure ();
\r
79 path.AddRectangle (new Rectangle (10, 20, 300, 400));
\r
80 path.StartFigure ();
\r
82 path.AddLine (new Point (400, 400), new Point (400, 10));
\r
84 GraphicsPathIterator iterator = new GraphicsPathIterator (path);
\r
85 GraphicsPath path2 = new GraphicsPath ();
\r
89 int count = iterator.NextSubpath (path2, out isClosed);
\r
90 Assert.AreEqual (4, count);
\r
91 Assert.IsFalse (isClosed);
\r
93 PointF [] actualPoints = path2.PathPoints;
\r
94 byte [] actualTypes = path2.PathTypes;
\r
96 PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
\r
97 new PointF(400f, 100f),
\r
98 new PointF(400f, 200f),
\r
99 new PointF(10f, 100f)};
\r
101 for(int i = 0; i < expectedPoints.Length; i++) {
\r
102 DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
\r
105 byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
\r
106 (byte) PathPointType.Line,
\r
107 (byte) PathPointType.Line,
\r
108 (byte) (PathPointType.Line | PathPointType.PathMarker)};
\r
110 for (int i=0; i < expectedTypes.Length; i++) {
\r
111 Assert.AreEqual (expectedTypes [i], actualTypes [i]);
\r
114 count = iterator.NextSubpath (path2, out isClosed);
\r
115 Assert.AreEqual (4, count);
\r
116 Assert.IsTrue (isClosed);
\r
118 actualPoints = path2.PathPoints;
\r
119 actualTypes = path2.PathTypes;
\r
121 expectedPoints = new PointF [] {new PointF(10f, 10f),
\r
122 new PointF(50f, 250f),
\r
123 new PointF(100f, 5f),
\r
124 new PointF(200f, 280f)};
\r
126 for(int i = 0; i < expectedPoints.Length; i++) {
\r
127 DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
\r
130 expectedTypes = new byte [] { (byte) PathPointType.Start,
\r
131 (byte) PathPointType.Bezier3,
\r
132 (byte) PathPointType.Bezier3,
\r
133 (byte) (PathPointType.Bezier3 | PathPointType.CloseSubpath | PathPointType.PathMarker)};
\r
135 for (int i=0; i < expectedTypes.Length; i++) {
\r
136 Assert.AreEqual (expectedTypes [i], actualTypes [i]);
\r
139 count = iterator.NextSubpath (path2, out isClosed);
\r
140 Assert.AreEqual (4, count);
\r
141 Assert.IsTrue (isClosed);
\r
143 actualPoints = path2.PathPoints;
\r
144 actualTypes = path2.PathTypes;
\r
146 expectedPoints = new PointF [] {new PointF(10f, 20f),
\r
147 new PointF(310f, 20f),
\r
148 new PointF(310f, 420f),
\r
149 new PointF(10f, 420f)};
\r
151 for(int i = 0; i < expectedPoints.Length; i++) {
\r
152 DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
\r
155 expectedTypes = new byte [] { (byte) PathPointType.Start,
\r
156 (byte) PathPointType.Line,
\r
157 (byte) PathPointType.Line,
\r
158 (byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker)};
\r
160 for (int i=0; i < expectedTypes.Length; i++) {
\r
161 Assert.AreEqual (expectedTypes [i], actualTypes [i]);
\r
164 count = iterator.NextSubpath (path2, out isClosed);
\r
165 Assert.AreEqual (2, count);
\r
166 Assert.IsFalse (isClosed);
\r
168 actualPoints = path2.PathPoints;
\r
169 actualTypes = path2.PathTypes;
\r
171 expectedPoints = new PointF [] {new PointF(400f, 400f),
\r
172 new PointF(400f, 10f)};
\r
174 for(int i = 0; i < expectedPoints.Length; i++) {
\r
175 DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
\r
178 expectedTypes = new byte [] { (byte) PathPointType.Start,
\r
179 (byte) PathPointType.Line};
\r
181 for (int i=0; i < expectedTypes.Length; i++) {
\r
182 Assert.AreEqual (expectedTypes [i], actualTypes [i]);
\r
185 count = iterator.NextSubpath (path2, out isClosed);
\r
186 Assert.AreEqual (0, count);
\r
188 count = iterator.NextSubpath (path2, out isClosed);
\r
189 Assert.AreEqual (0, count);
\r
190 Assert.IsTrue (isClosed);
\r
191 Assert.AreEqual (2, path2.PointCount);
\r
193 actualPoints = path2.PathPoints;
\r
194 actualTypes = path2.PathTypes;
\r
196 expectedPoints = new PointF [] {new PointF(400f, 400f),
\r
197 new PointF(400f, 10f)};
\r
199 for(int i = 0; i < expectedPoints.Length; i++) {
\r
200 DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
\r
203 expectedTypes = new byte [] { (byte) PathPointType.Start,
\r
204 (byte) PathPointType.Line};
\r
206 for (int i=0; i < expectedTypes.Length; i++) {
\r
207 Assert.AreEqual (expectedTypes [i], actualTypes [i]);
\r
210 path = new GraphicsPath ();
\r
211 path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
\r
212 iterator = new GraphicsPathIterator (path);
\r
214 path2 = new GraphicsPath ();
\r
215 count = iterator.NextSubpath (path2, out isClosed);
\r
216 Assert.AreEqual (4, count);
\r
217 Assert.IsFalse (isClosed);
\r
219 path2 = new GraphicsPath ();
\r
220 count = iterator.NextSubpath (path2, out isClosed);
\r
221 Assert.AreEqual (0, count);
\r
222 Assert.IsTrue (isClosed);
\r
226 public virtual void NextPathType()
\r
228 GraphicsPath path = new GraphicsPath ();
\r
229 path.AddLine (new Point (100, 100), new Point (400, 100));
\r
230 path.AddBezier( 100, 100, 500, 250, 100, 50, 250, 280);
\r
231 path.AddLine (new Point (400, 200), new Point (10, 100));
\r
232 path.StartFigure ();
\r
233 path.SetMarkers ();
\r
234 path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
\r
235 path.StartFigure ();
\r
236 path.SetMarkers ();
\r
237 path.AddRectangle (new Rectangle (10, 20, 300, 400));
\r
238 path.StartFigure ();
\r
239 path.SetMarkers ();
\r
240 path.AddLine (new Point (400, 400), new Point (400, 10));
\r
242 GraphicsPathIterator iterator = new GraphicsPathIterator (path);
\r
249 int count = iterator.NextPathType (out pathType, out start, out end);
\r
250 Assert.AreEqual (0, count);
\r
251 Assert.AreEqual ((byte)PathPointType.Start, pathType);
\r
252 Assert.AreEqual (0, start);
\r
253 Assert.AreEqual (0, end);
\r
255 iterator.NextSubpath (out start, out end, out isClosed);
\r
256 count = iterator.NextPathType (out pathType, out start, out end);
\r
257 Assert.AreEqual (3, count);
\r
258 Assert.AreEqual ((byte)PathPointType.Line, pathType);
\r
259 Assert.AreEqual (0, start);
\r
260 Assert.AreEqual (2, end);
\r
262 count = iterator.NextPathType (out pathType, out start, out end);
\r
263 Assert.AreEqual (4, count);
\r
264 Assert.AreEqual ((byte)PathPointType.Bezier3, pathType);
\r
265 Assert.AreEqual (2, start);
\r
266 Assert.AreEqual (5, end);
\r
268 count = iterator.NextPathType (out pathType, out start, out end);
\r
269 Assert.AreEqual (3, count);
\r
270 Assert.AreEqual ((byte)PathPointType.Line, pathType);
\r
271 Assert.AreEqual (5, start);
\r
272 Assert.AreEqual (7, end);
\r
274 // we don't want to be a bug compliant with .net
\r
276 count = iterator.NextPathType (out pathType, out start, out end);
\r
277 Assert.AreEqual (0, count);
\r
278 Assert.AreEqual ((byte)PathPointType.Line, pathType);
\r
279 Assert.AreEqual (5, start);
\r
280 Assert.AreEqual (7, end);
\r
283 iterator.NextSubpath (out start, out end, out isClosed);
\r
284 count = iterator.NextPathType (out pathType, out start, out end);
\r
285 Assert.AreEqual (4, count);
\r
286 Assert.AreEqual ((byte)PathPointType.Bezier3, pathType);
\r
287 Assert.AreEqual (8, start);
\r
288 Assert.AreEqual (11, end);
\r
290 iterator.NextSubpath (out start, out end, out isClosed);
\r
291 count = iterator.NextPathType (out pathType, out start, out end);
\r
292 Assert.AreEqual (4, count);
\r
293 Assert.AreEqual ((byte)PathPointType.Line, pathType);
\r
294 Assert.AreEqual (12, start);
\r
295 Assert.AreEqual (15, end);
\r
297 iterator.NextSubpath (out start, out end, out isClosed);
\r
298 count = iterator.NextPathType (out pathType, out start, out end);
\r
299 Assert.AreEqual (2, count);
\r
300 Assert.AreEqual ((byte)PathPointType.Line, pathType);
\r
301 Assert.AreEqual (16, start);
\r
302 Assert.AreEqual (17, end);
\r
304 iterator.NextSubpath (out start, out end, out isClosed);
\r
305 count = iterator.NextPathType (out pathType, out start, out end);
\r
306 Assert.AreEqual (0, count);
\r
307 Assert.AreEqual ((byte)PathPointType.Line, pathType);
\r
308 Assert.AreEqual (0, start);
\r
309 Assert.AreEqual (0, end);
\r
313 public virtual void NextMarker_Int32_Int32()
\r
315 GraphicsPath path = new GraphicsPath ();
\r
316 path.AddLine (new Point (100, 100), new Point (400, 100));
\r
317 path.AddLine (new Point (400, 200), new Point (10, 100));
\r
318 path.StartFigure ();
\r
319 path.SetMarkers ();
\r
320 path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
\r
321 path.StartFigure ();
\r
322 path.SetMarkers ();
\r
323 path.AddRectangle (new Rectangle (10, 20, 300, 400));
\r
324 path.StartFigure ();
\r
325 path.SetMarkers ();
\r
326 path.AddLine (new Point (400, 400), new Point (400, 10));
\r
328 GraphicsPathIterator iterator = new GraphicsPathIterator (path);
\r
332 int count = iterator.NextMarker (out start, out end);
\r
333 Assert.AreEqual (4, count);
\r
334 Assert.AreEqual (0, start);
\r
335 Assert.AreEqual (3, end);
\r
337 count = iterator.NextMarker (out start, out end);
\r
338 Assert.AreEqual (4, count);
\r
339 Assert.AreEqual (4, start);
\r
340 Assert.AreEqual (7, end);
\r
342 count = iterator.NextMarker (out start, out end);
\r
343 Assert.AreEqual (4, count);
\r
344 Assert.AreEqual (8, start);
\r
345 Assert.AreEqual (11, end);
\r
347 count = iterator.NextMarker (out start, out end);
\r
348 Assert.AreEqual (2, count);
\r
349 Assert.AreEqual (12, start);
\r
350 Assert.AreEqual (13, end);
\r
352 // FIXME - should return all 0'z?
\r
354 count = iterator.NextMarker (out start, out end);
\r
355 Assert.AreEqual (0, count);
\r
356 Assert.AreEqual (12, start);
\r
357 Assert.AreEqual (13, end);
\r
362 public void NextSubpath_NextMarker()
\r
364 GraphicsPath path = new GraphicsPath();
\r
366 path.AddLine (10, 10, 50, 50); // figure #1
\r
367 path.AddLine (50, 50, 80, 80);
\r
368 path.AddLine (90, 90, 100, 100);
\r
369 path.SetMarkers (); // marker #1
\r
370 path.AddLine (150, 150, 180, 180);
\r
371 path.SetMarkers (); // marker #2
\r
372 path.StartFigure (); // figure #2
\r
373 path.SetMarkers (); // marker #3 is actually marker #2
\r
374 path.AddRectangle (new Rectangle (200, 200, 200, 200));
\r
375 path.SetMarkers (); // marker #4
\r
376 path.AddLine (150, 150, 180, 180);
\r
377 path.StartFigure (); // figure #3
\r
378 path.AddBezier (400, 400, 500, 500, 600, 600, 700, 700);
\r
379 path.AddBezier (450, 450, 550, 550, 650, 650, 750, 750);
\r
381 GraphicsPathIterator iterator = new GraphicsPathIterator (path);
\r
386 int count = iterator.NextMarker (out start,out end); // marker #1
\r
387 Assert.AreEqual (5, count);
\r
388 Assert.AreEqual (0, start);
\r
389 Assert.AreEqual (4, end);
\r
391 count = iterator.NextSubpath (out start,out end,out isClosed); // figure #1
\r
392 Assert.AreEqual (7, count);
\r
393 Assert.AreEqual (0, start);
\r
394 Assert.AreEqual (6, end);
\r
395 Assert.AreEqual (false, isClosed);
\r
397 count = iterator.NextMarker (out start,out end); // marker #2 (and #3)
\r
398 Assert.AreEqual (2, count);
\r
399 Assert.AreEqual (5, start);
\r
400 Assert.AreEqual (6, end);
\r
402 count = iterator.NextSubpath (out start,out end,out isClosed); // figure #2
\r
403 Assert.AreEqual (4, count);
\r
404 Assert.AreEqual (7, start);
\r
405 Assert.AreEqual (10, end);
\r
406 Assert.AreEqual (true, isClosed);
\r
408 count = iterator.NextSubpath (out start,out end,out isClosed); // figure #3
\r
409 Assert.AreEqual (2, count);
\r
410 Assert.AreEqual (11, start);
\r
411 Assert.AreEqual (12, end);
\r
412 Assert.AreEqual (false, isClosed);
\r
414 count = iterator.NextMarker (out start,out end); // marker #5 (end)
\r
415 Assert.AreEqual (4, count);
\r
416 Assert.AreEqual (7, start);
\r
417 Assert.AreEqual (10, end);
\r
419 count = iterator.NextMarker (out start,out end); // marker #5 (end)
\r
420 Assert.AreEqual (10, count);
\r
421 Assert.AreEqual (11, start);
\r
422 Assert.AreEqual (20, end);
\r
424 // we dont want to be bug compliant with .net
\r
426 count = iterator.NextMarker (out start,out end); // no more markers
\r
427 Assert.AreEqual (0, count);
\r
428 Assert.AreEqual (11, start);
\r
429 Assert.AreEqual (20, end);
\r
432 count = iterator.NextSubpath (out start,out end,out isClosed); // figure #4
\r
433 Assert.AreEqual (8, count);
\r
434 Assert.AreEqual (13, start);
\r
435 Assert.AreEqual (20, end);
\r
436 Assert.AreEqual (false, isClosed);
\r
438 // we dont want to be bug compliant with .net
\r
440 count = iterator.NextMarker (out start,out end); // no more markers
\r
441 Assert.AreEqual (0, count);
\r
442 Assert.AreEqual (13, start);
\r
443 Assert.AreEqual (20, end);
\r
446 count = iterator.NextSubpath (out start,out end,out isClosed); // no more figures
\r
447 Assert.AreEqual (0, count);
\r
448 Assert.AreEqual (0, start);
\r
449 Assert.AreEqual (0, end);
\r
450 Assert.AreEqual (true, isClosed);
\r
452 count = iterator.NextMarker (out start,out end); // no more markers
\r
453 Assert.AreEqual (0, count);
\r
454 Assert.AreEqual (0, start);
\r
455 Assert.AreEqual (0, end);
\r
460 public virtual void NextMarker_GraphicsPath()
\r
462 GraphicsPath path = new GraphicsPath ();
\r
463 path.AddLine (new Point (100, 100), new Point (400, 100));
\r
464 path.AddLine (new Point (400, 200), new Point (10, 100));
\r
465 path.StartFigure ();
\r
466 path.SetMarkers ();
\r
467 path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
\r
468 path.StartFigure ();
\r
469 path.SetMarkers ();
\r
470 path.AddRectangle (new Rectangle (10, 20, 300, 400));
\r
471 path.StartFigure ();
\r
472 path.SetMarkers ();
\r
473 path.AddLine (new Point (400, 400), new Point (400, 10));
\r
475 GraphicsPath path2 = new GraphicsPath ();
\r
476 path.AddLine (new Point (150, 150), new Point (450, 150));
\r
477 path.AddLine (new Point (450, 250), new Point (50, 150));
\r
479 GraphicsPathIterator iterator = new GraphicsPathIterator (path);
\r
481 iterator.NextMarker (null);
\r
482 iterator.NextMarker (path2);
\r
484 Assert.AreEqual (4, path2.PointCount);
\r
485 PointF [] actualPoints = path2.PathPoints;
\r
486 byte [] actualTypes = path2.PathTypes;
\r
488 PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
\r
489 new PointF(400f, 100f),
\r
490 new PointF(400f, 200f),
\r
491 new PointF(10f, 100f)};
\r
493 for(int i = 0; i < expectedPoints.Length; i++) {
\r
494 DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
\r
497 byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
\r
498 (byte) PathPointType.Line,
\r
499 (byte) PathPointType.Line,
\r
500 (byte) (PathPointType.Line | PathPointType.PathMarker)};
\r
502 for (int i=0; i < expectedTypes.Length; i++) {
\r
503 Assert.AreEqual (expectedTypes [i], actualTypes [i]);
\r
506 iterator.NextMarker (null);
\r
507 iterator.NextMarker (null);
\r
508 iterator.NextMarker (null);
\r
509 iterator.NextMarker (path2);
\r
511 Assert.AreEqual (4, path2.PointCount);
\r
512 actualPoints = path2.PathPoints;
\r
513 actualTypes = path2.PathTypes;
\r
515 expectedPoints = new PointF [] {new PointF(10f, 10f),
\r
516 new PointF(50f, 250f),
\r
517 new PointF(100f, 5f),
\r
518 new PointF(200f, 280f)};
\r
520 for(int i = 0; i < expectedPoints.Length; i++) {
\r
521 DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
\r
524 expectedTypes = new byte [] { (byte) PathPointType.Start,
\r
525 (byte) PathPointType.Bezier3,
\r
526 (byte) PathPointType.Bezier3,
\r
527 (byte) (PathPointType.Bezier3 | PathPointType.PathMarker)};
\r
529 for (int i=0; i < expectedTypes.Length; i++) {
\r
530 Assert.AreEqual (expectedTypes [i], actualTypes [i]);
\r
536 public virtual void Count()
\r
538 GraphicsPath path = new GraphicsPath ();
\r
540 GraphicsPathIterator iterator = new GraphicsPathIterator (path);
\r
541 Assert.AreEqual (0, iterator.Count);
\r
543 path.AddLine (new Point (100, 100), new Point (400, 100));
\r
544 path.AddLine (new Point (400, 200), new Point (10, 100));
\r
546 path.StartFigure ();
\r
547 path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
\r
548 path.StartFigure ();
\r
549 path.AddRectangle (new Rectangle (10, 20, 300, 400));
\r
551 path.StartFigure ();
\r
552 path.AddLine (new Point (400, 400), new Point (400, 10));
\r
554 iterator = new GraphicsPathIterator (path);
\r
555 Assert.AreEqual (14, iterator.Count);
\r
559 public virtual void SubpathCount()
\r
561 GraphicsPath path = new GraphicsPath ();
\r
563 GraphicsPathIterator iterator = new GraphicsPathIterator (path);
\r
564 Assert.AreEqual (0, iterator.SubpathCount);
\r
566 path.AddLine (new Point (100, 100), new Point (400, 100));
\r
567 path.AddLine (new Point (400, 200), new Point (10, 100));
\r
569 path.StartFigure ();
\r
570 path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
\r
571 path.StartFigure ();
\r
572 path.AddRectangle (new Rectangle (10, 20, 300, 400));
\r
574 path.StartFigure ();
\r
575 path.AddLine (new Point (400, 400), new Point (400, 10));
\r
577 iterator = new GraphicsPathIterator (path);
\r
578 Assert.AreEqual (4, iterator.SubpathCount);
\r
582 public virtual void HasCurve()
\r
584 GraphicsPath path = new GraphicsPath ();
\r
586 GraphicsPathIterator iterator = new GraphicsPathIterator (path);
\r
587 Assert.IsFalse (iterator.HasCurve ());
\r
589 path.AddLine (new Point (100, 100), new Point (400, 100));
\r
590 path.AddLine (new Point (400, 200), new Point (10, 100));
\r
592 iterator = new GraphicsPathIterator (path);
\r
593 Assert.IsFalse (iterator.HasCurve ());
\r
595 path.StartFigure ();
\r
596 path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
\r
597 path.StartFigure ();
\r
598 path.AddRectangle (new Rectangle (10, 20, 300, 400));
\r
600 path.StartFigure ();
\r
601 path.AddLine (new Point (400, 400), new Point (400, 10));
\r
603 iterator = new GraphicsPathIterator (path);
\r
604 Assert.IsTrue (iterator.HasCurve ());
\r
608 public virtual void Rewind()
\r
610 GraphicsPath path = new GraphicsPath ();
\r
611 path.AddLine (new Point (100, 100), new Point (400, 100));
\r
612 path.AddLine (new Point (400, 200), new Point (10, 100));
\r
613 path.StartFigure ();
\r
614 path.SetMarkers ();
\r
615 path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
\r
616 path.StartFigure ();
\r
617 path.SetMarkers ();
\r
618 path.AddRectangle (new Rectangle (10, 20, 300, 400));
\r
619 path.StartFigure ();
\r
620 path.SetMarkers ();
\r
621 path.AddLine (new Point (400, 400), new Point (400, 10));
\r
623 GraphicsPathIterator iterator = new GraphicsPathIterator (path);
\r
627 iterator.NextMarker (out i, out j);
\r
628 iterator.NextMarker (out i, out j);
\r
630 iterator.Rewind ();
\r
631 iterator.NextMarker (out i, out j);
\r
633 Assert.AreEqual (0, i);
\r
634 Assert.AreEqual (3, j);
\r
638 public virtual void Enumerate()
\r
640 GraphicsPath path = new GraphicsPath ();
\r
641 path.AddLine (new Point (100, 100), new Point (400, 100));
\r
642 path.AddLine (new Point (400, 200), new Point (10, 100));
\r
644 path.StartFigure ();
\r
645 path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
\r
646 path.StartFigure ();
\r
647 path.AddRectangle (new Rectangle (10, 20, 300, 400));
\r
649 path.StartFigure ();
\r
650 path.AddLine (new Point (400, 400), new Point (400, 10));
\r
654 GraphicsPathIterator iterator = new GraphicsPathIterator (path);
\r
655 PointF [] actualPoints = new PointF [14];
\r
656 byte [] actualTypes = new byte [14];
\r
657 iterator.Enumerate (ref actualPoints, ref actualTypes);
\r
659 PointF [] expectedPoints = new PointF [] { new PointF(400f, 10f),
\r
660 new PointF(400f, 400f),
\r
661 new PointF(10f, 420f),
\r
662 new PointF(310f, 420f),
\r
663 new PointF(310f, 20f),
\r
664 new PointF(10f, 20f),
\r
665 new PointF(200f, 280f),
\r
666 new PointF(100f, 5f),
\r
667 new PointF(50f, 250f),
\r
668 new PointF(10f, 10f),
\r
669 new PointF(10f, 100f),
\r
670 new PointF(400f, 200f),
\r
671 new PointF(400f, 100f),
\r
672 new PointF(100f, 100f)};
\r
674 for(int i = 0; i < expectedPoints.Length; i++) {
\r
675 DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
\r
678 byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
\r
679 (byte) PathPointType.Line,
\r
680 (byte) PathPointType.Start,
\r
681 (byte) PathPointType.Line,
\r
682 (byte) PathPointType.Line,
\r
683 (byte) (PathPointType.Line | PathPointType.CloseSubpath),
\r
684 (byte) PathPointType.Start,
\r
685 (byte) PathPointType.Bezier3,
\r
686 (byte) PathPointType.Bezier3,
\r
687 (byte) PathPointType.Bezier3,
\r
688 (byte) PathPointType.Start,
\r
689 (byte) PathPointType.Line,
\r
690 (byte) PathPointType.Line,
\r
691 (byte) PathPointType.Line};
\r
693 for (int i=0; i < expectedTypes.Length; i++) {
\r
694 Assert.AreEqual (expectedTypes [i], actualTypes [i]);
\r
699 public virtual void CopyData()
\r
701 GraphicsPath path = new GraphicsPath ();
\r
702 path.AddLine (new Point (100, 100), new Point (400, 100));
\r
703 path.AddLine (new Point (400, 200), new Point (10, 100));
\r
704 path.StartFigure ();
\r
705 path.SetMarkers ();
\r
706 path.AddRectangle (new Rectangle (10, 20, 300, 400));
\r
707 path.StartFigure ();
\r
708 path.SetMarkers ();
\r
709 path.AddLine (new Point (400, 400), new Point (400, 10));
\r
711 GraphicsPathIterator pathIterator = new GraphicsPathIterator(path);
\r
712 pathIterator.Rewind ();
\r
713 PointF [] actualPoints = new PointF [10];
\r
714 byte [] actualTypes = new byte [10];
\r
715 pathIterator.CopyData (ref actualPoints, ref actualTypes, 0, 9);
\r
717 PointF [] expectedPoints = new PointF [] { new PointF(100f, 100f),
\r
718 new PointF(400f, 100f),
\r
719 new PointF(400f, 200f),
\r
720 new PointF(10f, 100f),
\r
721 new PointF(10f, 20f),
\r
722 new PointF(310f, 20f),
\r
723 new PointF(310f, 420f),
\r
724 new PointF(10f, 420f),
\r
725 new PointF(400f, 400f),
\r
726 new PointF(400f, 10f)};
\r
728 for(int i = 0; i < expectedPoints.Length; i++) {
\r
729 DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
\r
732 byte [] expectedTypes = new byte [] { (byte) PathPointType.Start,
\r
733 (byte) PathPointType.Line,
\r
734 (byte) PathPointType.Line,
\r
735 (byte) (PathPointType.Line | PathPointType.PathMarker),
\r
736 (byte) PathPointType.Start,
\r
737 (byte) PathPointType.Line,
\r
738 (byte) PathPointType.Line,
\r
739 (byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker),
\r
740 (byte) PathPointType.Start,
\r
741 (byte) PathPointType.Line};
\r
743 for (int i=0; i < expectedTypes.Length; i++) {
\r
744 Assert.AreEqual (expectedTypes [i], actualTypes [i]);
\r