Indicates whether a point is within a rectangle or not. - Android java.lang

Android examples for java.lang:Math Geometry

Description

Indicates whether a point is within a rectangle or not.

Demo Code


//package com.java2s;
import android.graphics.PointF;
import android.graphics.RectF;

public class Main {
    /**//from w w  w  . j av  a 2s  . c o  m
     * Indicates whether a point is within a rectangle or not.
     *
     * @param rect The rectangle in which to look for the point.
     * @param point The point.
     * @return True if the point is in the rectangle.
     */
    public static boolean pointIsInRect(RectF rect, PointF point) {
        return (point.x >= rect.left && point.x <= rect.right
                && point.y >= rect.top && point.y <= rect.bottom);
    }
}

Related Tutorials