/// <summary> /// Returns the area of the intersection of the two specified <see cref="SKRect"/>. /// </summary> /// <returns>The area of the intersection.</returns> /// <param name="rect1">The first <see cref="SKRect"/>.</param> /// <param name="rect2">The second <see cref="SKRect"/>.</param> public static float Intersection(SKRect rect1, SKRect rect2) { var rect = new SKRect(rect1.Left, rect1.Top, rect1.Right, rect1.Bottom); rect.Intersect(rect2); return(rect.GetArea()); }
public void TestGetArea() { var result = _rect2.GetArea(); Assert.AreEqual(.2f * 500 * .2f * 600, result, Tolerance); }
/// <summary> /// Returns the area of the union of the two specified <see cref="SKRect"/>. /// </summary> /// <returns>The area of the union.</returns> /// <param name="rect1">The first <see cref="SKRect"/>.</param> /// <param name="rect2">The second <see cref="SKRect"/>.</param> public static float Union(SKRect rect1, SKRect rect2) { return(rect1.GetArea() + rect2.GetArea() - Intersection(rect1, rect2)); }