/// <summary> /// Calculates the percentage of intersection of a rectangle. /// </summary> /// <param name="intersectingRect">The intersecting rectangle.</param> /// <returns>The percentage of intersection.</returns> public static double CalculateIntersectPercentage(this Rectangle rect, Rectangle intersectingRect) { if (rect.IsEmpty || intersectingRect.IsEmpty) { return(0); } Rectangle intersection = rect.CalculateIntersection(intersectingRect); return((intersection.Size.Width * intersection.Size.Height) / (rect.Size.Width * rect.Size.Height)); }