2 // System.Drawing.Region non-rectangular unit tests
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // Copyright (C) 2006 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Drawing.Imaging;
32 using System.Drawing.Drawing2D;
33 using System.Security.Permissions;
34 using NUnit.Framework;
36 namespace MonoTests.System.Drawing {
38 /* NOTE: General tests and rectangular region tests are located in TestRegion.cs */
39 /* Here we exclusively tests non-rectangular (GraphicsPath based) regions. */
42 [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
43 public class RegionNonRectTest {
45 private Bitmap bitmap;
46 private Graphics graphic;
47 private Matrix matrix;
48 private GraphicsPath sp1, sp2, sp3, sp4;
51 public void FixtureSetUp ()
53 bitmap = new Bitmap (10, 10);
54 graphic = Graphics.FromImage (bitmap);
55 matrix = new Matrix ();
57 sp1 = new GraphicsPath ();
58 sp1.AddPolygon (new Point[4] { new Point (0, 0), new Point (3, 0), new Point (3, 3), new Point (0, 3) });
60 sp2 = new GraphicsPath ();
61 sp2.AddPolygon (new Point[4] { new Point (2, 2), new Point (5, 2), new Point (5, 5), new Point (2, 5) });
63 sp3 = new GraphicsPath ();
64 sp3.AddPolygon (new Point[4] { new Point (6, 0), new Point (9, 0), new Point (9, 3), new Point (6, 3) });
66 sp4 = new GraphicsPath ();
67 sp4.AddPolygon (new Point[4] { new Point (8, 0), new Point (11, 0), new Point (11, 3), new Point (8, 3) });
70 // a region with an "empty ctor" graphic path is "empty" (i.e. not infinite)
71 private void CheckEmpty (string prefix, Region region)
73 Assert.IsTrue (region.IsEmpty (graphic), prefix + "IsEmpty");
74 Assert.IsFalse (region.IsInfinite (graphic), prefix + "graphic");
76 RectangleF rect = region.GetBounds (graphic);
77 Assert.AreEqual (0f, rect.X, prefix + "GetBounds.X");
78 Assert.AreEqual (0f, rect.Y, prefix + "GetBounds.Y");
79 Assert.AreEqual (0f, rect.Width, prefix + "GetBounds.Width");
80 Assert.AreEqual (0f, rect.Height, prefix + "GetBounds.Height");
84 public void Region_Ctor_GraphicsPath_Empty ()
86 Region region = new Region (new GraphicsPath ());
87 CheckEmpty ("GraphicsPath.", region);
89 Region clone = region.Clone ();
90 CheckEmpty ("Clone.", region);
94 [Ignore ("this does not work when using MS GDI+ - with or without Mono")]
95 public void Region_Ctor_RegionData ()
97 Region region = new Region (new GraphicsPath ());
98 RegionData data = region.GetRegionData ();
99 Region r2 = new Region (data);
100 CheckEmpty ("RegionData.", region);
104 public void Region_Ctor_GraphicsPath ()
106 GraphicsPath gp = new GraphicsPath ();
107 Region region = new Region (gp);
108 CheckEmpty ("GraphicsPath.", region);
110 Region clone = region.Clone ();
111 CheckEmpty ("Clone.", region);
114 private void CheckInfiniteBounds (GraphicsPath path)
116 RectangleF rect = path.GetBounds ();
117 Assert.AreEqual (-4194304f, rect.X, "Bounds.X");
118 Assert.AreEqual (-4194304f, rect.Y, "Bounds.Y");
119 Assert.AreEqual (8388608f, rect.Width, "Bounds.Width");
120 Assert.AreEqual (8388608f, rect.Height, "Bounds.Height");
124 public void Region_Curve_IsInfinite ()
126 Point[] points = new Point[2] { new Point (-4194304, -4194304), new Point (4194304, 4194304) };
127 GraphicsPath gp = new GraphicsPath ();
128 gp.AddCurve (points);
129 CheckInfiniteBounds (gp);
131 Region region = new Region (gp);
132 Assert.IsFalse (region.IsInfinite (graphic), "IsInfinite");
133 // note: infinity isn't based on the bounds
137 [Category ("NotWorking")]
138 public void Region_Polygon4_IsInfinite ()
140 Point[] points = new Point[4] { new Point (-4194304, -4194304), new Point (-4194304, 4194304), new Point (4194304, 4194304), new Point (4194304, -4194304) };
141 GraphicsPath gp = new GraphicsPath ();
142 gp.AddPolygon (points);
143 CheckInfiniteBounds (gp);
145 Region region = new Region (gp);
146 Assert.IsTrue (region.IsInfinite (graphic), "IsInfinite");
150 [Category ("NotWorking")]
151 public void Region_Polygon5_IsInfinite ()
153 // overlap the first/last point
154 Point[] points = new Point[5] { new Point (-4194304, -4194304), new Point (-4194304, 4194304), new Point (4194304, 4194304), new Point (4194304, -4194304), new Point (-4194304, -4194304) };
155 GraphicsPath gp = new GraphicsPath ();
156 gp.AddPolygon (points);
157 CheckInfiniteBounds (gp);
159 Region region = new Region (gp);
160 Assert.IsTrue (region.IsInfinite (graphic), "IsInfinite");
164 [Category ("NotWorking")]
165 public void Region_Rectangle_IsInfinite ()
167 GraphicsPath gp = new GraphicsPath ();
168 gp.AddRectangle (new Rectangle (-4194304, -4194304, 8388608, 8388608));
169 CheckInfiniteBounds (gp);
171 Region region = new Region (gp);
172 Assert.IsTrue (region.IsInfinite (graphic), "IsInfinite");
176 public void Curve_GetRegionScans ()
178 Point[] points = new Point[2] { new Point (-4194304, -4194304), new Point (4194304, 4194304) };
179 GraphicsPath gp = new GraphicsPath ();
180 gp.AddCurve (points);
181 Region region = new Region (gp);
182 // too big, returns 0
183 Assert.AreEqual (0, region.GetRegionScans (matrix).Length, "GetRegionScans");
186 private void DisplaySmallRegion (Region region, int ox, int oy, int width, int height)
188 for (int y = oy ; y < height - 1; y++) {
189 for (int x = ox; x < width - 1; x++) {
190 if (region.IsVisible (x, y))
195 Console.WriteLine ();
199 private void DisplaySmallRegion (Region region, int width, int height)
201 DisplaySmallRegion (region, -1, -1, width, height);
205 private void CompareSmallRegion (Region region, bool[] expected, int ox, int oy, int width, int height)
208 for (int y = oy; y < height + oy; y++) {
209 for (int x = ox; x < width + ox; x++) {
210 Assert.AreEqual (expected[p], region.IsVisible (x, y), String.Format ("{0},{1}", x, y));
216 private void CompareSmallRegion (Region region, bool[] expected, int width, int height)
218 CompareSmallRegion (region, expected, -1, -1, width, height);
221 private void CheckRectF (string msg, int x, int y, int w, int h, RectangleF rect)
223 Assert.AreEqual (x, rect.X, msg + ".X");
224 Assert.AreEqual (y, rect.Y, msg + ".Y");
225 Assert.AreEqual (w, rect.Width, msg + ".Width");
226 Assert.AreEqual (h, rect.Height, msg + ".Height");
229 static bool[] sunion = new bool[49] {
230 false, false, false, false, false, false, false, // .......
231 false, true, true, true, false, false, false, // .XXX...
232 false, true, true, true, false, false, false, // .XXX...
233 false, true, true, true, true, true, false, // .XXXXX.
234 false, false, false, true, true, true, false, // ...XXX.
235 false, false, false, true, true, true, false, // ...XXX.
236 false, false, false, false, false, false, false, // .......
240 public void SmallUnion1 ()
242 Region region = new Region (sp1);
244 CompareSmallRegion (region, sunion, 7, 7);
246 RectangleF[] scans = region.GetRegionScans (matrix);
247 Assert.AreEqual (3, scans.Length, "GetRegionScans");
248 CheckRectF ("[0]", 0, 0, 3, 2, scans[0]);
249 CheckRectF ("[1]", 0, 2, 5, 1, scans[1]);
250 CheckRectF ("[2]", 2, 3, 3, 2, scans[2]);
254 public void SmallUnion2 ()
256 Region region = new Region (sp2);
258 CompareSmallRegion (region, sunion, 7, 7);
260 RectangleF[] scans = region.GetRegionScans (matrix);
261 Assert.AreEqual (3, scans.Length, "GetRegionScans");
262 CheckRectF ("[0]", 0, 0, 3, 2, scans[0]);
263 CheckRectF ("[1]", 0, 2, 5, 1, scans[1]);
264 CheckRectF ("[2]", 2, 3, 3, 2, scans[2]);
267 static bool[] self1 = new bool[49] {
268 false, false, false, false, false, false, false, // .......
269 false, true, true, true, false, false, false, // .XXX...
270 false, true, true, true, false, false, false, // .XXX...
271 false, true, true, true, false, false, false, // .XXX...
272 false, false, false, false, false, false, false, // .......
273 false, false, false, false, false, false, false, // .......
274 false, false, false, false, false, false, false, // .......
278 public void SmallUnion_Self1 ()
280 Region region = new Region (sp1);
282 CompareSmallRegion (region, self1, 7, 7);
284 RectangleF[] scans = region.GetRegionScans (matrix);
285 Assert.AreEqual (1, scans.Length, "GetRegionScans");
286 CheckRectF ("[0]", 0, 0, 3, 3, scans[0]);
289 static bool[] self2 = new bool[49] {
290 false, false, false, false, false, false, false, // .......
291 false, false, false, false, false, false, false, // .......
292 false, false, false, false, false, false, false, // .......
293 false, false, false, true, true, true, false, // ...XXX.
294 false, false, false, true, true, true, false, // ...XXX.
295 false, false, false, true, true, true, false, // ...XXX.
296 false, false, false, false, false, false, false, // .......
300 public void SmallUnion_Self2 ()
302 Region region = new Region (sp2);
304 CompareSmallRegion (region, self2, 7, 7);
306 RectangleF[] scans = region.GetRegionScans (matrix);
307 Assert.AreEqual (1, scans.Length, "GetRegionScans");
308 CheckRectF ("[0]", 2, 2, 3, 3, scans[0]);
311 static bool[] sintersection = new bool[49] {
312 false, false, false, false, false, false, false, // .......
313 false, false, false, false, false, false, false, // .......
314 false, false, false, false, false, false, false, // .......
315 false, false, false, true, false, false, false, // ...X...
316 false, false, false, false, false, false, false, // .......
317 false, false, false, false, false, false, false, // .......
318 false, false, false, false, false, false, false, // .......
322 public void SmallIntersection1 ()
324 Region region = new Region (sp1);
325 region.Intersect (sp2);
326 CompareSmallRegion (region, sintersection, 7, 7);
328 RectangleF[] scans = region.GetRegionScans (matrix);
329 Assert.AreEqual (1, scans.Length, "GetRegionScans");
330 CheckRectF ("[0]", 2, 2, 1, 1, scans[0]);
334 public void SmallIntersection2 ()
336 Region region = new Region (sp2);
337 region.Intersect (sp1);
338 CompareSmallRegion (region, sintersection, 7, 7);
340 RectangleF[] scans = region.GetRegionScans (matrix);
341 Assert.AreEqual (1, scans.Length, "GetRegionScans");
342 CheckRectF ("[0]", 2, 2, 1, 1, scans[0]);
346 public void SmallIntersection_Self1 ()
348 Region region = new Region (sp1);
349 region.Intersect (sp1);
350 CompareSmallRegion (region, self1, 7, 7);
352 RectangleF[] scans = region.GetRegionScans (matrix);
353 Assert.AreEqual (1, scans.Length, "GetRegionScans");
354 CheckRectF ("[0]", 0, 0, 3, 3, scans[0]);
358 public void SmallIntersection_Self2 ()
360 Region region = new Region (sp2);
361 region.Intersect (sp2);
362 CompareSmallRegion (region, self2, 7, 7);
364 RectangleF[] scans = region.GetRegionScans (matrix);
365 Assert.AreEqual (1, scans.Length, "GetRegionScans");
366 CheckRectF ("[0]", 2, 2, 3, 3, scans[0]);
369 static bool[] sexclude1 = new bool[49] {
370 false, false, false, false, false, false, false, // .......
371 false, true, true, true, false, false, false, // .XXX...
372 false, true, true, true, false, false, false, // .XXX...
373 false, true, true, false, false, false, false, // .XX....
374 false, false, false, false, false, false, false, // .......
375 false, false, false, false, false, false, false, // .......
376 false, false, false, false, false, false, false, // .......
380 public void SmallExclude1 ()
382 Region region = new Region (sp1);
383 region.Exclude (sp2);
384 CompareSmallRegion (region, sexclude1, 7, 7);
386 RectangleF[] scans = region.GetRegionScans (matrix);
387 Assert.AreEqual (2, scans.Length, "GetRegionScans");
388 CheckRectF ("[0]", 0, 0, 3, 2, scans[0]);
389 CheckRectF ("[1]", 0, 2, 2, 1, scans[1]);
392 static bool[] sexclude2 = new bool[49] {
393 false, false, false, false, false, false, false, // .......
394 false, false, false, false, false, false, false, // .......
395 false, false, false, false, false, false, false, // .......
396 false, false, false, false, true, true, false, // ....XX.
397 false, false, false, true, true, true, false, // ...XXX.
398 false, false, false, true, true, true, false, // ...XXX.
399 false, false, false, false, false, false, false, // .......
403 public void SmallExclude2 ()
405 Region region = new Region (sp2);
406 region.Exclude (sp1);
407 CompareSmallRegion (region, sexclude2, 7, 7);
409 RectangleF[] scans = region.GetRegionScans (matrix);
410 Assert.AreEqual (2, scans.Length, "GetRegionScans");
411 CheckRectF ("[0]", 3, 2, 2, 1, scans[0]);
412 CheckRectF ("[1]", 2, 3, 3, 2, scans[1]);
415 static bool[] sempty = new bool[49] {
416 false, false, false, false, false, false, false, // .......
417 false, false, false, false, false, false, false, // .......
418 false, false, false, false, false, false, false, // .......
419 false, false, false, false, false, false, false, // .......
420 false, false, false, false, false, false, false, // .......
421 false, false, false, false, false, false, false, // .......
422 false, false, false, false, false, false, false, // .......
426 public void SmallExclude_Self1 ()
428 Region region = new Region (sp1);
429 region.Exclude (sp1);
430 CompareSmallRegion (region, sempty, 7, 7);
432 RectangleF[] scans = region.GetRegionScans (matrix);
433 Assert.AreEqual (0, scans.Length, "GetRegionScans");
437 public void SmallExclude_Self2 ()
439 Region region = new Region (sp2);
440 region.Exclude (sp2);
441 CompareSmallRegion (region, sempty, 7, 7);
443 RectangleF[] scans = region.GetRegionScans (matrix);
444 Assert.AreEqual (0, scans.Length, "GetRegionScans");
448 public void SmallComplement1 ()
450 Region region = new Region (sp1);
451 region.Complement (sp2);
452 CompareSmallRegion (region, sexclude2, 7, 7);
454 RectangleF[] scans = region.GetRegionScans (matrix);
455 Assert.AreEqual (2, scans.Length, "GetRegionScans");
456 CheckRectF ("[0]", 3, 2, 2, 1, scans[0]);
457 CheckRectF ("[1]", 2, 3, 3, 2, scans[1]);
461 public void SmallComplement2 ()
463 Region region = new Region (sp2);
464 region.Complement (sp1);
465 CompareSmallRegion (region, sexclude1, 7, 7);
467 RectangleF[] scans = region.GetRegionScans (matrix);
468 Assert.AreEqual (2, scans.Length, "GetRegionScans");
469 CheckRectF ("[0]", 0, 0, 3, 2, scans[0]);
470 CheckRectF ("[1]", 0, 2, 2, 1, scans[1]);
474 public void SmallComplement_Self1 ()
476 Region region = new Region (sp1);
477 region.Complement (sp1);
478 CompareSmallRegion (region, sempty, 7, 7);
480 RectangleF[] scans = region.GetRegionScans (matrix);
481 Assert.AreEqual (0, scans.Length, "GetRegionScans");
485 public void SmallComplement_Self2 ()
487 Region region = new Region (sp2);
488 region.Complement (sp2);
489 CompareSmallRegion (region, sempty, 7, 7);
491 RectangleF[] scans = region.GetRegionScans (matrix);
492 Assert.AreEqual (0, scans.Length, "GetRegionScans");
495 static bool[] sxor = new bool[49] {
496 false, false, false, false, false, false, false, // .......
497 false, true, true, true, false, false, false, // .XXX...
498 false, true, true, true, false, false, false, // .XXX...
499 false, true, true, false, true, true, false, // .XX.XX.
500 false, false, false, true, true, true, false, // ...XXX.
501 false, false, false, true, true, true, false, // ...XXX.
502 false, false, false, false, false, false, false, // .......
506 public void SmallXor1 ()
508 Region region = new Region (sp1);
510 CompareSmallRegion (region, sxor, 7, 7);
512 RectangleF[] scans = region.GetRegionScans (matrix);
513 Assert.AreEqual (4, scans.Length, "GetRegionScans");
514 CheckRectF ("[0]", 0, 0, 3, 2, scans[0]);
515 CheckRectF ("[1]", 0, 2, 2, 1, scans[1]);
516 CheckRectF ("[2]", 3, 2, 2, 1, scans[2]);
517 CheckRectF ("[3]", 2, 3, 3, 2, scans[3]);
521 public void SmallXor2 ()
523 Region region = new Region (sp2);
525 CompareSmallRegion (region, sxor, 7, 7);
527 RectangleF[] scans = region.GetRegionScans (matrix);
528 Assert.AreEqual (4, scans.Length, "GetRegionScans");
529 CheckRectF ("[0]", 0, 0, 3, 2, scans[0]);
530 CheckRectF ("[1]", 0, 2, 2, 1, scans[1]);
531 CheckRectF ("[2]", 3, 2, 2, 1, scans[2]);
532 CheckRectF ("[3]", 2, 3, 3, 2, scans[3]);
536 public void SmallXor_Self1 ()
538 Region region = new Region (sp1);
540 CompareSmallRegion (region, sempty, 7, 7);
542 RectangleF[] scans = region.GetRegionScans (matrix);
543 Assert.AreEqual (0, scans.Length, "GetRegionScans");
547 public void SmallXor_Self2 ()
549 Region region = new Region (sp2);
551 CompareSmallRegion (region, sempty, 7, 7);
553 RectangleF[] scans = region.GetRegionScans (matrix);
554 Assert.AreEqual (0, scans.Length, "GetRegionScans");
558 public void NegativeXor ()
560 GraphicsPath neg = new GraphicsPath ();
561 // identical result (matrix) of XOR but we're using negative coordinates
562 neg.AddPolygon (new Point[4] { new Point (-2, -2), new Point (1, -2), new Point (1, 1), new Point (-2, 1) });
564 Region region = new Region (sp1);
566 CompareSmallRegion (region, sxor, -3, -3, 7, 7);
569 static bool[] ni_union = new bool[55] {
570 false, false, false, false, false, false, false, false, false, false, false, // ...........
571 false, true, true, true, false, false, false, true, true, true, false, // .XXX...XXX.
572 false, true, true, true, false, false, false, true, true, true, false, // .XXX...XXX.
573 false, true, true, true, false, false, false, true, true, true, false, // .XXX...XXX.
574 false, false, false, false, false, false, false, false, false, false, false, // ...........
578 public void UnionWithoutIntersection ()
580 Region region = new Region (sp1);
582 CompareSmallRegion (region, ni_union, 11,5 );
586 // libgdiplus: both region are considered inside as intersecting rectangle because
587 // part of them co-exists in the same 8x8 bitmap. Full algorithm apply but results
588 // in an empty bitmap
589 public void IntersectionWithoutIntersection ()
591 Region region = new Region (sp1);
592 region.Intersect (sp3);
593 CompareSmallRegion (region, sempty, 7, 7);
597 // libgdiplus: no intersection results in an empty bitmap (optimization)
598 public void IntersectionWithoutIntersection_Large ()
600 Region region = new Region (sp1);
601 region.Intersect (sp4);
602 CompareSmallRegion (region, sempty, 7, 7);
606 // libgdiplus: both region are considered inside as intersecting rectangle because
607 // part of them co-exists in the same 8x8 bitmap. Full algorithm apply but results
609 public void ExcludeWithoutIntersection ()
611 Region region = new Region (sp1);
612 region.Exclude (sp3);
613 CompareSmallRegion (region, self1, 7, 7);
617 // libgdiplus: no intersection results in a clone of sp1 (optimization)
618 public void ExcludeWithoutIntersection_Large ()
620 Region region = new Region (sp1);
621 region.Exclude (sp4);
622 CompareSmallRegion (region, self1, 7, 7);
626 // libgdiplus: both region are considered inside as intersecting rectangle because
627 // part of them co-exists in the same 8x8 bitmap. Full algorithm apply but results
629 public void ComplementWithoutIntersection ()
631 Region region = new Region (sp3);
632 region.Complement (sp1);
633 CompareSmallRegion (region, self1, 7, 7);
637 // libgdiplus: no intersection results in a clone of sp1 (optimization)
638 public void ComplementWithoutIntersection_Large ()
640 Region region = new Region (sp4);
641 region.Complement (sp1);
642 CompareSmallRegion (region, self1, 7, 7);
646 // libgdiplus: both region are considered inside as intersecting rectangle because
647 // part of them co-exists in the same 8x8 bitmap.
648 public void XorWithoutIntersection ()
650 Region region = new Region (sp1);
652 CompareSmallRegion (region, ni_union, 11, 5);
655 static bool[] ni_xor = new bool[65] {
656 false, false, false, false, false, false, false, false, false, false, false, false, false, // .............
657 false, true, true, true, false, false, false, false, false, true, true, true, false, // .XXX.....XXX.
658 false, true, true, true, false, false, false, false, false, true, true, true, false, // .XXX.....XXX.
659 false, true, true, true, false, false, false, false, false, true, true, true, false, // .XXX.....XXX.
660 false, false, false, false, false, false, false, false, false, false, false, false, false, // .............
664 // libgdiplus: both region aren't considered as an intersection because they do
665 // not co-exists in the same 8x8 bitmap. In this case the xor function calls the
666 // union code (optimization).
667 public void XorWithoutIntersection_Large ()
669 Region region = new Region (sp1);
671 CompareSmallRegion (region, ni_xor, 13, 5);
675 public void IsEqual ()
677 Region r1 = new Region (sp1);
678 Region r2 = new Region (sp2);
679 Region r3 = new Region (sp3);
680 Region r4 = new Region (sp4);
682 Assert.IsTrue (r1.Equals (r1, graphic), "r1-r1");
683 Assert.IsTrue (r2.Equals (r2, graphic), "r2-r2");
684 Assert.IsTrue (r3.Equals (r3, graphic), "r3-r3");
685 Assert.IsTrue (r4.Equals (r4, graphic), "r4-r4");
687 Assert.IsFalse (r1.Equals (r4, graphic), "r1-r4");
688 Assert.IsFalse (r2.Equals (r3, graphic), "r2-r3");
689 Assert.IsFalse (r3.Equals (r2, graphic), "r3-r2");
690 Assert.IsFalse (r4.Equals (r1, graphic), "r4-r1");
691 // with same (not self)
692 Region r5 = r1.Clone ();
694 Assert.IsTrue (r1.Equals (r5, graphic), "r1-r5");
695 Assert.IsTrue (r5.Equals (r1, graphic), "r5-r1");
696 Assert.IsFalse (r5.Equals (r4, graphic), "r5-r4");
697 Assert.IsFalse (r4.Equals (r5, graphic), "r4-r5");
701 public void Translate_Int ()
703 Region r1 = new Region (sp1);
704 Region r2 = new Region (sp2);
705 r2.Translate (-2, -2);
707 CompareSmallRegion (r1, self1, 7, 7);
711 public void Translate_Float ()
713 Region r1 = new Region (sp1);
714 Region r2 = new Region (sp2);
715 r2.Translate (-2.0f, -2.0f);
717 CompareSmallRegion (r1, self1, 7, 7);
721 public void EmptyPathWithInfiniteRegion ()
723 GraphicsPath gp = new GraphicsPath ();
724 Region region = new Region ();
725 Assert.IsTrue (region.IsInfinite (graphic), "IsInfinite");
728 Assert.IsTrue (region.IsInfinite (graphic), "Union-IsInfinite");
731 Assert.IsTrue (region.IsInfinite (graphic), "Xor-IsInfinite");
734 Assert.IsTrue (region.IsInfinite (graphic), "Exclude-IsInfinite");
736 region.Intersect (gp);
737 Assert.IsTrue (region.IsEmpty (graphic), "Intersect-IsEmpty");
739 region.MakeInfinite ();
740 region.Complement (gp);
741 Assert.IsTrue (region.IsEmpty (graphic), "Complement-IsEmpty");
745 public void EmptyRegionWithInfiniteRegion ()
747 Region empty = new Region ();
749 Assert.IsTrue (empty.IsEmpty (graphic), "IsEmpty");
751 Region region = new Region ();
752 Assert.IsTrue (region.IsInfinite (graphic), "IsInfinite");
754 region.Union (empty);
755 Assert.IsTrue (region.IsInfinite (graphic), "Union-IsInfinite");
758 Assert.IsTrue (region.IsInfinite (graphic), "Xor-IsInfinite");
760 region.Exclude (empty);
761 Assert.IsTrue (region.IsInfinite (graphic), "Exclude-IsInfinite");
763 region.Intersect (empty);
764 Assert.IsTrue (region.IsEmpty (graphic), "Intersect-IsEmpty");
766 region.MakeInfinite ();
767 region.Complement (empty);
768 Assert.IsTrue (region.IsEmpty (graphic), "Complement-IsEmpty");