public static bool CCRectContainsPoint(CCRect rect, CCPoint point) { bool flag = false; if (rect != null) { if (float.IsNaN(point.x)) { point.x = 0f; } if (float.IsNaN(point.y)) { point.y = 0f; } CCRect.CCRectGetMinX(rect); CCRect.CCRectGetMaxX(rect); CCRect.CCRectGetMinY(rect); CCRect.CCRectGetMaxY(rect); if (point.x >= CCRect.CCRectGetMinX(rect) && point.x <= CCRect.CCRectGetMaxX(rect) && point.y >= CCRect.CCRectGetMinY(rect) && point.y <= CCRect.CCRectGetMaxY(rect)) { flag = true; } } return(flag); }
public static bool CCRectIntersetsRect(CCRect rectA, CCRect rectB) { bool flag = false; if (rectA != null && rectB != null) { flag = (CCRect.CCRectGetMaxX(rectA) < CCRect.CCRectGetMinX(rectB) || CCRect.CCRectGetMaxX(rectB) < CCRect.CCRectGetMinX(rectA) || CCRect.CCRectGetMaxY(rectA) < CCRect.CCRectGetMinY(rectB) ? false : CCRect.CCRectGetMaxY(rectB) >= CCRect.CCRectGetMinY(rectA)); } return(flag); }
public static CCRect CCRectApplyAffineTransform(CCRect rect, CCAffineTransform anAffineTransform) { float single = CCRect.CCRectGetMinY(rect); float single1 = CCRect.CCRectGetMinX(rect); float single2 = CCRect.CCRectGetMaxX(rect); float single3 = CCRect.CCRectGetMaxY(rect); CCPoint cCPoint = CCAffineTransform.CCPointApplyAffineTransform(new CCPoint(single1, single), anAffineTransform); CCPoint cCPoint1 = CCAffineTransform.CCPointApplyAffineTransform(new CCPoint(single2, single), anAffineTransform); CCPoint cCPoint2 = CCAffineTransform.CCPointApplyAffineTransform(new CCPoint(single1, single3), anAffineTransform); CCPoint cCPoint3 = CCAffineTransform.CCPointApplyAffineTransform(new CCPoint(single2, single3), anAffineTransform); float single4 = Math.Min(Math.Min(cCPoint.x, cCPoint1.x), Math.Min(cCPoint2.x, cCPoint3.x)); float single5 = Math.Max(Math.Max(cCPoint.x, cCPoint1.x), Math.Max(cCPoint2.x, cCPoint3.x)); float single6 = Math.Min(Math.Min(cCPoint.y, cCPoint1.y), Math.Min(cCPoint2.y, cCPoint3.y)); float single7 = Math.Max(Math.Max(cCPoint.y, cCPoint1.y), Math.Max(cCPoint2.y, cCPoint3.y)); return(new CCRect(single4, single6, single5 - single4, single7 - single6)); }
public static CCRect CCRectApplyAffineTransform(CCRect rect, CCAffineTransform anAffineTransform) { float top = CCRect.CCRectGetMinY(rect); float left = CCRect.CCRectGetMinX(rect); float right = CCRect.CCRectGetMaxX(rect); float bottom = CCRect.CCRectGetMaxY(rect); CCPoint topLeft = CCPointApplyAffineTransform(new CCPoint(left, top), anAffineTransform); CCPoint topRight = CCPointApplyAffineTransform(new CCPoint(right, top), anAffineTransform); CCPoint bottomLeft = CCPointApplyAffineTransform(new CCPoint(left, bottom), anAffineTransform); CCPoint bottomRight = CCPointApplyAffineTransform(new CCPoint(right, bottom), anAffineTransform); float minX = Math.Min(Math.Min(topLeft.x, topRight.x), Math.Min(bottomLeft.x, bottomRight.x)); float maxX = Math.Max(Math.Max(topLeft.x, topRight.x), Math.Max(bottomLeft.x, bottomRight.x)); float minY = Math.Min(Math.Min(topLeft.y, topRight.y), Math.Min(bottomLeft.y, bottomRight.y)); float maxY = Math.Max(Math.Max(topLeft.y, topRight.y), Math.Max(bottomLeft.y, bottomRight.y)); return(new CCRect(minX, minY, (maxX - minX), (maxY - minY))); }