public static PDFRect Union(PDFRect a, PDFRect b) { PDFUnit x = PDFUnit.Min(a.X, b.X); PDFUnit x2 = PDFUnit.Max(a.X + a.Width, b.X + b.Width); PDFUnit y = PDFUnit.Min(a.Y, b.Y); PDFUnit y2 = PDFUnit.Max(a.Y + a.Height, b.Y + b.Height); return(new PDFRect(x, y, x2 - x, y2 - y)); }
public static PDFRect Intersect(PDFRect a, PDFRect b) { PDFUnit x1 = PDFUnit.Max(a.X, b.X); PDFUnit x2 = PDFUnit.Min(a.X + a.Width, b.X + b.Width); PDFUnit y1 = PDFUnit.Max(a.Y, b.Y); PDFUnit y2 = PDFUnit.Min(a.Y + a.Height, b.Y + b.Height); if ((x2 >= x1) && (y2 >= y1)) { return(new PDFRect(x1, y1, x2 - x1, y2 - y1)); } else { return(PDFRect.Empty); } }