Java Rectangle rectCollide(final Rectangle a, final Rectangle b)

Here you can find the source of rectCollide(final Rectangle a, final Rectangle b)

Description

rect Collide

License

Open Source License

Declaration

public static boolean rectCollide(final Rectangle a, final Rectangle b) 

Method Source Code


//package com.java2s;
/* /*  w w w  .j  a  va  2s.c  o  m*/
 *  Copyright 2012 Samuel Taylor
 * 
 *  This file is part of darkFunction Editor
 *
 *  darkFunction Editor is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  darkFunction Editor is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
    
 *  You should have received a copy of the GNU General Public License
 *  along with darkFunction Editor.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.Rectangle;

public class Main {
    public static boolean rectCollide(final Rectangle a, final Rectangle b) {
        if (a.x > b.x + b.width || a.y > b.y + b.height || a.x + a.width < b.x || a.y + a.height < b.y) {
            return false;
        }
        return true;
    }
}

Related

  1. mergeRects(Set prev, Set current)
  2. normalizeRect(Rectangle rect)
  3. randomRectangle(int minW, int maxW, int minH, int maxH)
  4. randomSquare(int minW, int maxW)
  5. rectangleResize(Rectangle rect, int width, int height)
  6. rectDistance(final Rectangle r, final Rectangle q)
  7. rectFromArray(Rectangle2D aRectangle, double[] pts)
  8. rectFromRect2D(Rectangle2D rect)
  9. resetPosition(Window window1, Window window2)